Skip to content

Commit

Permalink
feat(client): make menu entries work in all cases
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
philippfromme committed Nov 29, 2018
1 parent 70b66b0 commit d770f51
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 30 deletions.
5 changes: 3 additions & 2 deletions app/lib/menu/menu-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}));
}
Expand Down
11 changes: 6 additions & 5 deletions client/src/app/tabs/bpmn/getBpmnEditMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}];
}

Expand Down
42 changes: 20 additions & 22 deletions client/src/app/tabs/dmn/getDmnEditMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion client/src/app/tabs/getEditMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit d770f51

Please sign in to comment.