Implement that nodes can also be deselected with ctrl+click

This commit is contained in:
Jan Oberhauser 2019-07-17 19:05:03 +02:00
parent 416eb81a6e
commit 5054c7054d
3 changed files with 31 additions and 4 deletions

View file

@ -156,6 +156,13 @@ export const mouseSelect = mixins(nodeIndex).extend({
this.updateSelectBox(e);
},
nodeDeselected (node: INodeUi) {
this.$store.commit('removeNodeFromSelection', node);
const nodeElement = `node-${this.getNodeIndex(node.name)}`;
// @ts-ignore
this.instance.removeFromDragSelection(nodeElement);
},
nodeSelected (node: INodeUi) {
this.$store.commit('addSelectedNode', node);
const nodeElement = `node-${this.getNodeIndex(node.name)}`;

View file

@ -26,6 +26,9 @@ export const nodeBase = mixins(nodeIndex).extend({
}
return false;
},
isMacOs(): boolean {
return /(ipad|iphone|ipod|mac)/i.test(navigator.platform);
},
isReadOnly (): boolean {
if (['NodeViewExisting', 'NodeViewNew'].includes(this.$route.name as string)) {
return false;
@ -271,24 +274,33 @@ export const nodeBase = mixins(nodeIndex).extend({
this.$store.commit('updateNodeProperties', updateInformation);
});
this.$store.commit('removeActiveAction', 'dragActive');
}
},
filter: '.action-button',
});
},
isCtrlKeyPressed(e: MouseEvent | KeyboardEvent): boolean {
if (this.isMacOs) {
return e.metaKey;
}
return e.ctrlKey;
},
mouseLeftClick (e: MouseEvent) {
if (this.$store.getters.isActionActive('dragActive')) {
this.$store.commit('removeActiveAction', 'dragActive');
} else {
if (!e.ctrlKey) {
if (this.isCtrlKeyPressed(e) === false) {
this.$emit('deselectAllNodes');
}
if (this.$store.getters.isNodeSelected(this.data.name)) {
this.$emit('deselectNode', this.name);
} else {
this.$emit('nodeSelected', this.name);
}
}
},
},
});

View file

@ -12,6 +12,7 @@
v-for="nodeData in nodes"
@duplicateNode="duplicateNode"
@deselectAllNodes="deselectAllNodes"
@deselectNode="nodeDeselectedByName"
@nodeSelected="nodeSelectedByName"
@removeNode="removeNode"
@runWorkflow="runWorkflow"
@ -781,6 +782,13 @@ export default mixins(
this.createNodeActive = false;
},
nodeDeselectedByName (nodeName: string) {
const node = this.$store.getters.nodeByName(nodeName);
if (node) {
this.nodeDeselected(node);
}
},
nodeSelectedByName (nodeName: string, setActive = false, deselectAllOthers?: boolean) {
if (deselectAllOthers === true) {
this.deselectAllNodes();