diff --git a/beat/web/algorithms/templates/algorithms/edition.html b/beat/web/algorithms/templates/algorithms/edition.html index f97dfb546a03de4a79d5d6b3a6a81576eddd84be..91ebf64c877a613bcfb73ead50347cf1b1871144 100644 --- a/beat/web/algorithms/templates/algorithms/edition.html +++ b/beat/web/algorithms/templates/algorithms/edition.html @@ -184,7 +184,7 @@ function setupEditor(algorithm, dataformats, libraries) }); -{% if not binary %} +{% if not edition and not binary %} // Language radio buttons handling var language_python_selector = $('#language_python'); var language_cxx_selector = $('#language_cxx'); @@ -261,7 +261,7 @@ function setupEditor(algorithm, dataformats, libraries) if (declaration.parameters === null) return false; -{% if not binary %} +{% if not edition and not binary %} if (language_python_selector[0].checked) { declaration.uses = libraries_panel.getLibraries(displayErrors); @@ -288,8 +288,7 @@ function setupEditor(algorithm, dataformats, libraries) }; {% if not binary %} - if (language_python_selector[0].checked) - data.code = source_code_editor.getSourceCode(); + data.code = source_code_editor.getSourceCode(); {% endif %} diff --git a/beat/web/experiments/static/experiments/js/panels.js b/beat/web/experiments/static/experiments/js/panels.js index 1a6751c1224690f9a5998a38c44dc4aa20812b08..aa0912f34cc5bc0bbfb98ef2941555bf828bf996 100644 --- a/beat/web/experiments/static/experiments/js/panels.js +++ b/beat/web/experiments/static/experiments/js/panels.js @@ -1319,13 +1319,32 @@ beat.experiments.panels.Settings.prototype._setBlock = function(block_entry, alg if (beat.experiments.utils.analyzeCompatibility(block_inputs_signature, block_outputs_signature, algorithm_inputs_signature, algorithm_outputs_signature, panel.dataformats)) { - panel.current_block = block.name; - panel.configuration.setComponentAlgorithm(block, algorithm_name); - panel._onAlgorithmSelected(false); - automatically_configured_blocks.push(block); } } + + // Don't auto-assign a block that is connected after an auto-assigned one + var automatically_configured_blocks_original = [block_entry.block].concat(automatically_configured_blocks); + + automatically_configured_blocks = []; + for (var i = 1; i < automatically_configured_blocks_original.length; ++i) { + var block = automatically_configured_blocks_original[i]; + + var predecessors = block.allPredecessors(); + + var auto_assigned_predecessors = predecessors.filter(function(block) { + return automatically_configured_blocks_original.indexOf(block) >= 0; + }); + + if (auto_assigned_predecessors.length == 0) + { + panel.current_block = block.name; + panel.configuration.setComponentAlgorithm(block, algorithm_name); + panel._onAlgorithmSelected(false); + + automatically_configured_blocks.push(block); + } + } } // Mapping diff --git a/beat/web/toolchains/static/toolchains/js/editor.js b/beat/web/toolchains/static/toolchains/js/editor.js index 91af32e0473e3b798da7d845f6ebbb48f8ef4d4c..2a90b5c3971129cc5ac19d10dbc1cb9ebe87aaab 100644 --- a/beat/web/toolchains/static/toolchains/js/editor.js +++ b/beat/web/toolchains/static/toolchains/js/editor.js @@ -2659,7 +2659,7 @@ beat.toolchains.editor.ToolchainView.prototype._onMouseDown = function(event) var infos = this._getComponentAt(this.mouse_position.x, this.mouse_position.y); // On a connection: Display the channel selection dialog - if (infos.component instanceof beat.toolchains.common.ConnectionRepresentation) + if ((infos != null) && (infos.component instanceof beat.toolchains.common.ConnectionRepresentation)) { var entries = []; var valid_channels = infos.component.connection.output.block.inputs.map(function(x) { return x.channel; }).unique() diff --git a/beat/web/toolchains/static/toolchains/js/models.js b/beat/web/toolchains/static/toolchains/js/models.js index 67f9f05561fc940f81bd14443d3f9f02dea37350..ee21ca6902e2b819ef35f6bb808d970c4655c250 100644 --- a/beat/web/toolchains/static/toolchains/js/models.js +++ b/beat/web/toolchains/static/toolchains/js/models.js @@ -312,7 +312,36 @@ beat.toolchains.models.Block.prototype.predecessors = function() for (var i = 0; i < this.connections.length; i++) { if (this.connections[i].input.block == this) - predecessors.push(this.connections[i].output.block); + { + if (predecessors.indexOf(this) == -1) + predecessors.push(this.connections[i].output.block); + } + } + + return predecessors; +} + + +//---------------------------------------------------------------------------------------- +// Returns a list of all the blocks that precedes this one in the toolchain +//---------------------------------------------------------------------------------------- +beat.toolchains.models.Block.prototype.allPredecessors = function() +{ + var predecessors = new Array(); + + var direct_predecessors = this.predecessors(); + + var predecessors = [].concat(direct_predecessors); + + for (var i = 0; i < direct_predecessors.length; i++) + { + var upstream_predecessors = direct_predecessors[i].allPredecessors(); + + upstream_predecessors = upstream_predecessors.filter(function(block) { + return predecessors.indexOf(block) == -1; + }); + + predecessors = predecessors.concat(upstream_predecessors); } return predecessors; diff --git a/beat/web/toolchains/templates/toolchains/edition.html b/beat/web/toolchains/templates/toolchains/edition.html index 6970f352b1ffdacacb51b83b9c15fa5283332f77..25f6db4b3a7fe53348e56895f106ad57983f0936 100644 --- a/beat/web/toolchains/templates/toolchains/edition.html +++ b/beat/web/toolchains/templates/toolchains/edition.html @@ -205,7 +205,11 @@ function setupEditor(databases, toolchains) }; toolchain_editor.callbacks.onClose = function(declaration) { +{% if not edition %} + window.location = '{% url "toolchains:list" toolchain_author %}'; +{% else %} window.location = '{% url "toolchains:view" toolchain_author toolchain_name toolchain_version %}'; +{% endif %} }; }