From 2d52527fb4dd2cc661c441d38149d51400066da2 Mon Sep 17 00:00:00 2001 From: Kazuki Nakanishi Date: Wed, 21 Mar 2018 05:39:46 +0900 Subject: [PATCH] Don't mark a subflow changed when actually modified nothing (#1665) --- editor/js/ui/deploy.js | 5 ++- editor/js/ui/editor.js | 90 ++++++++++++++++++++---------------------- editor/js/ui/view.js | 1 + 3 files changed, 48 insertions(+), 48 deletions(-) diff --git a/editor/js/ui/deploy.js b/editor/js/ui/deploy.js index 63305d2c2..a8c10930a 100644 --- a/editor/js/ui/deploy.js +++ b/editor/js/ui/deploy.js @@ -408,9 +408,12 @@ RED.deploy = (function() { delete confNode.credentials; } }); + RED.nodes.eachSubflow(function(subflow) { + subflow.changed = false; + }); RED.nodes.eachWorkspace(function(ws) { ws.changed = false; - }) + }); // Once deployed, cannot undo back to a clean state RED.history.markAllDirty(); RED.view.redraw(); diff --git a/editor/js/ui/editor.js b/editor/js/ui/editor.js index c3f0d4ea5..bf5b9bb49 100644 --- a/editor/js/ui/editor.js +++ b/editor/js/ui/editor.js @@ -819,6 +819,47 @@ RED.editor = (function() { selectIconModule.removeClass("input-error"); } + function updateLabels(editing_node, changes, outputMap) { + var inputLabels = $("#node-label-form-inputs").children().find("input"); + var outputLabels = $("#node-label-form-outputs").children().find("input"); + + var hasNonBlankLabel = false; + var changed = false; + var newValue = inputLabels.map(function() { + var v = $(this).val(); + hasNonBlankLabel = hasNonBlankLabel || v!== ""; + return v; + }).toArray().slice(0,editing_node.inputs); + if ((editing_node.inputLabels === undefined && hasNonBlankLabel) || + (editing_node.inputLabels !== undefined && JSON.stringify(newValue) !== JSON.stringify(editing_node.inputLabels))) { + changes.inputLabels = editing_node.inputLabels; + editing_node.inputLabels = newValue; + changed = true; + } + hasNonBlankLabel = false; + newValue = new Array(editing_node.outputs); + outputLabels.each(function() { + var index = $(this).attr('id').substring(23); // node-label-form-output- + if (outputMap && outputMap.hasOwnProperty(index)) { + index = parseInt(outputMap[index]); + if (index === -1) { + return; + } + } + var v = $(this).val(); + hasNonBlankLabel = hasNonBlankLabel || v!== ""; + newValue[index] = v; + }); + + if ((editing_node.outputLabels === undefined && hasNonBlankLabel) || + (editing_node.outputLabels !== undefined && JSON.stringify(newValue) !== JSON.stringify(editing_node.outputLabels))) { + changes.outputLabels = editing_node.outputLabels; + editing_node.outputLabels = newValue; + changed = true; + } + return changed; + } + function showEditDialog(node) { var editing_node = node; var isDefaultIcon; @@ -1034,40 +1075,7 @@ RED.editor = (function() { // } var removedLinks = updateNodeProperties(editing_node,outputMap); - var inputLabels = $("#node-label-form-inputs").children().find("input"); - var outputLabels = $("#node-label-form-outputs").children().find("input"); - - var hasNonBlankLabel = false; - newValue = inputLabels.map(function() { - var v = $(this).val(); - hasNonBlankLabel = hasNonBlankLabel || v!== ""; - return v; - }).toArray().slice(0,editing_node.inputs); - if ((editing_node.inputLabels === undefined && hasNonBlankLabel) || - (editing_node.inputLabels !== undefined && JSON.stringify(newValue) !== JSON.stringify(editing_node.inputLabels))) { - changes.inputLabels = editing_node.inputLabels; - editing_node.inputLabels = newValue; - changed = true; - } - hasNonBlankLabel = false; - newValue = new Array(editing_node.outputs); - outputLabels.each(function() { - var index = $(this).attr('id').substring(23); // node-label-form-output- - if (outputMap && outputMap.hasOwnProperty(index)) { - index = parseInt(outputMap[index]); - if (index === -1) { - return; - } - } - var v = $(this).val(); - hasNonBlankLabel = hasNonBlankLabel || v!== ""; - newValue[index] = v; - }) - - if ((editing_node.outputLabels === undefined && hasNonBlankLabel) || - (editing_node.outputLabels !== undefined && JSON.stringify(newValue) !== JSON.stringify(editing_node.outputLabels))) { - changes.outputLabels = editing_node.outputLabels; - editing_node.outputLabels = newValue; + if (updateLabels(editing_node, changes, outputMap)) { changed = true; } @@ -1675,19 +1683,7 @@ RED.editor = (function() { editing_node.info = newDescription; changed = true; } - var inputLabels = $("#node-label-form-inputs").children().find("input"); - var outputLabels = $("#node-label-form-outputs").children().find("input"); - - var newValue = inputLabels.map(function() { return $(this).val();}).toArray().slice(0,editing_node.inputs); - if (JSON.stringify(newValue) !== JSON.stringify(editing_node.inputLabels)) { - changes.inputLabels = editing_node.inputLabels; - editing_node.inputLabels = newValue; - changed = true; - } - newValue = outputLabels.map(function() { return $(this).val();}).toArray().slice(0,editing_node.outputs); - if (JSON.stringify(newValue) !== JSON.stringify(editing_node.outputLabels)) { - changes.outputLabels = editing_node.outputLabels; - editing_node.outputLabels = newValue; + if (updateLabels(editing_node, changes, null)) { changed = true; } diff --git a/editor/js/ui/view.js b/editor/js/ui/view.js index c685e852e..ba568459c 100644 --- a/editor/js/ui/view.js +++ b/editor/js/ui/view.js @@ -490,6 +490,7 @@ RED.view = (function() { } } else { var subflow = RED.nodes.subflow(m[1]); + nn.name = ""; nn.inputs = subflow.in.length; nn.outputs = subflow.out.length; }