diff --git a/editor/js/ui/editor.js b/editor/js/ui/editor.js index a594064a4..1a2cc2b8d 100644 --- a/editor/js/ui/editor.js +++ b/editor/js/ui/editor.js @@ -379,6 +379,32 @@ RED.editor = (function() { } input.val(label); } + + /** + * Create a config-node button for this property + * @param node - the node being edited + * @param property - the name of the field + * @param type - the type of the config-node + */ + function prepareConfigNodeButton(node,property,type) { + var input = $("#node-input-"+property); + input.val(node[property]); + input.attr("type","hidden"); + + var button = $("",{id:"node-input-edit-"+property, class:"btn"}); + input.after(button); + + if (node[property]) { + button.text("edit"); + } else { + button.text("add"); + } + + button.click(function(e) { + showEditConfigNodeDialog(property,type,input.val()||"_ADD_"); + e.preventDefault(); + }); + } /** * Populate the editor dialog input field for this property @@ -493,7 +519,11 @@ RED.editor = (function() { for (var d in definition.defaults) { if (definition.defaults.hasOwnProperty(d)) { if (definition.defaults[d].type) { - prepareConfigNodeSelect(node,d,definition.defaults[d].type); + if (definition.defaults[d].exclusive) { + prepareConfigNodeButton(node,d,definition.defaults[d].type); + } else { + prepareConfigNodeSelect(node,d,definition.defaults[d].type); + } } else { preparePropertyEditor(node,d,prefix); } @@ -633,25 +663,36 @@ RED.editor = (function() { .dialog("option","title",(adding?"Add new ":"Edit ")+type+" config node") .dialog( "open" ); } - + function updateConfigNodeSelect(name,type,value) { - var select = $("#node-input-"+name); - var node_def = RED.nodes.getType(type); - select.children().remove(); - RED.nodes.eachConfig(function(config) { - if (config.type == type) { - var label = ""; - if (typeof node_def.label == "function") { - label = node_def.label.call(config); - } else { - label = node_def.label; - } - select.append(''); + var button = $("#node-input-edit-"+name); + if (button.length) { + if (value) { + button.text("edit"); + } else { + button.text("add"); } - }); - - select.append(''); - window.setTimeout(function() { select.change();},50); + $("#node-input-"+name).val(value); + } else { + + var select = $("#node-input-"+name); + var node_def = RED.nodes.getType(type); + select.children().remove(); + RED.nodes.eachConfig(function(config) { + if (config.type == type) { + var label = ""; + if (typeof node_def.label == "function") { + label = node_def.label.call(config); + } else { + label = node_def.label; + } + select.append(''); + } + }); + + select.append(''); + window.setTimeout(function() { select.change();},50); + } } $( "#node-config-dialog" ).dialog({ diff --git a/nodes/core/io/21-httpin.html b/nodes/core/io/21-httpin.html index 2a089b308..7926fc57c 100644 --- a/nodes/core/io/21-httpin.html +++ b/nodes/core/io/21-httpin.html @@ -162,7 +162,7 @@ name: {value:""}, url: {value:"",required:true}, method: {value:"get",required:true}, - swaggerDoc: {type:"swagger-doc", required:false} + swaggerDoc: {type:"swagger-doc", exclusive:true, required:false} }, inputs:0, outputs:1,