From d770f5173c7871430f5bcb326584382b5139428a Mon Sep 17 00:00:00 2001 From: Philipp Fromme Date: Thu, 29 Nov 2018 09:21:14 +0100 Subject: [PATCH] feat(client): make menu entries work in all cases * clicking menu entry will trigger editor action or default behavior in the cases of copy, paste and selectAll depending on an input being focussed or not Related to #1027 --- app/lib/menu/menu-builder.js | 5 ++- client/src/app/tabs/bpmn/getBpmnEditMenu.js | 11 +++--- client/src/app/tabs/dmn/getDmnEditMenu.js | 42 ++++++++++----------- client/src/app/tabs/getEditMenu.js | 5 ++- 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/app/lib/menu/menu-builder.js b/app/lib/menu/menu-builder.js index 7abb4857d3..70269e629f 100644 --- a/app/lib/menu/menu-builder.js +++ b/app/lib/menu/menu-builder.js @@ -277,12 +277,13 @@ class MenuBuilder { } builder.menu.append(new MenuItem({ - label: menuItem.label, accelerator: menuItem.accelerator, - enabled: menuItem.enabled !== undefined ? menuItem.enabled : true, click: function() { app.emit('menu:action', menuItem.action, menuItem.options); }, + enabled: menuItem.enabled !== undefined ? menuItem.enabled : true, + label: menuItem.label, + role: menuItem.role, submenu })); } diff --git a/client/src/app/tabs/bpmn/getBpmnEditMenu.js b/client/src/app/tabs/bpmn/getBpmnEditMenu.js index a202c9a606..b778928899 100644 --- a/client/src/app/tabs/bpmn/getBpmnEditMenu.js +++ b/client/src/app/tabs/bpmn/getBpmnEditMenu.js @@ -8,18 +8,19 @@ import { function getCopyPasteEntries({ copy, - paste + paste, + inputActive }) { return [{ label: 'Copy', - accelerator: 'CommandOrControl+C', enabled: copy, - action: 'copy' + action: 'copy', + role: inputActive && 'copy' }, { label: 'Paste', - accelerator: 'CommandOrControl+V', enabled: paste, - action: 'paste' + action: 'paste', + role: inputActive && 'paste' }]; } diff --git a/client/src/app/tabs/dmn/getDmnEditMenu.js b/client/src/app/tabs/dmn/getDmnEditMenu.js index 358b67632f..a865c6e08e 100644 --- a/client/src/app/tabs/dmn/getDmnEditMenu.js +++ b/client/src/app/tabs/dmn/getDmnEditMenu.js @@ -33,28 +33,26 @@ function getDecisionTableEntries({ ], [ { label: 'Add Clause', - submenu: [ - [ - { - label: 'Input', - action: 'addInput' - }, { - label: 'Output', - action: 'addOutput' - } - ], [ - { - label: 'Left Of Selected', - enabled: hasSelection, - action: 'addClauseLeft' - }, - { - label: 'Right Of Selected', - enabled: hasSelection, - action: 'addClauseRight' - } - ] - ] + submenu: [{ + label: 'Input', + action: 'addInput' + }, { + label: 'Output', + action: 'addOutput' + }, + { + type: 'separator' + }, + { + label: 'Left Of Selected', + enabled: hasSelection, + action: 'addClauseLeft' + }, + { + label: 'Right Of Selected', + enabled: hasSelection, + action: 'addClauseRight' + }] }, { label: 'Remove Clause', enabled: hasSelection, diff --git a/client/src/app/tabs/getEditMenu.js b/client/src/app/tabs/getEditMenu.js index 9b346c5cdc..71b065c2d9 100644 --- a/client/src/app/tabs/getEditMenu.js +++ b/client/src/app/tabs/getEditMenu.js @@ -119,13 +119,16 @@ export function getCanvasEntries({ } export function getSelectionEntries({ + inputActive, removeSelected, selectAll }) { return [{ label: 'Select All', accelerator: 'CommandOrControl+A', - action: 'selectElements' + enabled: selectAll, + action: 'selectElements', + role: inputActive && 'selectAll' }, { label: 'Remove Selected', accelerator: 'Delete',