mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
feat: rename tabs if element is renamed
This commit is contained in:
@ -224,6 +224,7 @@ export default {
|
|||||||
refreshStructure: 'workspaces/refreshStructure',
|
refreshStructure: 'workspaces/refreshStructure',
|
||||||
setUnsavedChanges: 'workspaces/setUnsavedChanges',
|
setUnsavedChanges: 'workspaces/setUnsavedChanges',
|
||||||
newTab: 'workspaces/newTab',
|
newTab: 'workspaces/newTab',
|
||||||
|
renameTabs: 'workspaces/renameTabs',
|
||||||
changeBreadcrumbs: 'workspaces/changeBreadcrumbs'
|
changeBreadcrumbs: 'workspaces/changeBreadcrumbs'
|
||||||
}),
|
}),
|
||||||
async getFieldsData () {
|
async getFieldsData () {
|
||||||
@ -233,7 +234,10 @@ export default {
|
|||||||
this.lastTable = this.table;
|
this.lastTable = this.table;
|
||||||
this.newFieldsCounter = 0;
|
this.newFieldsCounter = 0;
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
this.localOptions = JSON.parse(JSON.stringify(this.tableOptions));
|
try {
|
||||||
|
this.localOptions = JSON.parse(JSON.stringify(this.tableOptions));
|
||||||
|
}
|
||||||
|
catch (error) {}
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
uid: this.connection.uid,
|
uid: this.connection.uid,
|
||||||
@ -441,7 +445,13 @@ export default {
|
|||||||
|
|
||||||
if (oldName !== this.localOptions.name) {
|
if (oldName !== this.localOptions.name) {
|
||||||
this.setUnsavedChanges(false);
|
this.setUnsavedChanges(false);
|
||||||
this.newTab({ uid: this.connection.uid, schema: this.schema, table: this.localOptions.name, type: 'table-props' });// TODO: rename function that gets new and old name and change it on all opened tables
|
this.renameTabs({
|
||||||
|
uid: this.connection.uid,
|
||||||
|
schema: this.schema,
|
||||||
|
elementName: oldName,
|
||||||
|
elementNewName: this.localOptions.name,
|
||||||
|
elementType: 'table'
|
||||||
|
});
|
||||||
this.changeBreadcrumbs({ schema: this.schema, table: this.localOptions.name });
|
this.changeBreadcrumbs({ schema: this.schema, table: this.localOptions.name });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,6 +235,27 @@ export default {
|
|||||||
return workspace;
|
return workspace;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
RENAME_TABS (state, { uid, schema, elementName, elementType, elementNewName }) {
|
||||||
|
state.workspaces = state.workspaces.map(workspace => {
|
||||||
|
if (workspace.uid === uid) {
|
||||||
|
return {
|
||||||
|
...workspace,
|
||||||
|
tabs: workspace.tabs.map(tab => {
|
||||||
|
if (tab[elementType] === elementName && tab.schema === schema) {
|
||||||
|
return {
|
||||||
|
...tab,
|
||||||
|
[elementType]: elementNewName
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return tab;
|
||||||
|
})
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return workspace;
|
||||||
|
});
|
||||||
|
},
|
||||||
SELECT_TAB (state, { uid, tab }) {
|
SELECT_TAB (state, { uid, tab }) {
|
||||||
state.workspaces = state.workspaces.map(workspace => workspace.uid === uid ? { ...workspace, selected_tab: tab } : workspace);
|
state.workspaces = state.workspaces.map(workspace => workspace.uid === uid ? { ...workspace, selected_tab: tab } : workspace);
|
||||||
},
|
},
|
||||||
@ -566,6 +587,9 @@ export default {
|
|||||||
|
|
||||||
commit('SELECT_TAB', { uid, tab: tabUid });
|
commit('SELECT_TAB', { uid, tab: tabUid });
|
||||||
},
|
},
|
||||||
|
renameTabs ({ commit }, payload) {
|
||||||
|
commit('RENAME_TABS', payload);
|
||||||
|
},
|
||||||
removeTab ({ commit }, payload) {
|
removeTab ({ commit }, payload) {
|
||||||
commit('REMOVE_TAB', payload);
|
commit('REMOVE_TAB', payload);
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user