1
0
mirror of https://github.com/lana-k/sqliteviz.git synced 2025-12-07 02:28:54 +08:00

Merge branch 'master' of github.com:lana-k/sqliteviz into migrate_to_vue3

This commit is contained in:
lana-k
2025-01-13 22:19:00 +01:00
14 changed files with 588 additions and 423 deletions

View File

@@ -187,7 +187,6 @@ export default {
mixins: [tooltipMixin],
data () {
return {
inquiries: [],
filter: null,
newName: null,
processedInquiryId: null,
@@ -202,6 +201,9 @@ export default {
}
},
computed: {
inquiries () {
return this.$store.state.inquiries
},
predefinedInquiries () {
return this.$store.state.predefinedInquiries.map(inquiry => {
inquiry.isPredefined = true
@@ -267,7 +269,6 @@ export default {
}
},
async created () {
this.inquiries = storedInquiries.getStoredInquiries()
const loadingPredefinedInquiries = this.$store.state.loadingPredefinedInquiries
const predefinedInquiriesLoaded = this.$store.state.predefinedInquiriesLoaded
if (!predefinedInquiriesLoaded && !loadingPredefinedInquiries) {
@@ -342,31 +343,17 @@ export default {
this.errorMsg = "Inquiry name can't be empty"
return
}
const processedInquiry = this.inquiries[this.processedInquiryIndex]
processedInquiry.name = this.newName
this.inquiries[this.processedInquiryIndex] = processedInquiry
this.$store.dispatch('renameInquiry', {
inquiryId: this.processedInquiryId,
newName: this.newName
})
// update inquiries in local storage
storedInquiries.updateStorage(this.inquiries)
// update tab, if renamed inquiry is opened
const tab = this.$store.state.tabs
.find(tab => tab.id === processedInquiry.id)
if (tab) {
this.$store.commit('updateTab', {
tab,
newValues: {
name: this.newName
}
})
}
// hide dialog
this.$modal.hide('rename')
},
duplicateInquiry (index) {
const newInquiry = storedInquiries.duplicateInquiry(this.showedInquiries[index])
this.inquiries.push(newInquiry)
storedInquiries.updateStorage(this.inquiries)
this.$store.dispatch('addInquiry', newInquiry)
},
showDeleteDialog (idsSet) {
this.deleteGroup = idsSet.size > 1
@@ -378,39 +365,19 @@ export default {
deleteInquiry () {
this.$modal.hide('delete')
if (!this.deleteGroup) {
this.inquiries.splice(this.processedInquiryIndex, 1)
// Close deleted inquiry tab if it was opened
const tab = this.$store.state.tabs
.find(tab => tab.id === this.processedInquiryId)
if (tab) {
this.$store.commit('deleteTab', tab)
}
this.$store.dispatch('deleteInquiries', new Set().add(this.processedInquiryId))
// Clear checkbox
if (this.selectedInquiriesIds.has(this.processedInquiryId)) {
this.selectedInquiriesIds.delete(this.processedInquiryId)
}
} else {
this.inquiries = this.inquiries.filter(
inquiry => !this.selectedInquiriesIds.has(inquiry.id)
)
// Close deleted inquiries if it was opened
const tabs = this.$store.state.tabs
let i = tabs.length - 1
while (i > -1) {
if (this.selectedInquiriesIds.has(tabs[i].id)) {
this.$store.commit('deleteTab', tabs[i])
}
i--
}
this.$store.dispatch('deleteInquiries', this.selectedInquiriesIds)
// Clear checkboxes
this.selectedInquiriesIds.clear()
}
this.selectedInquiriesCount = this.selectedInquiriesIds.size
storedInquiries.updateStorage(this.inquiries)
},
exportToFile (inquiryList, fileName) {
storedInquiries.export(inquiryList, fileName)
@@ -426,8 +393,7 @@ export default {
importInquiries () {
storedInquiries.importInquiries()
.then(importedInquiries => {
this.inquiries = this.inquiries.concat(importedInquiries)
storedInquiries.updateStorage(this.inquiries)
this.$store.commit('setInquiries', this.inquiries.concat(importedInquiries))
})
},

View File

@@ -123,7 +123,7 @@ export default {
this.saveInquiry()
}
},
saveInquiry () {
async saveInquiry () {
const isNeedName = storedInquiries.isTabNeedName(this.currentInquiry)
if (isNeedName && !this.name) {
this.errorMsg = 'Inquiry name can\'t be empty'
@@ -133,7 +133,10 @@ export default {
const tabView = this.currentInquiry.view
// Save inquiry
const value = storedInquiries.save(this.currentInquiry, this.name)
const value = await this.$store.dispatch('saveInquiry', {
inquiryTab: this.currentInquiry,
newName: this.name
})
// Update tab in store
this.$store.commit('updateTab', {