fix(UI): table icon in view data tabs

This commit is contained in:
Fabio Di Stasio 2021-07-14 12:33:26 +02:00
parent 5bb4e496f2
commit f0fa7c81b7
3 changed files with 13 additions and 12 deletions

View File

@ -96,7 +96,7 @@
class="tab-link" class="tab-link"
@dblclick="openAsDataTab(tab)" @dblclick="openAsDataTab(tab)"
> >
<i class="mdi mdi-18px mr-1" :class="workspace.breadcrumbs.table ? 'mdi-table' : 'mdi-table-eye'" /> <i class="mdi mdi-18px mr-1" :class="tab.element === 'view' ? 'mdi-table-eye' : 'mdi-table'" />
<span :title="`${$t('word.data').toUpperCase()}: ${tab.table}`"> <span :title="`${$t('word.data').toUpperCase()}: ${tab.table}`">
<span class=" text-italic">{{ tab.table }}</span> <span class=" text-italic">{{ tab.table }}</span>
<span <span
@ -108,7 +108,7 @@
</a> </a>
<a v-if="tab.type === 'data'" class="tab-link"> <a v-if="tab.type === 'data'" class="tab-link">
<i class="mdi mdi-18px mr-1" :class="workspace.breadcrumbs.table ? 'mdi-table' : 'mdi-table-eye'" /> <i class="mdi mdi-18px mr-1" :class="tab.element === 'view' ? 'mdi-table-eye' : 'mdi-table'" />
<span :title="`${$t('word.data').toUpperCase()}: ${tab.table}`"> <span :title="`${$t('word.data').toUpperCase()}: ${tab.table}`">
{{ tab.table }} {{ tab.table }}
<span <span
@ -326,7 +326,7 @@ export default {
this.addWheelEvent(); this.addWheelEvent();
}, },
openAsDataTab (tab) { openAsDataTab (tab) {
this.newTab({ uid: this.connection.uid, schema: tab.schema, table: tab.table, type: 'data' }); this.newTab({ uid: this.connection.uid, schema: tab.schema, table: tab.table, type: 'data', element: tab.element });
this.addWheelEvent(); this.addWheelEvent();
}, },
closeTab (tab) { closeTab (tab) {

View File

@ -282,11 +282,11 @@ export default {
this.changeBreadcrumbs({ schema, table: null }); this.changeBreadcrumbs({ schema, table: null });
}, },
selectTable ({ schema, table }) { selectTable ({ schema, table }) {
this.newTab({ uid: this.connection.uid, table: table.name, schema: this.database.name, type: 'temp-data' }); this.newTab({ uid: this.connection.uid, table: table.name, schema: this.database.name, type: 'temp-data', element: table.type });
this.setBreadcrumbs({ schema, [table.type]: table.name }); this.setBreadcrumbs({ schema, [table.type]: table.name });
}, },
openDataTab ({ schema, table }) { openDataTab ({ schema, table }) {
this.newTab({ uid: this.connection.uid, table: table.name, schema: this.database.name, type: 'data' }); this.newTab({ uid: this.connection.uid, table: table.name, schema: this.database.name, type: 'data', element: table.type });
this.setBreadcrumbs({ schema, [table.type]: table.name }); this.setBreadcrumbs({ schema, [table.type]: table.name });
}, },
showSchemaContext (event, schema) { showSchemaContext (event, schema) {

View File

@ -178,7 +178,7 @@ export default {
} }
: workspace); : workspace);
}, },
NEW_TAB (state, { uid, tab, content, type, autorun, schema, table }) { NEW_TAB (state, { uid, tab, content, type, autorun, schema, table, element }) {
if (type === 'query') if (type === 'query')
tabIndex[uid] = tabIndex[uid] ? ++tabIndex[uid] : 1; tabIndex[uid] = tabIndex[uid] ? ++tabIndex[uid] : 1;
@ -189,6 +189,7 @@ export default {
type, type,
schema, schema,
table, table,
element,
fields: [], fields: [],
keyUsage: [], keyUsage: [],
content: content || '', content: content || '',
@ -217,14 +218,14 @@ export default {
return workspace; return workspace;
}); });
}, },
REPLACE_TAB (state, { uid, tab: tUid, type, schema, table }) { REPLACE_TAB (state, { uid, tab: tUid, type, schema, table, element }) {
state.workspaces = state.workspaces.map(workspace => { state.workspaces = state.workspaces.map(workspace => {
if (workspace.uid === uid) { if (workspace.uid === uid) {
return { return {
...workspace, ...workspace,
tabs: workspace.tabs.map(tab => { tabs: workspace.tabs.map(tab => {
if (tab.uid === tUid) if (tab.uid === tUid)
return { ...tab, type, schema, table }; return { ...tab, type, schema, table, element };
return tab; return tab;
}) })
@ -491,7 +492,7 @@ export default {
setSearchTerm ({ commit, getters }, term) { setSearchTerm ({ commit, getters }, term) {
commit('SET_SEARCH_TERM', { uid: getters.getSelected, term }); commit('SET_SEARCH_TERM', { uid: getters.getSelected, term });
}, },
newTab ({ state, commit }, { uid, content, type, autorun, schema, table }) { newTab ({ state, commit }, { uid, content, type, autorun, schema, table, element }) {
let tabUid; let tabUid;
const workspaceTabs = state.workspaces.find(workspace => workspace.uid === uid); const workspaceTabs = state.workspaces.find(workspace => workspace.uid === uid);
@ -510,13 +511,13 @@ export default {
const tempTabs = workspaceTabs ? workspaceTabs.tabs.filter(tab => tab.type === 'temp-data') : false; const tempTabs = workspaceTabs ? workspaceTabs.tabs.filter(tab => tab.type === 'temp-data') : false;
if (tempTabs && tempTabs.length) { // if temp table already opened if (tempTabs && tempTabs.length) { // if temp table already opened
for (const tab of tempTabs) { for (const tab of tempTabs) {
commit('REPLACE_TAB', { uid, tab: tab.uid, type, schema, table }); commit('REPLACE_TAB', { uid, tab: tab.uid, type, schema, table, element });
tabUid = tab.uid; tabUid = tab.uid;
} }
} }
else { else {
tabUid = uidGen('T'); tabUid = uidGen('T');
commit('NEW_TAB', { uid, tab: tabUid, content, type, autorun, schema, table }); commit('NEW_TAB', { uid, tab: tabUid, content, type, autorun, schema, table, element });
} }
} }
} }
@ -529,7 +530,7 @@ export default {
: false; : false;
if (existentTab) { if (existentTab) {
commit('REPLACE_TAB', { uid, tab: existentTab.uid, type, schema, table }); commit('REPLACE_TAB', { uid, tab: existentTab.uid, type, schema, table, element });
tabUid = existentTab.uid; tabUid = existentTab.uid;
} }
else { else {