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

refactor: prefix to internal rows id

This commit is contained in:
2021-11-08 15:12:37 +01:00
parent fd25f881f9
commit 3369d3dc2d
17 changed files with 104 additions and 104 deletions

View File

@ -70,13 +70,13 @@
<template slot-scope="{ items }">
<WorkspaceTabQueryTableRow
v-for="row in items"
:key="row._id"
:key="row._antares_id"
:row="row"
:fields="fieldsObj"
:key-usage="keyUsage"
:element-type="elementType"
:class="{'selected': selectedRows.includes(row._id)}"
@select-row="selectRow($event, row._id)"
:class="{'selected': selectedRows.includes(row._antares_id)}"
@select-row="selectRow($event, row._antares_id)"
@update-field="updateField($event, row)"
@contextmenu="contextMenu"
/>
@ -196,7 +196,7 @@ export default {
if (this.sortedResults.length) {
const fieldsObj = {};
for (const key in this.sortedResults[0]) {
if (key === '_id') continue;
if (key === '_antares_id') continue;
const fieldObj = this.fields.find(field => {
let fieldNames = [
@ -310,7 +310,7 @@ export default {
setLocalResults () {
this.localResults = this.resultsWithRows[this.resultsetIndex] && this.resultsWithRows[this.resultsetIndex].rows
? this.resultsWithRows[this.resultsetIndex].rows.map(item => {
return { ...item, _id: uidGen() };
return { ...item, _antares_id: uidGen() };
})
: [];
},
@ -330,7 +330,7 @@ export default {
this.resizeResults();
},
updateField (payload, row) {
const orgRow = this.localResults.find(lr => lr._id === row._id);
const orgRow = this.localResults.find(lr => lr._antares_id === row._antares_id);
Object.keys(orgRow).forEach(key => { // remap the row
if (orgRow[key] instanceof Date && moment(orgRow[key]).isValid()) { // if datetime
@ -367,8 +367,8 @@ export default {
},
deleteSelected () {
this.closeContext();
const rows = JSON.parse(JSON.stringify(this.localResults)).filter(row => this.selectedRows.includes(row._id)).map(row => {
delete row._id;
const rows = JSON.parse(JSON.stringify(this.localResults)).filter(row => this.selectedRows.includes(row._antares_id)).map(row => {
delete row._antares_id;
return row;
});
@ -381,7 +381,7 @@ export default {
this.$emit('delete-selected', params);
},
setNull () {
const row = this.localResults.find(row => this.selectedRows.includes(row._id));
const row = this.localResults.find(row => this.selectedRows.includes(row._antares_id));
const params = {
primary: this.primaryField.name,
@ -396,7 +396,7 @@ export default {
this.$emit('update-field', params);
},
copyCell () {
const row = this.localResults.find(row => this.selectedRows.includes(row._id));
const row = this.localResults.find(row => this.selectedRows.includes(row._antares_id));
const cellName = Object.keys(row).find(prop => [
this.selectedCell.field,
`${this.fields[0].table}.${this.selectedCell.field}`,
@ -406,9 +406,9 @@ export default {
navigator.clipboard.writeText(valueToCopy);
},
copyRow () {
const row = this.localResults.find(row => this.selectedRows.includes(row._id));
const row = this.localResults.find(row => this.selectedRows.includes(row._antares_id));
const rowToCopy = JSON.parse(JSON.stringify(row));
delete rowToCopy._id;
delete rowToCopy._antares_id;
navigator.clipboard.writeText(JSON.stringify(rowToCopy));
},
applyUpdate (params) {
@ -435,15 +435,15 @@ export default {
this.selectedRows.push(row);
else {
const lastID = this.selectedRows.slice(-1)[0];
const lastIndex = this.sortedResults.findIndex(el => el._id === lastID);
const clickedIndex = this.sortedResults.findIndex(el => el._id === row);
const lastIndex = this.sortedResults.findIndex(el => el._antares_id === lastID);
const clickedIndex = this.sortedResults.findIndex(el => el._antares_id === row);
if (lastIndex > clickedIndex) {
for (let i = clickedIndex; i < lastIndex; i++)
this.selectedRows.push(this.sortedResults[i]._id);
this.selectedRows.push(this.sortedResults[i]._antares_id);
}
else if (lastIndex < clickedIndex) {
for (let i = clickedIndex; i > lastIndex; i--)
this.selectedRows.push(this.sortedResults[i]._id);
this.selectedRows.push(this.sortedResults[i]._antares_id);
}
}
}
@ -452,7 +452,7 @@ export default {
},
selectAllRows () {
this.selectedRows = this.localResults.reduce((acc, curr) => {
acc.push(curr._id);
acc.push(curr._antares_id);
return acc;
}, []);
},
@ -501,7 +501,7 @@ export default {
if (!this.sortedResults) return;
const rows = JSON.parse(JSON.stringify(this.sortedResults)).map(row => {
delete row._id;
delete row._antares_id;
return row;
});