mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add support for exclusive config nodes
This commit is contained in:
parent
7dc838dea6
commit
913fdac671
@ -380,6 +380,32 @@ RED.editor = (function() {
|
|||||||
input.val(label);
|
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 = $("<a>",{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
|
* Populate the editor dialog input field for this property
|
||||||
* @param node - the node being edited
|
* @param node - the node being edited
|
||||||
@ -493,7 +519,11 @@ RED.editor = (function() {
|
|||||||
for (var d in definition.defaults) {
|
for (var d in definition.defaults) {
|
||||||
if (definition.defaults.hasOwnProperty(d)) {
|
if (definition.defaults.hasOwnProperty(d)) {
|
||||||
if (definition.defaults[d].type) {
|
if (definition.defaults[d].type) {
|
||||||
|
if (definition.defaults[d].exclusive) {
|
||||||
|
prepareConfigNodeButton(node,d,definition.defaults[d].type);
|
||||||
|
} else {
|
||||||
prepareConfigNodeSelect(node,d,definition.defaults[d].type);
|
prepareConfigNodeSelect(node,d,definition.defaults[d].type);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
preparePropertyEditor(node,d,prefix);
|
preparePropertyEditor(node,d,prefix);
|
||||||
}
|
}
|
||||||
@ -635,6 +665,16 @@ RED.editor = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateConfigNodeSelect(name,type,value) {
|
function updateConfigNodeSelect(name,type,value) {
|
||||||
|
var button = $("#node-input-edit-"+name);
|
||||||
|
if (button.length) {
|
||||||
|
if (value) {
|
||||||
|
button.text("edit");
|
||||||
|
} else {
|
||||||
|
button.text("add");
|
||||||
|
}
|
||||||
|
$("#node-input-"+name).val(value);
|
||||||
|
} else {
|
||||||
|
|
||||||
var select = $("#node-input-"+name);
|
var select = $("#node-input-"+name);
|
||||||
var node_def = RED.nodes.getType(type);
|
var node_def = RED.nodes.getType(type);
|
||||||
select.children().remove();
|
select.children().remove();
|
||||||
@ -653,6 +693,7 @@ RED.editor = (function() {
|
|||||||
select.append('<option value="_ADD_"'+(value===""?" selected":"")+'>Add new '+type+'...</option>');
|
select.append('<option value="_ADD_"'+(value===""?" selected":"")+'>Add new '+type+'...</option>');
|
||||||
window.setTimeout(function() { select.change();},50);
|
window.setTimeout(function() { select.change();},50);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$( "#node-config-dialog" ).dialog({
|
$( "#node-config-dialog" ).dialog({
|
||||||
modal: true,
|
modal: true,
|
||||||
|
@ -162,7 +162,7 @@
|
|||||||
name: {value:""},
|
name: {value:""},
|
||||||
url: {value:"",required:true},
|
url: {value:"",required:true},
|
||||||
method: {value:"get",required:true},
|
method: {value:"get",required:true},
|
||||||
swaggerDoc: {type:"swagger-doc", required:false}
|
swaggerDoc: {type:"swagger-doc", exclusive:true, required:false}
|
||||||
},
|
},
|
||||||
inputs:0,
|
inputs:0,
|
||||||
outputs:1,
|
outputs:1,
|
||||||
|
Loading…
Reference in New Issue
Block a user