mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-07 10:38:54 +08:00
refactoring manipulations with My queries
This commit is contained in:
@@ -54,7 +54,7 @@
|
||||
<script>
|
||||
import TextField from '@/components/TextField'
|
||||
import CloseIcon from '@/components/svg/close'
|
||||
import queryTab from '@/queryTab'
|
||||
import storedQueries from '@/storedQueries'
|
||||
|
||||
export default {
|
||||
name: 'MainMenu',
|
||||
@@ -100,9 +100,9 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
createNewQuery () {
|
||||
const tab = queryTab.newBlankTab()
|
||||
this.$store.commit('addTab', tab)
|
||||
this.$store.commit('setCurrentTabId', tab.id)
|
||||
this.$store.dispatch('addTab').then(id => {
|
||||
this.$store.commit('setCurrentTabId', id)
|
||||
})
|
||||
},
|
||||
cancelSave () {
|
||||
this.$modal.hide('save')
|
||||
@@ -112,14 +112,14 @@ export default {
|
||||
this.errorMsg = null
|
||||
this.name = ''
|
||||
|
||||
if (queryTab.isTabNeedName(this.currentQuery)) {
|
||||
if (storedQueries.isTabNeedName(this.currentQuery)) {
|
||||
this.$modal.show('save')
|
||||
} else {
|
||||
this.saveQuery()
|
||||
}
|
||||
},
|
||||
saveQuery () {
|
||||
const isNeedName = queryTab.isTabNeedName(this.currentQuery)
|
||||
const isNeedName = storedQueries.isTabNeedName(this.currentQuery)
|
||||
if (isNeedName && !this.name) {
|
||||
this.errorMsg = 'Query name can\'t be empty'
|
||||
return
|
||||
@@ -128,7 +128,7 @@ export default {
|
||||
const tabView = this.currentQuery.view
|
||||
|
||||
// Save query
|
||||
const value = queryTab.save(this.currentQuery, this.name)
|
||||
const value = storedQueries.save(this.currentQuery, this.name)
|
||||
|
||||
// Update tab in store
|
||||
this.$store.commit('updateTab', {
|
||||
|
||||
@@ -13,6 +13,7 @@ import 'codemirror/theme/neo.css'
|
||||
import 'codemirror/addon/hint/show-hint.js'
|
||||
import 'codemirror/addon/hint/show-hint.css'
|
||||
import 'codemirror/addon/hint/sql-hint.js'
|
||||
import 'codemirror/addon/display/autorefresh.js'
|
||||
import { debounce } from 'debounce'
|
||||
|
||||
const sqlHint = CM.hint.sql
|
||||
@@ -42,7 +43,9 @@ export default {
|
||||
mode: 'text/x-mysql',
|
||||
theme: 'neo',
|
||||
lineNumbers: true,
|
||||
line: true
|
||||
line: true,
|
||||
autofocus: true,
|
||||
autoRefresh: true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user