1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge pull request #3382 from node-red-hitachi/fix-subflow-update

fix opening/closing subflow template not to make subflow changed
This commit is contained in:
Nick O'Leary 2022-01-27 09:30:26 +00:00 committed by GitHub
commit 3304ebe9d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,9 +35,10 @@
editState.changed = true; editState.changed = true;
} }
if (!node._def.defaults || !node._def.defaults.hasOwnProperty("icon")) { if (!node._def.defaults || !node._def.defaults.hasOwnProperty("icon")) {
var icon = $("#red-ui-editor-node-icon").val()||"" var icon = $("#red-ui-editor-node-icon").val()||"";
if (!this.isDefaultIcon) { if (!this.isDefaultIcon) {
if (icon !== node.icon) { if ((icon !== node.icon) &&
(icon !== "")) {
editState.changes.icon = node.icon; editState.changes.icon = node.icon;
node.icon = icon; node.icon = icon;
editState.changed = true; editState.changed = true;
@ -101,14 +102,14 @@
if (showLabel) { if (showLabel) {
// Default to show label // Default to show label
if (node.l !== false) { if (node.l !== false) {
editState.changes.l = node.l editState.changes.l = node.l;
editState.changed = true; editState.changed = true;
} }
node.l = false; node.l = false;
} else { } else {
// Node has showLabel:false (eg link nodes) // Node has showLabel:false (eg link nodes)
if (node.hasOwnProperty('l') && node.l) { if (node.hasOwnProperty('l') && node.l) {
editState.changes.l = node.l editState.changes.l = node.l;
editState.changed = true; editState.changed = true;
} }
delete node.l; delete node.l;
@ -118,20 +119,20 @@
if (showLabel) { if (showLabel) {
// Default to show label // Default to show label
if (node.hasOwnProperty('l') && !node.l) { if (node.hasOwnProperty('l') && !node.l) {
editState.changes.l = node.l editState.changes.l = node.l;
editState.changed = true; editState.changed = true;
} }
delete node.l; delete node.l;
} else { } else {
if (!node.l) { if (!node.l) {
editState.changes.l = node.l editState.changes.l = node.l;
editState.changed = true; editState.changed = true;
} }
node.l = true; node.l = true;
} }
} }
} }
} };
}); });
function buildAppearanceForm(container,node) { function buildAppearanceForm(container,node) {
@ -164,10 +165,10 @@
var categories = RED.palette.getCategories(); var categories = RED.palette.getCategories();
categories.sort(function(A,B) { categories.sort(function(A,B) {
return A.label.localeCompare(B.label); return A.label.localeCompare(B.label);
}) });
categories.forEach(function(cat) { categories.forEach(function(cat) {
categorySelector.append($("<option/>").val(cat.id).text(cat.label)); categorySelector.append($("<option/>").val(cat.id).text(cat.label));
}) });
categorySelector.append($("<option/>").attr('disabled',true).text("---")); categorySelector.append($("<option/>").attr('disabled',true).text("---"));
categorySelector.append($("<option/>").val("_custom_").text(RED._("palette.addCategory"))); categorySelector.append($("<option/>").val("_custom_").text(RED._("palette.addCategory")));
@ -180,7 +181,7 @@
$("#subflow-appearance-input-category").width(250); $("#subflow-appearance-input-category").width(250);
$("#subflow-appearance-input-custom-category").hide(); $("#subflow-appearance-input-custom-category").hide();
} }
}) });
$("#subflow-appearance-input-category").val(node.category||"subflows"); $("#subflow-appearance-input-category").val(node.category||"subflows");
var userCount = 0; var userCount = 0;
@ -204,7 +205,7 @@
$("#node-input-show-label").toggleButton({ $("#node-input-show-label").toggleButton({
enabledLabel: RED._("editor.show"), enabledLabel: RED._("editor.show"),
disabledLabel: RED._("editor.hide") disabledLabel: RED._("editor.hide")
}) });
if (!node.hasOwnProperty("l")) { if (!node.hasOwnProperty("l")) {
// Show label unless def.showLabel set to false // Show label unless def.showLabel set to false
@ -230,7 +231,7 @@
"#E9967A", "#F3B567", "#FDD0A2", "#E9967A", "#F3B567", "#FDD0A2",
"#FDF0C2", "#FFAAAA", "#FFCC66", "#FDF0C2", "#FFAAAA", "#FFCC66",
"#FFF0F0", "#FFFFFF" "#FFF0F0", "#FFFFFF"
] ];
RED.editor.colorPicker.create({ RED.editor.colorPicker.create({
id: "red-ui-editor-node-color", id: "red-ui-editor-node-color",
@ -245,9 +246,9 @@
nodeDiv.css('backgroundColor',colour); nodeDiv.css('backgroundColor',colour);
var borderColor = RED.utils.getDarkerColor(colour); var borderColor = RED.utils.getDarkerColor(colour);
if (borderColor !== colour) { if (borderColor !== colour) {
nodeDiv.css('border-color',borderColor) nodeDiv.css('border-color',borderColor);
} }
}) });
} }
@ -264,7 +265,7 @@
nodeDiv.css('backgroundColor',colour); nodeDiv.css('backgroundColor',colour);
var borderColor = RED.utils.getDarkerColor(colour); var borderColor = RED.utils.getDarkerColor(colour);
if (borderColor !== colour) { if (borderColor !== colour) {
nodeDiv.css('border-color',borderColor) nodeDiv.css('border-color',borderColor);
} }
var iconContainer = $('<div/>',{class:"red-ui-palette-icon-container"}).appendTo(nodeDiv); var iconContainer = $('<div/>',{class:"red-ui-palette-icon-container"}).appendTo(nodeDiv);
@ -292,7 +293,7 @@
RED.popover.tooltip(iconButton, function() { RED.popover.tooltip(iconButton, function() {
return $("#red-ui-editor-node-icon").val() || RED._("editor.default"); return $("#red-ui-editor-node-icon").val() || RED._("editor.default");
}) });
$('<input type="hidden" id="red-ui-editor-node-icon">').val(node.icon).appendTo(iconRow); $('<input type="hidden" id="red-ui-editor-node-icon">').val(node.icon).appendTo(iconRow);
} }
@ -417,11 +418,11 @@
}); });
rows.sort(function(A,B) { rows.sort(function(A,B) {
return A.i-B.i; return A.i-B.i;
}) });
rows.forEach(function(r,i) { rows.forEach(function(r,i) {
r.r.find("label").text((i+1)+"."); r.r.find("label").text((i+1)+".");
r.r.appendTo(outputsDiv); r.r.appendTo(outputsDiv);
}) });
if (rows.length === 0) { if (rows.length === 0) {
buildLabelRow("output",i,"").appendTo(outputsDiv); buildLabelRow("output",i,"").appendTo(outputsDiv);
} else { } else {
@ -467,7 +468,7 @@
clear.on("click", function(evt) { clear.on("click", function(evt) {
evt.preventDefault(); evt.preventDefault();
input.val(""); input.val("");
}) });
} }
return result; return result;
} }