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

Merge pull request #3239 from node-red/group-diff-fix

Group diff fix
This commit is contained in:
Nick O'Leary 2021-11-22 23:25:19 +00:00 committed by GitHub
commit 314c19650d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 8 deletions

View File

@ -1097,6 +1097,11 @@ RED.nodes = (function() {
// Until we know how that can happen, add a filter here to remove them // Until we know how that can happen, add a filter here to remove them
node.nodes = node.nodes.filter(function(n) { return !!n }).map(function(n) { return n.id }); node.nodes = node.nodes.filter(function(n) { return !!n }).map(function(n) { return n.id });
} }
if (n.type === "tab" || n.type === "group") {
if (node.env && node.env.length === 0) {
delete node.env;
}
}
if (n._def.category != "config") { if (n._def.category != "config") {
node.x = n.x; node.x = n.x;
node.y = n.y; node.y = n.y;

View File

@ -554,6 +554,8 @@ RED.diff = (function() {
color: "#DDAA99", color: "#DDAA99",
defaults:{name:{value:""}} defaults:{name:{value:""}}
} }
} else if (node.type === "group") {
def = RED.group.def;
} else { } else {
def = {}; def = {};
} }
@ -763,16 +765,15 @@ RED.diff = (function() {
} }
} }
if (node.hasOwnProperty('x')) { if (node.hasOwnProperty('x')) {
if (localNode) { if (localNode) {
if (localNode.x !== node.x || localNode.y !== node.y) { if (localNode.x !== node.x || localNode.y !== node.y || localNode.w !== node.w || localNode.h !== node.h ) {
localChanged = true; localChanged = true;
localChanges++; localChanges++;
} }
} }
if (remoteNode) { if (remoteNode) {
if (remoteNode.x !== node.x || remoteNode.y !== node.y) { if (remoteNode.x !== node.x || remoteNode.y !== node.y|| remoteNode.w !== node.w || remoteNode.h !== node.h) {
remoteChanged = true; remoteChanged = true;
remoteChanges++; remoteChanges++;
} }
@ -790,7 +791,12 @@ RED.diff = (function() {
localCell.addClass("red-ui-diff-status-"+(localChanged?"changed":"unchanged")); localCell.addClass("red-ui-diff-status-"+(localChanged?"changed":"unchanged"));
$('<span class="red-ui-diff-status">'+(localChanged?'<i class="fa fa-square"></i>':'')+'</span>').appendTo(localCell); $('<span class="red-ui-diff-status">'+(localChanged?'<i class="fa fa-square"></i>':'')+'</span>').appendTo(localCell);
element = $('<span class="red-ui-diff-list-element"></span>').appendTo(localCell); element = $('<span class="red-ui-diff-list-element"></span>').appendTo(localCell);
propertyElements['local.position'] = RED.utils.createObjectElement({x:localNode.x,y:localNode.y}, var localPosition = {x:localNode.x,y:localNode.y};
if (localNode.hasOwnProperty('w')) {
localPosition.w = localNode.w;
localPosition.h = localNode.h;
}
propertyElements['local.position'] = RED.utils.createObjectElement(localPosition,
{ {
path: "position", path: "position",
exposeApi: true, exposeApi: true,
@ -811,7 +817,12 @@ RED.diff = (function() {
if (remoteNode) { if (remoteNode) {
$('<span class="red-ui-diff-status">'+(remoteChanged?'<i class="fa fa-square"></i>':'')+'</span>').appendTo(remoteCell); $('<span class="red-ui-diff-status">'+(remoteChanged?'<i class="fa fa-square"></i>':'')+'</span>').appendTo(remoteCell);
element = $('<span class="red-ui-diff-list-element"></span>').appendTo(remoteCell); element = $('<span class="red-ui-diff-list-element"></span>').appendTo(remoteCell);
propertyElements['remote.position'] = RED.utils.createObjectElement({x:remoteNode.x,y:remoteNode.y}, var remotePosition = {x:remoteNode.x,y:remoteNode.y};
if (remoteNode.hasOwnProperty('w')) {
remotePosition.w = remoteNode.w;
remotePosition.h = remoteNode.h;
}
propertyElements['remote.position'] = RED.utils.createObjectElement(remotePosition,
{ {
path: "position", path: "position",
exposeApi: true, exposeApi: true,
@ -883,11 +894,11 @@ RED.diff = (function() {
} }
} }
} }
var properties = Object.keys(node).filter(function(p) { return p!='inputLabels'&&p!='outputLabels'&&p!='z'&&p!='wires'&&p!=='x'&&p!=='y'&&p!=='id'&&p!=='type'&&(!def.defaults||!def.defaults.hasOwnProperty(p))}); var properties = Object.keys(node).filter(function(p) { return p!='inputLabels'&&p!='outputLabels'&&p!='z'&&p!='wires'&&p!=='x'&&p!=='y'&&p!=='w'&&p!=='h'&&p!=='id'&&p!=='type'&&(!def.defaults||!def.defaults.hasOwnProperty(p))});
if (def.defaults) { if (def.defaults) {
properties = properties.concat(Object.keys(def.defaults)); properties = properties.concat(Object.keys(def.defaults));
} }
if (node.type !== 'tab') { if (node.type !== 'tab' && node.type !== "group") {
properties = properties.concat(['inputLabels','outputLabels']); properties = properties.concat(['inputLabels','outputLabels']);
} }
if ( ((localNode && localNode.hasOwnProperty('icon')) || (remoteNode && remoteNode.hasOwnProperty('icon'))) && if ( ((localNode && localNode.hasOwnProperty('icon')) || (remoteNode && remoteNode.hasOwnProperty('icon'))) &&

View File

@ -56,8 +56,12 @@
}); });
} }
if (!isSameObj(old_env, new_env)) { if (!isSameObj(old_env, new_env)) {
node.env = new_env;
editState.changes.env = node.env; editState.changes.env = node.env;
if (new_env.length === 0) {
delete node.env;
} else {
node.env = new_env;
}
editState.changed = true; editState.changed = true;
} }
} }