mirror of
https://github.com/node-red/node-red
synced 2024-11-21 23:48:30 +00:00
Merge pull request #4800 from GogoVega/fix-config-select
Use `_ADD_` value for both `add new...` and `none` options
This commit is contained in:
commit
830e475969
@ -413,11 +413,8 @@ RED.editor = (function() {
|
||||
if (selectedOpt?.data('env')) {
|
||||
disableButton(addButton, true);
|
||||
disableButton(editButton, true);
|
||||
// disable the edit button if no options available
|
||||
} else if (optionsLength === 1 && selectedOpt.val() === "_ADD_") {
|
||||
disableButton(addButton, false);
|
||||
disableButton(editButton, true);
|
||||
} else if (selectedOpt.val() === "") {
|
||||
// disable the edit button if no options available or 'none' selected
|
||||
} else if (optionsLength === 1 || selectedOpt.val() === "_ADD_") {
|
||||
disableButton(addButton, false);
|
||||
disableButton(editButton, true);
|
||||
} else {
|
||||
@ -426,13 +423,9 @@ RED.editor = (function() {
|
||||
}
|
||||
});
|
||||
|
||||
const optionCount = select.find("option").length
|
||||
if (optionCount === 1) {
|
||||
// We only have the 'add new...' option
|
||||
select.val('_ADD_')
|
||||
} else {
|
||||
select.val(nodeValue);
|
||||
}
|
||||
// If the value is "", 'add new...' option if no config node available or 'none' option
|
||||
// Otherwise, it's a config node
|
||||
select.val(nodeValue || '_ADD_');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -933,9 +926,11 @@ RED.editor = (function() {
|
||||
}
|
||||
|
||||
if (!configNodes.length) {
|
||||
// Add 'add new...' option
|
||||
select.append('<option value="_ADD_" selected>' + RED._("editor.addNewType", { type: label }) + '</option>');
|
||||
} 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);
|
||||
|
Loading…
Reference in New Issue
Block a user