Ensure exclusive conf node is removed on edit cancel

- If an exclusive conf node was added to a node, but the
   node's own edit dialog was canceled, the conf node remained
   but not associated with the node - effectively orphaning it
This commit is contained in:
Nick O'Leary 2015-07-22 22:28:30 +01:00
parent 08d687ad60
commit 6b03379e4e
1 changed files with 22 additions and 0 deletions

View File

@ -303,6 +303,28 @@ RED.editor = (function() {
if (editing_node._def.oneditcancel) {
editing_node._def.oneditcancel.call(editing_node);
}
for (var d in editing_node._def.defaults) {
if (editing_node._def.defaults.hasOwnProperty(d)) {
var def = editing_node._def.defaults[d];
if (def.type) {
var configTypeDef = RED.nodes.getType(def.type);
if (configTypeDef && configTypeDef.exclusive) {
var input = $("#node-input-"+d).val()||"";
if (input !== "" && !editing_node[d]) {
// This node has an exclusive config node that
// has just been added. As the user is cancelling
// the edit, need to delete the just-added config
// node so that it doesn't get orphaned.
RED.nodes.remove(input);
}
}
}
}
}
}
$( this ).dialog( "close" );
}