mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-06 18:18:53 +08:00
add Delete query feature
This commit is contained in:
@@ -16,10 +16,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.dialog-body {
|
.dialog-body {
|
||||||
min-height: 100px;
|
min-height: 60px;
|
||||||
background-color: var(--color-bg-light);
|
background-color: var(--color-bg-light);
|
||||||
padding: 24px;
|
padding: 24px;
|
||||||
border-top: 1px solid var(--color-border-light);
|
border-top: 1px solid var(--color-border-light);
|
||||||
|
color: var(--color-text-base);
|
||||||
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dialog-buttons-container {
|
.dialog-buttons-container {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
<rename-icon @click="showRenameDialog(index)" />
|
<rename-icon @click="showRenameDialog(index)" />
|
||||||
<copy-icon @click="duplicateQuery(index)"/>
|
<copy-icon @click="duplicateQuery(index)"/>
|
||||||
<export-icon />
|
<export-icon />
|
||||||
<delete-icon />
|
<delete-icon @click="showDeleteDialog(index)"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@@ -50,6 +50,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!--Rename Query dialog -->
|
||||||
<modal name="rename" classes="dialog" height="auto">
|
<modal name="rename" classes="dialog" height="auto">
|
||||||
<div class="dialog-header">
|
<div class="dialog-header">
|
||||||
Rename query
|
Rename query
|
||||||
@@ -68,6 +69,29 @@
|
|||||||
<button class="primary" @click="renameQuery">Rename</button>
|
<button class="primary" @click="renameQuery">Rename</button>
|
||||||
</div>
|
</div>
|
||||||
</modal>
|
</modal>
|
||||||
|
|
||||||
|
<!--Delete Query dialog -->
|
||||||
|
<modal name="delete" classes="dialog" height="auto">
|
||||||
|
<div class="dialog-header">
|
||||||
|
Delete query
|
||||||
|
<close-icon @click="$modal.hide('delete')"/>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="
|
||||||
|
currentQueryIndex !== null
|
||||||
|
&& currentQueryIndex >= 0
|
||||||
|
&& currentQueryIndex < queries.length
|
||||||
|
"
|
||||||
|
class="dialog-body"
|
||||||
|
>
|
||||||
|
Are you sure you want to delete
|
||||||
|
"{{ queries[currentQueryIndex].name }}"?
|
||||||
|
</div>
|
||||||
|
<div class="dialog-buttons-container">
|
||||||
|
<button class="secondary" @click="$modal.hide('delete')">Cancel</button>
|
||||||
|
<button class="primary" @click="deleteQuery">Delete</button>
|
||||||
|
</div>
|
||||||
|
</modal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -146,7 +170,7 @@ export default {
|
|||||||
this.$set(this.queries, this.currentQueryIndex, currentQuery)
|
this.$set(this.queries, this.currentQueryIndex, currentQuery)
|
||||||
this.$modal.hide('rename')
|
this.$modal.hide('rename')
|
||||||
this.saveQueriesInLocalStorage()
|
this.saveQueriesInLocalStorage()
|
||||||
const tabIndex = this.$store.state.tabs.findIndex(tab => tab.id === currentQuery.id)
|
const tabIndex = this.findTabIndex(currentQuery.id)
|
||||||
if (tabIndex >= 0) {
|
if (tabIndex >= 0) {
|
||||||
this.$store.commit('updateTabName', { index: tabIndex, newName: this.newName })
|
this.$store.commit('updateTabName', { index: tabIndex, newName: this.newName })
|
||||||
}
|
}
|
||||||
@@ -159,6 +183,23 @@ export default {
|
|||||||
this.queries.push(newQuery)
|
this.queries.push(newQuery)
|
||||||
this.saveQueriesInLocalStorage()
|
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 () {
|
saveQueriesInLocalStorage () {
|
||||||
localStorage.setItem('myQueries', JSON.stringify(this.queries))
|
localStorage.setItem('myQueries', JSON.stringify(this.queries))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user