1
0
mirror of https://github.com/lana-k/sqliteviz.git synced 2025-12-07 18:48:55 +08:00

adding and closing tabs; saving of queries

This commit is contained in:
lana-k
2020-10-07 16:03:36 +02:00
parent f898493d29
commit 4841e43a09
7 changed files with 191 additions and 27 deletions

View File

@@ -8,7 +8,11 @@ export default new Vuex.Store({
schema: null,
dbFile: null,
dbName: null,
worker: new Worker('/js/worker.sql-wasm.js')
worker: new Worker('/js/worker.sql-wasm.js'),
tabs: [],
currentTab: null,
currentTabId: null,
untitledLastIndex: 0
},
mutations: {
saveSchema (state, schema) {
@@ -19,6 +23,41 @@ export default new Vuex.Store({
},
saveDbName (state, name) {
state.dbName = name
},
addTab (state, tab) {
state.tabs.push(tab)
},
updateTabName (state, { index, newName }) {
const tab = state.tabs[index]
tab.name = newName
Vue.set(state.tabs, index, tab)
},
updateTabState (state, { index, newValue }) {
console.log(index, newValue)
const tab = state.tabs[index]
tab.isUnsaved = newValue
Vue.set(state.tabs, index, tab)
},
deleteTab (state, index) {
if (state.tabs[index].id !== state.currentTabId) {
} else if (index < state.tabs.length - 1) {
state.currentTabId = state.tabs[index + 1].id
} else if (index > 0) {
state.currentTabId = state.tabs[index - 1].id
} else {
state.currentTabId = null
state.untitledLastIndex = 0
}
state.tabs.splice(index, 1)
},
setCurrentTabId (state, id) {
state.currentTabId = id
},
setCurrentTab (state, tab) {
state.currentTab = tab
},
updateUntitledLastIndex (state) {
state.untitledLastIndex += 1
}
},
actions: {