Allow user to disable the node button

pull/5150/head
GogoVega 2025-06-04 09:46:23 +02:00
parent 30215b02ac
commit 1f8836cd5f
No known key found for this signature in database
GPG Key ID: E1E048B63AC5AC2B
4 changed files with 40 additions and 2 deletions

View File

@ -445,6 +445,7 @@
}
},
"editor": {
"button": "Button",
"configEdit": "Edit",
"configAdd": "Add",
"configUpdate": "Update",
@ -468,6 +469,8 @@
"searchIcons": "Search icons",
"useDefault": "use default",
"description": "Description",
"disabled": "Disabled",
"enabled": "Enabled",
"show": "Show",
"hide": "Hide",
"locale": "Select UI Language",

View File

@ -1377,6 +1377,9 @@ RED.nodes = (function() {
node.l = n.l;
}
}
if (n._def.button && n.hasOwnProperty("b") && n.b) {
node.b = true;
}
}
if (n.info) {
node.info = n.info;
@ -2337,6 +2340,9 @@ RED.nodes = (function() {
if (n.hasOwnProperty('g')) {
node.g = n.g;
}
if (n.hasOwnProperty('b')) {
node.b = n.b;
}
if (options.markChanged) {
node.changed = true
}

View File

@ -130,6 +130,20 @@
node.l = true;
}
}
if (node._def.button) {
if ($("#node-input-enable-button").prop("checked")) {
if (node.hasOwnProperty("b") && node.b) {
editState.changes.b = node.b;
editState.changed = true;
delete node.b;
}
} else if (!node.b) {
editState.changes.b = node.b;
editState.changed = true;
node.b = true;
}
}
}
};
});
@ -195,6 +209,21 @@
.text(RED._("subflow.subflowInstances", {count:node.instances.length})).show();
}
if (node._def.button) {
$('<div class="form-row">'+
'<label for="node-input-enable-button" data-i18n="editor.button"></label>'+
'<span style="margin-right: 2px;"/>'+
'<input type="checkbox" id="node-input-enable-button"/>'+
'</div>').appendTo(dialogForm);
$("#node-input-enable-button").toggleButton({
enabledLabel: RED._("editor.enabled"),
disabledLabel: RED._("editor.disabled")
});
$("#node-input-enable-button").prop("checked", !node.b).trigger("change");
}
$('<div class="form-row">'+
'<label for="node-input-show-label" data-i18n="editor.label"></label>'+
'<span style="margin-right: 2px;"/>'+

View File

@ -4126,7 +4126,7 @@ RED.view = (function() {
function isButtonEnabled(d) {
var buttonEnabled = true;
var ws = RED.nodes.workspace(RED.workspaces.active());
if (ws && !ws.disabled && !d.d && !ws.locked) {
if (ws && !ws.disabled && !d.d && !d.b && !ws.locked) {
if (d._def.button.hasOwnProperty('enabled')) {
if (typeof d._def.button.enabled === "function") {
buttonEnabled = d._def.button.enabled.call(d);
@ -4149,7 +4149,7 @@ RED.view = (function() {
}
var activeWorkspace = RED.workspaces.active();
var ws = RED.nodes.workspace(activeWorkspace);
if (ws && !ws.disabled && !d.d && !ws.locked) {
if (ws && !ws.disabled && !d.d && !d.b && !ws.locked) {
if (d._def.button.toggle) {
d[d._def.button.toggle] = !d[d._def.button.toggle];
d.dirty = true;