Add hooks to Node Lifecycle (#1882)

*  add hook when closing node editing view

*  add hook for node deletion

*  add hook call to escape key
This commit is contained in:
Ben Hesseldieck 2021-06-18 22:47:03 +02:00 committed by GitHub
parent 0470740737
commit c0c994d245
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 3 deletions

View file

@ -86,11 +86,9 @@ export default mixins(externalHooks, nodeHelpers, workflowHelpers).extend({
return this.$store.getters.activeNode; return this.$store.getters.activeNode;
}, },
nodeType (): INodeTypeDescription | null { nodeType (): INodeTypeDescription | null {
const activeNode = this.node;
if (this.node) { if (this.node) {
return this.$store.getters.nodeType(this.node.type); return this.$store.getters.nodeType(this.node.type);
} }
return null; return null;
}, },
}, },
@ -111,6 +109,7 @@ export default mixins(externalHooks, nodeHelpers, workflowHelpers).extend({
close (e: MouseEvent) { close (e: MouseEvent) {
// @ts-ignore // @ts-ignore
if (e.target.className && e.target.className.includes && e.target.className.includes('close-on-click')) { if (e.target.className && e.target.className.includes && e.target.className.includes('close-on-click')) {
this.$externalHooks().run('dataDisplay.nodeEditingFinished');
this.showDocumentHelp = false; this.showDocumentHelp = false;
this.$store.commit('setActiveNode', null); this.$store.commit('setActiveNode', null);
} }

View file

@ -46,6 +46,7 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import { externalHooks } from '@/components/mixins/externalHooks';
import { nodeBase } from '@/components/mixins/nodeBase'; import { nodeBase } from '@/components/mixins/nodeBase';
import { nodeHelpers } from '@/components/mixins/nodeHelpers'; import { nodeHelpers } from '@/components/mixins/nodeHelpers';
import { workflowHelpers } from '@/components/mixins/workflowHelpers'; import { workflowHelpers } from '@/components/mixins/workflowHelpers';
@ -59,7 +60,7 @@ import NodeIcon from '@/components/NodeIcon.vue';
import mixins from 'vue-typed-mixins'; import mixins from 'vue-typed-mixins';
export default mixins(nodeBase, nodeHelpers, workflowHelpers).extend({ export default mixins(externalHooks, nodeBase, nodeHelpers, workflowHelpers).extend({
name: 'Node', name: 'Node',
components: { components: {
NodeIcon, NodeIcon,
@ -152,6 +153,7 @@ export default mixins(nodeBase, nodeHelpers, workflowHelpers).extend({
this.$emit('runWorkflow', this.data.name, 'Node.executeNode'); this.$emit('runWorkflow', this.data.name, 'Node.executeNode');
}, },
deleteNode () { deleteNode () {
this.$externalHooks().run('node.deleteNode', { node: this.data});
Vue.nextTick(() => { Vue.nextTick(() => {
// Wait a tick else vue causes problems because the data is gone // Wait a tick else vue causes problems because the data is gone
this.$emit('removeNode', this.data.name); this.$emit('removeNode', this.data.name);

View file

@ -453,6 +453,7 @@ export default mixins(
this.callDebounced('deleteSelectedNodes', 500); this.callDebounced('deleteSelectedNodes', 500);
} else if (e.key === 'Escape') { } else if (e.key === 'Escape') {
this.$externalHooks().run('dataDisplay.nodeEditingFinished');
this.createNodeActive = false; this.createNodeActive = false;
this.$store.commit('setActiveNode', null); this.$store.commit('setActiveNode', null);
} else if (e.key === 'Tab') { } else if (e.key === 'Tab') {