refactor: prefix to internal rows id

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

View File

@ -84,7 +84,7 @@ export default (connections) => {
}); });
ipcMain.handle('update-table-cell', async (event, params) => { ipcMain.handle('update-table-cell', async (event, params) => {
delete params.row._id; delete params.row._antares_id;
try { // TODO: move to client classes try { // TODO: move to client classes
let escapedParam; let escapedParam;

View File

@ -17,7 +17,7 @@
<form class="form-horizontal"> <form class="form-horizontal">
<div <div
v-for="(parameter, i) in inParameters" v-for="(parameter, i) in inParameters"
:key="parameter._id" :key="parameter._antares_id"
class="form-group" class="form-group"
> >
<div class="col-4"> <div class="col-4">

View File

@ -344,7 +344,7 @@ export default {
}, },
addField () { addField () {
this.localFields.push({ this.localFields.push({
_id: uidGen(), _antares_id: uidGen(),
name: `${this.$tc('word.field', 1)}_${++this.newFieldsCounter}`, name: `${this.$tc('word.field', 1)}_${++this.newFieldsCounter}`,
key: '', key: '',
type: this.workspace.dataTypes[0].types[0].name, type: this.workspace.dataTypes[0].types[0].name,
@ -385,8 +385,8 @@ export default {
}); });
}, },
duplicateField (uid) { duplicateField (uid) {
const fieldToClone = Object.assign({}, this.localFields.find(field => field._id === uid)); const fieldToClone = Object.assign({}, this.localFields.find(field => field._antares_id === uid));
fieldToClone._id = uidGen(); fieldToClone._antares_id = uidGen();
fieldToClone.name = `${fieldToClone.name}_copy`; fieldToClone.name = `${fieldToClone.name}_copy`;
fieldToClone.order = this.localFields.length + 1; fieldToClone.order = this.localFields.length + 1;
this.localFields = [...this.localFields, fieldToClone]; this.localFields = [...this.localFields, fieldToClone];
@ -397,11 +397,11 @@ export default {
}, 20); }, 20);
}, },
removeField (uid) { removeField (uid) {
this.localFields = this.localFields.filter(field => field._id !== uid); this.localFields = this.localFields.filter(field => field._antares_id !== uid);
}, },
addNewIndex (payload) { addNewIndex (payload) {
this.localIndexes = [...this.localIndexes, { this.localIndexes = [...this.localIndexes, {
_id: uidGen(), _antares_id: uidGen(),
name: payload.index === 'PRIMARY' ? 'PRIMARY' : payload.field, name: payload.index === 'PRIMARY' ? 'PRIMARY' : payload.field,
fields: [payload.field], fields: [payload.field],
type: payload.index, type: payload.index,
@ -413,7 +413,7 @@ export default {
}, },
addToIndex (payload) { addToIndex (payload) {
this.localIndexes = this.localIndexes.map(index => { this.localIndexes = this.localIndexes.map(index => {
if (index._id === payload.index) index.fields.push(payload.field); if (index._antares_id === payload.index) index.fields.push(payload.field);
return index; return index;
}); });
}, },

View File

@ -373,7 +373,7 @@ export default {
this.originalFunction = response; this.originalFunction = response;
this.originalFunction.parameters = [...this.originalFunction.parameters.map(param => { this.originalFunction.parameters = [...this.originalFunction.parameters.map(param => {
param._id = uidGen(); param._antares_id = uidGen();
return param; return param;
})]; })];

View File

@ -36,10 +36,10 @@
<div ref="parametersPanel" class="panel-body p-0 pr-1"> <div ref="parametersPanel" class="panel-body p-0 pr-1">
<div <div
v-for="param in parametersProxy" v-for="param in parametersProxy"
:key="param._id" :key="param._antares_id"
class="tile tile-centered c-hand mb-1 p-1" class="tile tile-centered c-hand mb-1 p-1"
:class="{'selected-element': selectedParam === param._id}" :class="{'selected-element': selectedParam === param._antares_id}"
@click="selectParameter($event, param._id)" @click="selectParameter($event, param._antares_id)"
> >
<div class="tile-icon"> <div class="tile-icon">
<div> <div>
@ -56,7 +56,7 @@
<button <button
class="btn btn-link remove-field p-0 mr-2" class="btn btn-link remove-field p-0 mr-2"
:title="$t('word.delete')" :title="$t('word.delete')"
@click.prevent="removeParameter(param._id)" @click.prevent="removeParameter(param._antares_id)"
> >
<i class="mdi mdi-close" /> <i class="mdi mdi-close" />
</button> </button>
@ -196,7 +196,7 @@ export default {
}, },
computed: { computed: {
selectedParamObj () { selectedParamObj () {
return this.parametersProxy.find(param => param._id === this.selectedParam); return this.parametersProxy.find(param => param._antares_id === this.selectedParam);
}, },
isChanged () { isChanged () {
return JSON.stringify(this.localParameters) !== JSON.stringify(this.parametersProxy); return JSON.stringify(this.localParameters) !== JSON.stringify(this.parametersProxy);
@ -238,7 +238,7 @@ export default {
}, },
addParameter () { addParameter () {
this.parametersProxy = [...this.parametersProxy, { this.parametersProxy = [...this.parametersProxy, {
_id: uidGen(), _antares_id: uidGen(),
name: `Param${this.i++}`, name: `Param${this.i++}`,
type: 'INT', type: 'INT',
context: 'IN', context: 'IN',
@ -253,7 +253,7 @@ export default {
}, 20); }, 20);
}, },
removeParameter (uid) { removeParameter (uid) {
this.parametersProxy = this.parametersProxy.filter(param => param._id !== uid); this.parametersProxy = this.parametersProxy.filter(param => param._antares_id !== uid);
if (this.selectedParam === name && this.parametersProxy.length) if (this.selectedParam === name && this.parametersProxy.length)
this.resetSelectedID(); this.resetSelectedID();
@ -266,7 +266,7 @@ export default {
this.resetSelectedID(); this.resetSelectedID();
}, },
resetSelectedID () { resetSelectedID () {
this.selectedParam = this.parametersProxy.length ? this.parametersProxy[0]._id : ''; this.selectedParam = this.parametersProxy.length ? this.parametersProxy[0]._antares_id : '';
} }
} }
}; };

View File

@ -318,7 +318,7 @@ export default {
this.originalRoutine = response; this.originalRoutine = response;
this.originalRoutine.parameters = [...this.originalRoutine.parameters.map(param => { this.originalRoutine.parameters = [...this.originalRoutine.parameters.map(param => {
param._id = uidGen(); param._antares_id = uidGen();
return param; return param;
})]; })];

View File

@ -36,10 +36,10 @@
<div ref="parametersPanel" class="panel-body p-0 pr-1"> <div ref="parametersPanel" class="panel-body p-0 pr-1">
<div <div
v-for="param in parametersProxy" v-for="param in parametersProxy"
:key="param._id" :key="param._antares_id"
class="tile tile-centered c-hand mb-1 p-1" class="tile tile-centered c-hand mb-1 p-1"
:class="{'selected-element': selectedParam === param._id}" :class="{'selected-element': selectedParam === param._antares_id}"
@click="selectParameter($event, param._id)" @click="selectParameter($event, param._antares_id)"
> >
<div class="tile-icon"> <div class="tile-icon">
<div> <div>
@ -56,7 +56,7 @@
<button <button
class="btn btn-link remove-field p-0 mr-2" class="btn btn-link remove-field p-0 mr-2"
:title="$t('word.delete')" :title="$t('word.delete')"
@click.prevent="removeParameter(param._id)" @click.prevent="removeParameter(param._antares_id)"
> >
<i class="mdi mdi-close" /> <i class="mdi mdi-close" />
</button> </button>
@ -196,7 +196,7 @@ export default {
}, },
computed: { computed: {
selectedParamObj () { selectedParamObj () {
return this.parametersProxy.find(param => param._id === this.selectedParam); return this.parametersProxy.find(param => param._antares_id === this.selectedParam);
}, },
isChanged () { isChanged () {
return JSON.stringify(this.localParameters) !== JSON.stringify(this.parametersProxy); return JSON.stringify(this.localParameters) !== JSON.stringify(this.parametersProxy);
@ -238,7 +238,7 @@ export default {
}, },
addParameter () { addParameter () {
this.parametersProxy = [...this.parametersProxy, { this.parametersProxy = [...this.parametersProxy, {
_id: uidGen(), _antares_id: uidGen(),
name: `param${this.i++}`, name: `param${this.i++}`,
type: this.workspace.dataTypes[0].types[0].name, type: this.workspace.dataTypes[0].types[0].name,
context: 'IN', context: 'IN',
@ -253,7 +253,7 @@ export default {
}, 20); }, 20);
}, },
removeParameter (uid) { removeParameter (uid) {
this.parametersProxy = this.parametersProxy.filter(param => param._id !== uid); this.parametersProxy = this.parametersProxy.filter(param => param._antares_id !== uid);
if (this.selectedParam === name && this.parametersProxy.length) if (this.selectedParam === name && this.parametersProxy.length)
this.resetSelectedID(); this.resetSelectedID();
@ -266,7 +266,7 @@ export default {
this.resetSelectedID(); this.resetSelectedID();
}, },
resetSelectedID () { resetSelectedID () {
this.selectedParam = this.parametersProxy.length ? this.parametersProxy[0]._id : ''; this.selectedParam = this.parametersProxy.length ? this.parametersProxy[0]._antares_id : '';
} }
} }
}; };

View File

@ -342,7 +342,7 @@ export default {
field.default = `'${field.default}'`; field.default = `'${field.default}'`;
} }
return { ...field, _id: uidGen() }; return { ...field, _antares_id: uidGen() };
}); });
this.localFields = JSON.parse(JSON.stringify(this.originalFields)); this.localFields = JSON.parse(JSON.stringify(this.originalFields));
} }
@ -365,7 +365,7 @@ export default {
this.originalIndexes = Object.keys(indexesObj).map(index => { this.originalIndexes = Object.keys(indexesObj).map(index => {
return { return {
_id: uidGen(), _antares_id: uidGen(),
name: index, name: index,
fields: indexesObj[index].map(field => field.column), fields: indexesObj[index].map(field => field.column),
type: indexesObj[index][0].type, type: indexesObj[index][0].type,
@ -391,7 +391,7 @@ export default {
if (status === 'success') { if (status === 'success') {
this.originalKeyUsage = response.map(foreign => { this.originalKeyUsage = response.map(foreign => {
return { return {
_id: uidGen(), _antares_id: uidGen(),
...foreign ...foreign
}; };
}); });
@ -411,25 +411,25 @@ export default {
this.isSaving = true; this.isSaving = true;
// FIELDS // FIELDS
const originalIDs = this.originalFields.reduce((acc, curr) => [...acc, curr._id], []); const originalIDs = this.originalFields.reduce((acc, curr) => [...acc, curr._antares_id], []);
const localIDs = this.localFields.reduce((acc, curr) => [...acc, curr._id], []); const localIDs = this.localFields.reduce((acc, curr) => [...acc, curr._antares_id], []);
// Fields Additions // Fields Additions
const additions = this.localFields.filter((field, i) => !originalIDs.includes(field._id)).map(field => { const additions = this.localFields.filter((field, i) => !originalIDs.includes(field._antares_id)).map(field => {
const lI = this.localFields.findIndex(localField => localField._id === field._id); const lI = this.localFields.findIndex(localField => localField._antares_id === field._antares_id);
const after = lI > 0 ? this.localFields[lI - 1].name : false; const after = lI > 0 ? this.localFields[lI - 1].name : false;
return { ...field, after }; return { ...field, after };
}); });
// Fields Deletions // Fields Deletions
const deletions = this.originalFields.filter(field => !localIDs.includes(field._id)); const deletions = this.originalFields.filter(field => !localIDs.includes(field._antares_id));
// Fields Changes // Fields Changes
const changes = []; const changes = [];
this.originalFields.forEach((originalField, oI) => { this.originalFields.forEach((originalField, oI) => {
const lI = this.localFields.findIndex(localField => localField._id === originalField._id); const lI = this.localFields.findIndex(localField => localField._antares_id === originalField._antares_id);
const originalSibling = oI > 0 ? this.originalFields[oI - 1]._id : false; const originalSibling = oI > 0 ? this.originalFields[oI - 1]._antares_id : false;
const localSibling = lI > 0 ? this.localFields[lI - 1]._id : false; const localSibling = lI > 0 ? this.localFields[lI - 1]._antares_id : false;
const after = lI > 0 ? this.localFields[lI - 1].name : false; const after = lI > 0 ? this.localFields[lI - 1].name : false;
const orgName = originalField.name; const orgName = originalField.name;
@ -450,15 +450,15 @@ export default {
changes: [], changes: [],
deletions: [] deletions: []
}; };
const originalIndexIDs = this.originalIndexes.reduce((acc, curr) => [...acc, curr._id], []); const originalIndexIDs = this.originalIndexes.reduce((acc, curr) => [...acc, curr._antares_id], []);
const localIndexIDs = this.localIndexes.reduce((acc, curr) => [...acc, curr._id], []); const localIndexIDs = this.localIndexes.reduce((acc, curr) => [...acc, curr._antares_id], []);
// Index Additions // Index Additions
indexChanges.additions = this.localIndexes.filter(index => !originalIndexIDs.includes(index._id)); indexChanges.additions = this.localIndexes.filter(index => !originalIndexIDs.includes(index._antares_id));
// Index Changes // Index Changes
this.originalIndexes.forEach(originalIndex => { this.originalIndexes.forEach(originalIndex => {
const lI = this.localIndexes.findIndex(localIndex => localIndex._id === originalIndex._id); const lI = this.localIndexes.findIndex(localIndex => localIndex._antares_id === originalIndex._antares_id);
if (JSON.stringify(originalIndex) !== JSON.stringify(this.localIndexes[lI])) { if (JSON.stringify(originalIndex) !== JSON.stringify(this.localIndexes[lI])) {
if (this.localIndexes[lI]) { if (this.localIndexes[lI]) {
indexChanges.changes.push({ indexChanges.changes.push({
@ -471,7 +471,7 @@ export default {
}); });
// Index Deletions // Index Deletions
indexChanges.deletions = this.originalIndexes.filter(index => !localIndexIDs.includes(index._id)); indexChanges.deletions = this.originalIndexes.filter(index => !localIndexIDs.includes(index._antares_id));
// FOREIGN KEYS // FOREIGN KEYS
const foreignChanges = { const foreignChanges = {
@ -479,15 +479,15 @@ export default {
changes: [], changes: [],
deletions: [] deletions: []
}; };
const originalForeignIDs = this.originalKeyUsage.reduce((acc, curr) => [...acc, curr._id], []); const originalForeignIDs = this.originalKeyUsage.reduce((acc, curr) => [...acc, curr._antares_id], []);
const localForeignIDs = this.localKeyUsage.reduce((acc, curr) => [...acc, curr._id], []); const localForeignIDs = this.localKeyUsage.reduce((acc, curr) => [...acc, curr._antares_id], []);
// Foreigns Additions // Foreigns Additions
foreignChanges.additions = this.localKeyUsage.filter(foreign => !originalForeignIDs.includes(foreign._id)); foreignChanges.additions = this.localKeyUsage.filter(foreign => !originalForeignIDs.includes(foreign._antares_id));
// Foreigns Changes // Foreigns Changes
this.originalKeyUsage.forEach(originalForeign => { this.originalKeyUsage.forEach(originalForeign => {
const lI = this.localKeyUsage.findIndex(localForeign => localForeign._id === originalForeign._id); const lI = this.localKeyUsage.findIndex(localForeign => localForeign._antares_id === originalForeign._antares_id);
if (JSON.stringify(originalForeign) !== JSON.stringify(this.localKeyUsage[lI])) { if (JSON.stringify(originalForeign) !== JSON.stringify(this.localKeyUsage[lI])) {
if (this.localKeyUsage[lI]) { if (this.localKeyUsage[lI]) {
foreignChanges.changes.push({ foreignChanges.changes.push({
@ -499,7 +499,7 @@ export default {
}); });
// Foreigns Deletions // Foreigns Deletions
foreignChanges.deletions = this.originalKeyUsage.filter(foreign => !localForeignIDs.includes(foreign._id)); foreignChanges.deletions = this.originalKeyUsage.filter(foreign => !localForeignIDs.includes(foreign._antares_id));
// ALTER // ALTER
const params = { const params = {
@ -555,7 +555,7 @@ export default {
}, },
addField () { addField () {
this.localFields.push({ this.localFields.push({
_id: uidGen(), _antares_id: uidGen(),
name: `${this.$tc('word.field', 1)}_${++this.newFieldsCounter}`, name: `${this.$tc('word.field', 1)}_${++this.newFieldsCounter}`,
key: '', key: '',
type: this.workspace.dataTypes[0].types[0].name, type: this.workspace.dataTypes[0].types[0].name,
@ -597,8 +597,8 @@ export default {
}); });
}, },
duplicateField (uid) { duplicateField (uid) {
const fieldToClone = Object.assign({}, this.localFields.find(field => field._id === uid)); const fieldToClone = Object.assign({}, this.localFields.find(field => field._antares_id === uid));
fieldToClone._id = uidGen(); fieldToClone._antares_id = uidGen();
fieldToClone.name = `${fieldToClone.name}_copy`; fieldToClone.name = `${fieldToClone.name}_copy`;
fieldToClone.order = this.localFields.length + 1; fieldToClone.order = this.localFields.length + 1;
this.localFields = [...this.localFields, fieldToClone]; this.localFields = [...this.localFields, fieldToClone];
@ -609,11 +609,11 @@ export default {
}, 20); }, 20);
}, },
removeField (uid) { removeField (uid) {
this.localFields = this.localFields.filter(field => field._id !== uid); this.localFields = this.localFields.filter(field => field._antares_id !== uid);
}, },
addNewIndex (payload) { addNewIndex (payload) {
this.localIndexes = [...this.localIndexes, { this.localIndexes = [...this.localIndexes, {
_id: uidGen(), _antares_id: uidGen(),
name: payload.index === 'PRIMARY' ? 'PRIMARY' : payload.field, name: payload.index === 'PRIMARY' ? 'PRIMARY' : payload.field,
fields: [payload.field], fields: [payload.field],
type: payload.index, type: payload.index,
@ -625,7 +625,7 @@ export default {
}, },
addToIndex (payload) { addToIndex (payload) {
this.localIndexes = this.localIndexes.map(index => { this.localIndexes = this.localIndexes.map(index => {
if (index._id === payload.index) index.fields.push(payload.field); if (index._antares_id === payload.index) index.fields.push(payload.field);
return index; return index;
}); });
}, },

View File

@ -27,7 +27,7 @@
:key="index.name" :key="index.name"
class="context-element" class="context-element"
:class="{'disabled': index.fields.includes(selectedField.name)}" :class="{'disabled': index.fields.includes(selectedField.name)}"
@click="addToIndex(index._id)" @click="addToIndex(index._antares_id)"
> >
<span class="d-flex"><i class="mdi mdi-18px mdi-key column-key pr-1" :class="`key-${index.type}`" /> {{ index.name }}</span> <span class="d-flex"><i class="mdi mdi-18px mdi-key column-key pr-1" :class="`key-${index.type}`" /> {{ index.name }}</span>
</div> </div>

View File

@ -109,7 +109,7 @@
> >
<TableRow <TableRow
v-for="row in fields" v-for="row in fields"
:key="row._id" :key="row._antares_id"
:row="row" :row="row"
:indexes="getIndexes(row.name)" :indexes="getIndexes(row.name)"
:foreigns="getForeigns(row.name)" :foreigns="getForeigns(row.name)"
@ -217,15 +217,15 @@ export default {
this.resizeResults(); this.resizeResults();
}, },
contextMenu (event, uid) { contextMenu (event, uid) {
this.selectedField = this.fields.find(field => field._id === uid); this.selectedField = this.fields.find(field => field._antares_id === uid);
this.contextEvent = event; this.contextEvent = event;
this.isContext = true; this.isContext = true;
}, },
duplicateField () { duplicateField () {
this.$emit('duplicate-field', this.selectedField._id); this.$emit('duplicate-field', this.selectedField._antares_id);
}, },
removeField () { removeField () {
this.$emit('remove-field', this.selectedField._id); this.$emit('remove-field', this.selectedField._antares_id);
}, },
getIndexes (field) { getIndexes (field) {
return this.indexes.reduce((acc, curr) => { return this.indexes.reduce((acc, curr) => {

View File

@ -36,10 +36,10 @@
<div ref="indexesPanel" class="panel-body p-0 pr-1"> <div ref="indexesPanel" class="panel-body p-0 pr-1">
<div <div
v-for="foreign in foreignProxy" v-for="foreign in foreignProxy"
:key="foreign._id" :key="foreign._antares_id"
class="tile tile-centered c-hand mb-1 p-1" class="tile tile-centered c-hand mb-1 p-1"
:class="{'selected-element': selectedForeignID === foreign._id}" :class="{'selected-element': selectedForeignID === foreign._antares_id}"
@click="selectForeign($event, foreign._id)" @click="selectForeign($event, foreign._antares_id)"
> >
<div class="tile-icon"> <div class="tile-icon">
<div> <div>
@ -68,7 +68,7 @@
<button <button
class="btn btn-link remove-field p-0 mr-2" class="btn btn-link remove-field p-0 mr-2"
:title="$t('word.delete')" :title="$t('word.delete')"
@click.prevent="removeIndex(foreign._id)" @click.prevent="removeIndex(foreign._antares_id)"
> >
<i class="mdi mdi-close" /> <i class="mdi mdi-close" />
</button> </button>
@ -238,7 +238,7 @@ export default {
}, },
computed: { computed: {
selectedForeignObj () { selectedForeignObj () {
return this.foreignProxy.find(foreign => foreign._id === this.selectedForeignID); return this.foreignProxy.find(foreign => foreign._antares_id === this.selectedForeignID);
}, },
isChanged () { isChanged () {
return JSON.stringify(this.localKeyUsage) !== JSON.stringify(this.foreignProxy); return JSON.stringify(this.localKeyUsage) !== JSON.stringify(this.foreignProxy);
@ -288,7 +288,7 @@ export default {
}, },
addForeign () { addForeign () {
this.foreignProxy = [...this.foreignProxy, { this.foreignProxy = [...this.foreignProxy, {
_id: uidGen(), _antares_id: uidGen(),
constraintName: `FK_${this.foreignProxy.length + 1}`, constraintName: `FK_${this.foreignProxy.length + 1}`,
refSchema: this.schema, refSchema: this.schema,
table: this.table, table: this.table,
@ -307,19 +307,19 @@ export default {
}, 20); }, 20);
}, },
removeIndex (id) { removeIndex (id) {
this.foreignProxy = this.foreignProxy.filter(foreign => foreign._id !== id); this.foreignProxy = this.foreignProxy.filter(foreign => foreign._antares_id !== id);
if (this.selectedForeignID === id && this.foreignProxy.length) if (this.selectedForeignID === id && this.foreignProxy.length)
this.resetSelectedID(); this.resetSelectedID();
}, },
clearChanges () { clearChanges () {
this.foreignProxy = JSON.parse(JSON.stringify(this.localKeyUsage)); this.foreignProxy = JSON.parse(JSON.stringify(this.localKeyUsage));
if (!this.foreignProxy.some(foreign => foreign._id === this.selectedForeignID)) if (!this.foreignProxy.some(foreign => foreign._antares_id === this.selectedForeignID))
this.resetSelectedID(); this.resetSelectedID();
}, },
toggleField (field) { toggleField (field) {
this.foreignProxy = this.foreignProxy.map(foreign => { this.foreignProxy = this.foreignProxy.map(foreign => {
if (foreign._id === this.selectedForeignID) if (foreign._antares_id === this.selectedForeignID)
foreign.field = field; foreign.field = field;
return foreign; return foreign;
@ -327,14 +327,14 @@ export default {
}, },
toggleRefField (field) { toggleRefField (field) {
this.foreignProxy = this.foreignProxy.map(foreign => { this.foreignProxy = this.foreignProxy.map(foreign => {
if (foreign._id === this.selectedForeignID) if (foreign._antares_id === this.selectedForeignID)
foreign.refField = field; foreign.refField = field;
return foreign; return foreign;
}); });
}, },
resetSelectedID () { resetSelectedID () {
this.selectedForeignID = this.foreignProxy.length ? this.foreignProxy[0]._id : ''; this.selectedForeignID = this.foreignProxy.length ? this.foreignProxy[0]._antares_id : '';
}, },
async getRefFields () { async getRefFields () {
if (!this.selectedForeignObj.refTable) return; if (!this.selectedForeignObj.refTable) return;

View File

@ -36,10 +36,10 @@
<div ref="indexesPanel" class="panel-body p-0 pr-1"> <div ref="indexesPanel" class="panel-body p-0 pr-1">
<div <div
v-for="index in indexesProxy" v-for="index in indexesProxy"
:key="index._id" :key="index._antares_id"
class="tile tile-centered c-hand mb-1 p-1" class="tile tile-centered c-hand mb-1 p-1"
:class="{'selected-element': selectedIndexID === index._id}" :class="{'selected-element': selectedIndexID === index._antares_id}"
@click="selectIndex($event, index._id)" @click="selectIndex($event, index._antares_id)"
> >
<div class="tile-icon"> <div class="tile-icon">
<div> <div>
@ -56,7 +56,7 @@
<button <button
class="btn btn-link remove-field p-0 mr-2" class="btn btn-link remove-field p-0 mr-2"
:title="$t('word.delete')" :title="$t('word.delete')"
@click.prevent="removeIndex(index._id)" @click.prevent="removeIndex(index._antares_id)"
> >
<i class="mdi mdi-close" /> <i class="mdi mdi-close" />
</button> </button>
@ -163,7 +163,7 @@ export default {
}, },
computed: { computed: {
selectedIndexObj () { selectedIndexObj () {
return this.indexesProxy.find(index => index._id === this.selectedIndexID); return this.indexesProxy.find(index => index._antares_id === this.selectedIndexID);
}, },
isChanged () { isChanged () {
return JSON.stringify(this.localIndexes) !== JSON.stringify(this.indexesProxy); return JSON.stringify(this.localIndexes) !== JSON.stringify(this.indexesProxy);
@ -200,7 +200,7 @@ export default {
}, },
addIndex () { addIndex () {
this.indexesProxy = [...this.indexesProxy, { this.indexesProxy = [...this.indexesProxy, {
_id: uidGen(), _antares_id: uidGen(),
name: 'NEW_INDEX', name: 'NEW_INDEX',
fields: [], fields: [],
type: 'INDEX', type: 'INDEX',
@ -218,19 +218,19 @@ export default {
}, 20); }, 20);
}, },
removeIndex (id) { removeIndex (id) {
this.indexesProxy = this.indexesProxy.filter(index => index._id !== id); this.indexesProxy = this.indexesProxy.filter(index => index._antares_id !== id);
if (this.selectedIndexID === id && this.indexesProxy.length) if (this.selectedIndexID === id && this.indexesProxy.length)
this.resetSelectedID(); this.resetSelectedID();
}, },
clearChanges () { clearChanges () {
this.indexesProxy = JSON.parse(JSON.stringify(this.localIndexes)); this.indexesProxy = JSON.parse(JSON.stringify(this.localIndexes));
if (!this.indexesProxy.some(index => index._id === this.selectedIndexID)) if (!this.indexesProxy.some(index => index._antares_id === this.selectedIndexID))
this.resetSelectedID(); this.resetSelectedID();
}, },
toggleField (field) { toggleField (field) {
this.indexesProxy = this.indexesProxy.map(index => { this.indexesProxy = this.indexesProxy.map(index => {
if (index._id === this.selectedIndexID) { if (index._antares_id === this.selectedIndexID) {
if (index.fields.includes(field)) if (index.fields.includes(field))
index.fields = index.fields.filter(f => f !== field); index.fields = index.fields.filter(f => f !== field);
else else
@ -240,7 +240,7 @@ export default {
}); });
}, },
resetSelectedID () { resetSelectedID () {
this.selectedIndexID = this.indexesProxy.length ? this.indexesProxy[0]._id : ''; this.selectedIndexID = this.indexesProxy.length ? this.indexesProxy[0]._antares_id : '';
} }
} }
}; };

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="tr" @contextmenu.prevent="$emit('contextmenu', $event, localRow._id)"> <div class="tr" @contextmenu.prevent="$emit('contextmenu', $event, localRow._antares_id)">
<div class="td p-0" tabindex="0"> <div class="td p-0" tabindex="0">
<div :class="customizations.sortableFields ? 'row-draggable' : 'text-center'"> <div :class="customizations.sortableFields ? 'row-draggable' : 'text-center'">
<i v-if="customizations.sortableFields" class="mdi mdi-drag-horizontal row-draggable-icon" /> <i v-if="customizations.sortableFields" class="mdi mdi-drag-horizontal row-draggable-icon" />

View File

@ -238,7 +238,7 @@ export default {
this.originalFunction = response; this.originalFunction = response;
this.originalFunction.parameters = [...this.originalFunction.parameters.map(param => { this.originalFunction.parameters = [...this.originalFunction.parameters.map(param => {
param._id = uidGen(); param._antares_id = uidGen();
return param; return param;
})]; })];

View File

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

View File

@ -1,14 +1,14 @@
<template> <template>
<div class="tr" @click="selectRow($event, row._id)"> <div class="tr" @click="selectRow($event, row._antares_id)">
<div <div
v-for="(col, cKey) in row" v-for="(col, cKey) in row"
v-show="cKey !== '_id'" v-show="cKey !== '_antares_id'"
:key="cKey" :key="cKey"
class="td p-0" class="td p-0"
tabindex="0" tabindex="0"
@contextmenu.prevent="openContext($event, { id: row._id, field: cKey })" @contextmenu.prevent="openContext($event, { id: row._antares_id, field: cKey })"
> >
<template v-if="cKey !== '_id'"> <template v-if="cKey !== '_antares_id'">
<span <span
v-if="!isInlineEditor[cKey] && fields[cKey]" v-if="!isInlineEditor[cKey] && fields[cKey]"
class="cell-content" class="cell-content"

View File

@ -142,7 +142,7 @@
code { code {
background-color: #000; background-color: #000;
color: $body-font-color-dark; color: rgba($body-font-color-dark, 0.7);
} }
// Antares // Antares