From 6b725b1d40753ad89bfad6f1df57c6fb737e5262 Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Sat, 17 Jul 2021 16:09:57 +0200 Subject: [PATCH] fix: issues with trigger temp tabs --- .../components/WorkspaceExploreBarSchema.vue | 8 +++++++- .../components/WorkspacePropsTabTrigger.vue | 8 +++++--- src/renderer/store/modules/workspaces.store.js | 16 ++++++++-------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/renderer/components/WorkspaceExploreBarSchema.vue b/src/renderer/components/WorkspaceExploreBarSchema.vue index 85a81f04..0eed6d40 100644 --- a/src/renderer/components/WorkspaceExploreBarSchema.vue +++ b/src/renderer/components/WorkspaceExploreBarSchema.vue @@ -310,7 +310,13 @@ export default { trigger: 'trigger-props' }; - this.newTab({ uid: this.connection.uid, elementName: misc.name, schema: this.database.name, type: miscTabs[type], elementType: type }); + this.newTab({ + uid: this.connection.uid, + elementName: misc.name, + schema: this.database.name, + type: miscTabs[type], + elementType: type + }); this.setBreadcrumbs({ schema, [type]: misc.name }); }, showSchemaContext (event, schema) { diff --git a/src/renderer/components/WorkspacePropsTabTrigger.vue b/src/renderer/components/WorkspacePropsTabTrigger.vue index ec380aca..9ed5161d 100644 --- a/src/renderer/components/WorkspacePropsTabTrigger.vue +++ b/src/renderer/components/WorkspacePropsTabTrigger.vue @@ -152,6 +152,7 @@ export default { return { isLoading: false, isSaving: false, + isReady: false, originalTrigger: null, localTrigger: { sql: '' }, lastTrigger: null, @@ -211,10 +212,10 @@ export default { this.getTriggerData(); } }, - isChanged (val, oldVal) { + isChanged (val) { this.setUnsavedChanges({ uid: this.connection.uid, tUid: this.tabUid, isChanged: val }); - if (val && !oldVal) { + if (val) { const triggerName = this.customizations.triggerTableInName ? `${this.originalTrigger.table}.${this.originalTrigger.name}` : this.originalTrigger.name; this.newTab({ @@ -233,7 +234,7 @@ export default { window.addEventListener('keydown', this.onKey); }, mounted () { - window.addEventListener('resize', this.resizeQueryEditor); + window.addEventListener('resize', this.resizeQueryEditor); ; }, destroyed () { window.removeEventListener('resize', this.resizeQueryEditor); @@ -273,6 +274,7 @@ export default { this.originalTrigger = response; this.localTrigger = JSON.parse(JSON.stringify(this.originalTrigger)); this.sqlProxy = this.localTrigger.sql; + this.isReady = true; if (this.customizations.triggerMultipleEvents) { this.originalTrigger.event.forEach(e => { diff --git a/src/renderer/store/modules/workspaces.store.js b/src/renderer/store/modules/workspaces.store.js index dd578456..4f189312 100644 --- a/src/renderer/store/modules/workspaces.store.js +++ b/src/renderer/store/modules/workspaces.store.js @@ -566,9 +566,9 @@ export default { const existentTab = workspaceTabs ? workspaceTabs.tabs.find(tab => tab.schema === schema && - tab.elementName === elementName && - tab.elementType === elementType && - ['temp-data', 'data'].includes(tab.type)) + tab.elementName === elementName && + tab.elementType === elementType && + ['temp-data', 'data'].includes(tab.type)) : false; if (existentTab) { @@ -585,8 +585,8 @@ export default { const existentTab = workspaceTabs ? workspaceTabs.tabs.find(tab => tab.elementName === elementName && - tab.elementType === elementType && - tab.type === type) + tab.elementType === elementType && + tab.type === type) : false; if (existentTab) { @@ -603,9 +603,9 @@ export default { const existentTab = workspaceTabs ? workspaceTabs.tabs.find(tab => tab.schema === schema && - tab.elementName === elementName && - tab.elementType === elementType && - ['temp-trigger-props', 'trigger-props'].includes(tab.type)) + tab.elementName === elementName && + tab.elementType === elementType && + ['temp-trigger-props', 'trigger-props'].includes(tab.type)) : false; if (existentTab) { // if tab exists