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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @param node - the node being edited
|
||||
@ -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);
|
||||
}
|
||||
@ -635,23 +665,34 @@ RED.editor = (function() {
|
||||
}
|
||||
|
||||
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('<option value="'+config.id+'"'+(value==config.id?" selected":"")+'>'+label+'</option>');
|
||||
var button = $("#node-input-edit-"+name);
|
||||
if (button.length) {
|
||||
if (value) {
|
||||
button.text("edit");
|
||||
} else {
|
||||
button.text("add");
|
||||
}
|
||||
});
|
||||
$("#node-input-"+name).val(value);
|
||||
} else {
|
||||
|
||||
select.append('<option value="_ADD_"'+(value===""?" selected":"")+'>Add new '+type+'...</option>');
|
||||
window.setTimeout(function() { select.change();},50);
|
||||
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('<option value="'+config.id+'"'+(value==config.id?" selected":"")+'>'+label+'</option>');
|
||||
}
|
||||
});
|
||||
|
||||
select.append('<option value="_ADD_"'+(value===""?" selected":"")+'>Add new '+type+'...</option>');
|
||||
window.setTimeout(function() { select.change();},50);
|
||||
}
|
||||
}
|
||||
|
||||
$( "#node-config-dialog" ).dialog({
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user