Add handling to disable items on context menu for node labels

This commit is contained in:
Kazuhito Yokoi 2023-12-29 17:51:03 +09:00
parent 70ea5c839a
commit aaed9882b8

View File

@ -34,6 +34,8 @@ RED.contextMenu = (function () {
const hasGroup = hasSelection && selection.nodes.filter(n => n.type === 'group').length > 0
const hasDisabledNode = hasSelection && selection.nodes.filter(e => e.d).length > 0;
const hasEnabledNode = hasSelection && selection.nodes.filter(e => !e.d).length > 0;
const hasUnlabeledNode = hasSelection && selection.nodes.filter(e => e.l === false).length > 0;
const hasLabeledNode = hasSelection && selection.nodes.filter(e => e.l || e.l === undefined).length > 0;
const offset = $("#red-ui-workspace-chart").offset()
let addX = options.x - offset.left + $("#red-ui-workspace-chart").scrollLeft()
@ -118,8 +120,8 @@ RED.contextMenu = (function () {
{ onselect: 'core:enable-selected-nodes', label: RED._('menu.label.enableSelectedNodes'), disabled: !hasDisabledNode },
{ onselect: 'core:disable-selected-nodes', label: RED._('menu.label.disableSelectedNodes'), disabled: !hasEnabledNode },
null,
{ onselect: 'core:show-selected-node-labels', label: RED._('menu.label.showSelectedNodeLabels') },
{ onselect: 'core:hide-selected-node-labels', label: RED._('menu.label.hideSelectedNodeLabels') }
{ onselect: 'core:show-selected-node-labels', label: RED._('menu.label.showSelectedNodeLabels'), disabled: !hasUnlabeledNode },
{ onselect: 'core:hide-selected-node-labels', label: RED._('menu.label.hideSelectedNodeLabels'), disabled: !hasLabeledNode }
)
menuItems.push({
label: RED._('sidebar.info.node'),