refactor: adaptation of row deletion and modification functions due last commits

This commit is contained in:
Fabio 2020-09-06 10:35:32 +02:00
parent 023c6a633a
commit 1d87ca959f
3 changed files with 26 additions and 7 deletions

View File

@ -80,8 +80,8 @@ export default {
return this.getWorkspace(this.connection.uid);
},
schema () {
if ('fields' in this.results && this.results.fields.length)
return this.results.fields[0].db;
if ('fields' in this.results && this.results[this.selectedResultsset].fields.length)
return this.results[this.selectedResultsset].fields[0].db;
return this.workspace.breadcrumbs.schema;
}
},

View File

@ -169,6 +169,9 @@ export default {
this.setTabKeyUsage({ cUid: this.connection.uid, tUid: this.tabUid, keyUsage: keysArr });
this.isQuering = false;
},
getTable () {
return this.table;
},
reloadTable () {
this.getTableData();
},

View File

@ -7,8 +7,8 @@ export default {
const params = {
uid: this.connection.uid,
schema: this.workspace.breadcrumbs.schema,
table: this.table,
schema: this.schema,
table: this.getTable(this.selectedResultsset),
...payload
};
@ -34,16 +34,32 @@ export default {
const params = {
uid: this.connection.uid,
schema: this.workspace.breadcrumbs.schema,
table: this.workspace.breadcrumbs.table,
schema: this.schema,
table: this.getTable(this.selectedResultsset),
...payload
};
try {
const { status, response } = await Tables.deleteTableRows(params);
if (status === 'success') {
const { primary, rows } = params;
this.results = { ...this.results, rows: this.results.rows.filter(row => !rows.includes(row[primary])) };
if (Array.isArray(this.results)) {
this.results = this.results.map((result, index) => {
if (index === this.selectedResultsset) {
return {
...result,
rows: result.rows.filter(row => !rows.includes(row[primary]))
};
}
else
return result;
});
}
else
this.results = { ...this.results, rows: this.results.rows.filter(row => !rows.includes(row[primary])) };
this.$refs.queryTable.refreshScroller();// Necessary to re-render virtual scroller
}
else