From fbccb3d9be0137fecb2dc7c8d77d280475094032 Mon Sep 17 00:00:00 2001 From: lana-k Date: Tue, 13 Oct 2020 21:13:47 +0200 Subject: [PATCH] add Delete query feature --- src/assets/styles/dialogs.css | 4 +++- src/views/MyQueries.vue | 45 +++++++++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/src/assets/styles/dialogs.css b/src/assets/styles/dialogs.css index 47aa996..2d4394e 100644 --- a/src/assets/styles/dialogs.css +++ b/src/assets/styles/dialogs.css @@ -16,10 +16,12 @@ } .dialog-body { - min-height: 100px; + min-height: 60px; background-color: var(--color-bg-light); padding: 24px; border-top: 1px solid var(--color-border-light); + color: var(--color-text-base); + font-size: 13px; } .dialog-buttons-container { diff --git a/src/views/MyQueries.vue b/src/views/MyQueries.vue index 52ecf55..b0d9af1 100644 --- a/src/views/MyQueries.vue +++ b/src/views/MyQueries.vue @@ -39,7 +39,7 @@ - + @@ -50,6 +50,7 @@ +
Rename query @@ -68,6 +69,29 @@
+ + + +
+ Delete query + +
+
+ Are you sure you want to delete + "{{ queries[currentQueryIndex].name }}"? +
+
+ + +
+
@@ -146,7 +170,7 @@ export default { this.$set(this.queries, this.currentQueryIndex, currentQuery) this.$modal.hide('rename') this.saveQueriesInLocalStorage() - const tabIndex = this.$store.state.tabs.findIndex(tab => tab.id === currentQuery.id) + const tabIndex = this.findTabIndex(currentQuery.id) if (tabIndex >= 0) { this.$store.commit('updateTabName', { index: tabIndex, newName: this.newName }) } @@ -159,6 +183,23 @@ export default { this.queries.push(newQuery) this.saveQueriesInLocalStorage() }, + showDeleteDialog (index) { + this.currentQueryIndex = index + this.$modal.show('delete') + }, + deleteQuery () { + this.$modal.hide('delete') + const id = this.queries[this.currentQueryIndex].id + this.queries.splice(this.currentQueryIndex, 1) + this.saveQueriesInLocalStorage() + const tabIndex = this.findTabIndex(id) + if (tabIndex >= 0) { + this.$store.commit('deleteTab', tabIndex) + } + }, + findTabIndex (id) { + return this.$store.state.tabs.findIndex(tab => tab.id === id) + }, saveQueriesInLocalStorage () { localStorage.setItem('myQueries', JSON.stringify(this.queries)) }