From 6b03379e4ecc6d72d117842fbd45e9ac6b5ab9fe Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Wed, 22 Jul 2015 22:28:30 +0100 Subject: [PATCH] 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 --- editor/js/ui/editor.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/editor/js/ui/editor.js b/editor/js/ui/editor.js index 39edf883e..ef5dca742 100644 --- a/editor/js/ui/editor.js +++ b/editor/js/ui/editor.js @@ -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" ); }