diff --git a/beat/web/experiments/static/experiments/js/panels.js b/beat/web/experiments/static/experiments/js/panels.js index c07d00c6ecd9625cf02523a616a5b70a8babda4a..1a6751c1224690f9a5998a38c44dc4aa20812b08 100644 --- a/beat/web/experiments/static/experiments/js/panels.js +++ b/beat/web/experiments/static/experiments/js/panels.js @@ -923,6 +923,32 @@ beat.experiments.panels.Settings.prototype._onAlgorithmSelected = function(by_us var algorithm_name = this.configuration.componentAlgorithm(this.current_block); block_entry.algorithm = this.algorithms.get(algorithm_name); + // Update the environment if necessary + var block_env = this.configuration.blockEnvironment(this.current_block); + var default_env = this.configuration.defaultEnvironment(); + + if (!this.environments[block_entry.algorithm.language].contains(block_env.name, block_env.version)) + { + if (!this.environments[block_entry.algorithm.language].contains(default_env.name, default_env.version)) + { + var env = this.environments[block_entry.algorithm.language].getByIndex(0); + + var config_env = { + name: env.name, + version: env.version, + }; + this.configuration.setBlockEnvironment(this.current_block, config_env); + } + else + { + this.configuration.resetBlockEnvironmentAndQueue(this.current_block); + } + } + else if ((block_env.name == default_env.name) && (block_env.version == default_env.version)) + { + this.configuration.resetBlockEnvironmentAndQueue(this.current_block); + } + // Update the selection controls $(block_entry.algorithm_element).find('option').remove(); var option = $(document.createElement('option'));