mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Allow config nodes to be disabled, tidy css and add actions
This commit is contained in:
@@ -1500,6 +1500,8 @@ RED.editor = (function() {
|
||||
var trayFooterLeft = $('<div class="red-ui-tray-footer-left"></div>').appendTo(trayFooter)
|
||||
|
||||
$('<input id="node-input-node-disabled" type="checkbox">').prop("checked",!!node.d).appendTo(trayFooterLeft).toggleButton({
|
||||
enabledIcon: "fa-circle-thin",
|
||||
disabledIcon: "fa-ban",
|
||||
invertState: true
|
||||
})
|
||||
|
||||
@@ -1683,7 +1685,9 @@ RED.editor = (function() {
|
||||
|
||||
var trayFooterLeft = $('<div class="red-ui-tray-footer-left"></div>').appendTo(trayFooter)
|
||||
|
||||
$('<input type="checkbox">').appendTo(trayFooterLeft).toggleButton({
|
||||
$('<input id="node-config-input-node-disabled" type="checkbox">').prop("checked",!!editing_config_node.d).appendTo(trayFooterLeft).toggleButton({
|
||||
enabledIcon: "fa-circle-thin",
|
||||
disabledIcon: "fa-ban",
|
||||
invertState: true
|
||||
})
|
||||
|
||||
@@ -1918,6 +1922,16 @@ RED.editor = (function() {
|
||||
editing_config_node.label = configTypeDef.label;
|
||||
editing_config_node.z = scope;
|
||||
|
||||
if ($("#node-config-input-node-disabled").prop('checked')) {
|
||||
if (editing_config_node.d !== true) {
|
||||
editing_config_node.d = true;
|
||||
}
|
||||
} else {
|
||||
if (editing_config_node.d === true) {
|
||||
delete editing_config_node.d;
|
||||
}
|
||||
}
|
||||
|
||||
if (scope) {
|
||||
// Search for nodes that use this one that are no longer
|
||||
// in scope, so must be removed
|
||||
@@ -2072,7 +2086,7 @@ RED.editor = (function() {
|
||||
RED.nodes.eachConfig(function(config) {
|
||||
if (config.type == type && (!config.z || config.z === activeWorkspace.id)) {
|
||||
var label = RED.utils.getNodeLabel(config,config.id);
|
||||
config.__label__ = label;
|
||||
config.__label__ = label+(config.d?" ["+RED._("workspace.disabled")+"]":"");
|
||||
configNodes.push(config);
|
||||
}
|
||||
});
|
||||
|
@@ -145,7 +145,12 @@ RED.sidebar.config = (function() {
|
||||
var entry = $('<li class="red-ui-palette-node_id_'+node.id.replace(/\./g,"-")+'"></li>').appendTo(list);
|
||||
var nodeDiv = $('<div class="red-ui-palette-node-config red-ui-palette-node"></div>').appendTo(entry);
|
||||
entry.data('node',node.id);
|
||||
$('<div class="red-ui-palette-label"></div>').text(label).appendTo(nodeDiv);
|
||||
var label = $('<div class="red-ui-palette-label"></div>').text(label).appendTo(nodeDiv);
|
||||
if (node.d) {
|
||||
nodeDiv.addClass("red-ui-palette-node-config-disabled");
|
||||
$('<i class="fa fa-ban"></i>').prependTo(label);
|
||||
}
|
||||
|
||||
if (node._def.hasUsers !== false) {
|
||||
var iconContainer = $('<div/>',{class:"red-ui-palette-icon-container red-ui-palette-icon-container-right"}).appendTo(nodeDiv);
|
||||
if (node.users.length === 0) {
|
||||
|
@@ -410,6 +410,8 @@ RED.view = (function() {
|
||||
RED.actions.add("core:zoom-in",zoomIn);
|
||||
RED.actions.add("core:zoom-out",zoomOut);
|
||||
RED.actions.add("core:zoom-reset",zoomZero);
|
||||
RED.actions.add("core:enable-selected-nodes", function() { setSelectedNodeState(false)});
|
||||
RED.actions.add("core:disable-selected-nodes", function() { setSelectedNodeState(true)});
|
||||
|
||||
RED.actions.add("core:toggle-show-grid",function(state) {
|
||||
if (state === undefined) {
|
||||
@@ -2376,7 +2378,7 @@ RED.view = (function() {
|
||||
function isButtonEnabled(d) {
|
||||
var buttonEnabled = true;
|
||||
var ws = RED.nodes.workspace(RED.workspaces.active());
|
||||
if (ws && !ws.disabled) {
|
||||
if (ws && !ws.disabled && !d.d) {
|
||||
if (d._def.button.hasOwnProperty('enabled')) {
|
||||
if (typeof d._def.button.enabled === "function") {
|
||||
buttonEnabled = d._def.button.enabled.call(d);
|
||||
@@ -2397,7 +2399,7 @@ RED.view = (function() {
|
||||
}
|
||||
var activeWorkspace = RED.workspaces.active();
|
||||
var ws = RED.nodes.workspace(activeWorkspace);
|
||||
if (ws && !ws.disabled) {
|
||||
if (ws && !ws.disabled && !d.d) {
|
||||
if (d._def.button.toggle) {
|
||||
d[d._def.button.toggle] = !d[d._def.button.toggle];
|
||||
d.dirty = true;
|
||||
@@ -3580,6 +3582,48 @@ RED.view = (function() {
|
||||
//TODO: subscribe/unsubscribe here
|
||||
redraw();
|
||||
}
|
||||
function setSelectedNodeState(isDisabled) {
|
||||
if (mouse_mode === RED.state.SELECTING_NODE) {
|
||||
return;
|
||||
}
|
||||
var workspaceSelection = RED.workspaces.selection();
|
||||
var changed = false;
|
||||
if (workspaceSelection.length > 0) {
|
||||
// TODO: toggle workspace state
|
||||
} else if (moving_set.length > 0) {
|
||||
var historyEvents = [];
|
||||
for (var i=0;i<moving_set.length;i++) {
|
||||
var node = moving_set[i].n;
|
||||
if (isDisabled != node.d) {
|
||||
historyEvents.push({
|
||||
t: "edit",
|
||||
node: node,
|
||||
changed: node.changed,
|
||||
changes: {
|
||||
d: node.d
|
||||
}
|
||||
});
|
||||
if (isDisabled) {
|
||||
node.d = true;
|
||||
} else {
|
||||
delete node.d;
|
||||
}
|
||||
node.dirty = true;
|
||||
node.changed = true;
|
||||
}
|
||||
}
|
||||
if (historyEvents.length > 0) {
|
||||
RED.history.push({
|
||||
t:"multi",
|
||||
events: historyEvents,
|
||||
dirty:RED.nodes.dirty()
|
||||
})
|
||||
RED.nodes.dirty(true)
|
||||
}
|
||||
}
|
||||
RED.view.redraw();
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
init: init,
|
||||
|
@@ -201,8 +201,11 @@ RED.workspaces = (function() {
|
||||
} else {
|
||||
workspace.disabled = false;
|
||||
}
|
||||
$("#node-input-disabled").toggleButton({invertState: true})
|
||||
|
||||
$("#node-input-disabled").toggleButton({
|
||||
enabledIcon: "fa-circle-thin",
|
||||
disabledIcon: "fa-ban",
|
||||
invertState: true
|
||||
})
|
||||
|
||||
$('<input type="text" style="display: none;" />').prependTo(dialogForm);
|
||||
dialogForm.on("submit", function(e) { e.preventDefault();});
|
||||
|
Reference in New Issue
Block a user