1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-06-05 21:59:22 +02:00

feat: query tabs auto focus

This commit is contained in:
2020-12-11 15:55:18 +01:00
parent 3ed5ea023e
commit f81312aeb0
4 changed files with 25 additions and 8 deletions

View File

@ -14,7 +14,8 @@ monaco.languages.registerCompletionItemProvider('sql', completionItemProvider(mo
export default { export default {
name: 'QueryEditor', name: 'QueryEditor',
props: { props: {
value: String value: String,
autoFocus: { type: Boolean, default: false }
}, },
data () { data () {
return { return {
@ -40,6 +41,12 @@ export default {
const content = this.editor.getValue(); const content = this.editor.getValue();
this.$emit('update:value', content); this.$emit('update:value', content);
}); });
if (this.autoFocus) {
setTimeout(() => {
this.editor.focus();
}, 20);
}
}, },
beforeDestroy () { beforeDestroy () {
this.editor && this.editor.dispose(); this.editor && this.editor.dispose();

View File

@ -29,14 +29,14 @@
</div> </div>
</div> </div>
<div class="th"> <div class="th">
<div class="column-resizable"> <div class="column-resizable min-100">
<div class="table-column-title"> <div class="table-column-title">
{{ $t('word.name') }} {{ $t('word.name') }}
</div> </div>
</div> </div>
</div> </div>
<div class="th"> <div class="th">
<div class="column-resizable"> <div class="column-resizable min-100">
<div class="table-column-title"> <div class="table-column-title">
{{ $t('word.type') }} {{ $t('word.type') }}
</div> </div>
@ -231,4 +231,8 @@ export default {
.vscroll { .vscroll {
overflow: auto; overflow: auto;
} }
.min-100 {
min-width: 100px !important;
}
</style> </style>

View File

@ -1,7 +1,11 @@
<template> <template>
<div v-show="isSelected" class="workspace-query-tab column col-12 columns col-gapless"> <div v-show="isSelected" class="workspace-query-tab column col-12 columns col-gapless">
<div class="workspace-query-runner column col-12"> <div class="workspace-query-runner column col-12">
<QueryEditor v-if="isSelected" :value.sync="query" /> <QueryEditor
v-if="isSelected"
:auto-focus="true"
:value.sync="query"
/>
<div class="workspace-query-runner-footer"> <div class="workspace-query-runner-footer">
<div class="workspace-query-buttons"> <div class="workspace-query-buttons">
<button <button

View File

@ -111,11 +111,10 @@ export default {
} }
: workspace); : workspace);
}, },
NEW_TAB (state, uid) { NEW_TAB (state, { uid, tab }) {
tabIndex[uid] = tabIndex[uid] ? ++tabIndex[uid] : 1; tabIndex[uid] = tabIndex[uid] ? ++tabIndex[uid] : 1;
const newTab = { const newTab = {
uid: uidGen('T'), uid: tab,
index: tabIndex[uid], index: tabIndex[uid],
selected: false, selected: false,
type: 'query', type: 'query',
@ -338,7 +337,10 @@ export default {
lastBreadcrumbs = { ...breadcrumbsObj, ...payload }; lastBreadcrumbs = { ...breadcrumbsObj, ...payload };
}, },
newTab ({ commit }, uid) { newTab ({ commit }, uid) {
commit('NEW_TAB', uid); const tab = uidGen('T');
commit('NEW_TAB', { uid, tab });
commit('SELECT_TAB', { uid, tab });
}, },
removeTab ({ commit }, payload) { removeTab ({ commit }, payload) {
commit('REMOVE_TAB', payload); commit('REMOVE_TAB', payload);