mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Use _ADD_
value for add...
and none
options
This commit is contained in:
parent
5a75440668
commit
f75e2f221c
@ -413,11 +413,8 @@ RED.editor = (function() {
|
|||||||
if (selectedOpt?.data('env')) {
|
if (selectedOpt?.data('env')) {
|
||||||
disableButton(addButton, true);
|
disableButton(addButton, true);
|
||||||
disableButton(editButton, true);
|
disableButton(editButton, true);
|
||||||
// disable the edit button if no options available
|
// disable the edit button if no options available or 'none' selected
|
||||||
} else if (optionsLength === 1 && selectedOpt.val() === "_ADD_") {
|
} else if (optionsLength === 1 || selectedOpt.val() === "_ADD_") {
|
||||||
disableButton(addButton, false);
|
|
||||||
disableButton(editButton, true);
|
|
||||||
} else if (selectedOpt.val() === "") {
|
|
||||||
disableButton(addButton, false);
|
disableButton(addButton, false);
|
||||||
disableButton(editButton, true);
|
disableButton(editButton, true);
|
||||||
} else {
|
} else {
|
||||||
@ -426,13 +423,9 @@ RED.editor = (function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const optionCount = select.find("option").length
|
// If the value is "", 'add new...' option if no config node available or 'none' option
|
||||||
if (optionCount === 1) {
|
// Otherwise, it's a config node
|
||||||
// We only have the 'add new...' option
|
select.val(nodeValue || '_ADD_');
|
||||||
select.val('_ADD_')
|
|
||||||
} else {
|
|
||||||
select.val(nodeValue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -933,9 +926,11 @@ RED.editor = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!configNodes.length) {
|
if (!configNodes.length) {
|
||||||
|
// Add 'add new...' option
|
||||||
select.append('<option value="_ADD_" selected>' + RED._("editor.addNewType", { type: label }) + '</option>');
|
select.append('<option value="_ADD_" selected>' + RED._("editor.addNewType", { type: label }) + '</option>');
|
||||||
} else {
|
} else {
|
||||||
select.append('<option value="">' + RED._("editor.inputs.none") + '</option>');
|
// Add 'none' option
|
||||||
|
select.append('<option value="_ADD_">' + RED._("editor.inputs.none") + '</option>');
|
||||||
}
|
}
|
||||||
|
|
||||||
window.setTimeout(function() { select.trigger("change");},50);
|
window.setTimeout(function() { select.trigger("change");},50);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user