mirror of https://github.com/Fabio286/antares.git
refactor: prefix to internal rows id
This commit is contained in:
parent
fd25f881f9
commit
3369d3dc2d
|
@ -84,7 +84,7 @@ export default (connections) => {
|
|||
});
|
||||
|
||||
ipcMain.handle('update-table-cell', async (event, params) => {
|
||||
delete params.row._id;
|
||||
delete params.row._antares_id;
|
||||
|
||||
try { // TODO: move to client classes
|
||||
let escapedParam;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<form class="form-horizontal">
|
||||
<div
|
||||
v-for="(parameter, i) in inParameters"
|
||||
:key="parameter._id"
|
||||
:key="parameter._antares_id"
|
||||
class="form-group"
|
||||
>
|
||||
<div class="col-4">
|
||||
|
|
|
@ -344,7 +344,7 @@ export default {
|
|||
},
|
||||
addField () {
|
||||
this.localFields.push({
|
||||
_id: uidGen(),
|
||||
_antares_id: uidGen(),
|
||||
name: `${this.$tc('word.field', 1)}_${++this.newFieldsCounter}`,
|
||||
key: '',
|
||||
type: this.workspace.dataTypes[0].types[0].name,
|
||||
|
@ -385,8 +385,8 @@ export default {
|
|||
});
|
||||
},
|
||||
duplicateField (uid) {
|
||||
const fieldToClone = Object.assign({}, this.localFields.find(field => field._id === uid));
|
||||
fieldToClone._id = uidGen();
|
||||
const fieldToClone = Object.assign({}, this.localFields.find(field => field._antares_id === uid));
|
||||
fieldToClone._antares_id = uidGen();
|
||||
fieldToClone.name = `${fieldToClone.name}_copy`;
|
||||
fieldToClone.order = this.localFields.length + 1;
|
||||
this.localFields = [...this.localFields, fieldToClone];
|
||||
|
@ -397,11 +397,11 @@ export default {
|
|||
}, 20);
|
||||
},
|
||||
removeField (uid) {
|
||||
this.localFields = this.localFields.filter(field => field._id !== uid);
|
||||
this.localFields = this.localFields.filter(field => field._antares_id !== uid);
|
||||
},
|
||||
addNewIndex (payload) {
|
||||
this.localIndexes = [...this.localIndexes, {
|
||||
_id: uidGen(),
|
||||
_antares_id: uidGen(),
|
||||
name: payload.index === 'PRIMARY' ? 'PRIMARY' : payload.field,
|
||||
fields: [payload.field],
|
||||
type: payload.index,
|
||||
|
@ -413,7 +413,7 @@ export default {
|
|||
},
|
||||
addToIndex (payload) {
|
||||
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;
|
||||
});
|
||||
},
|
||||
|
|
|
@ -373,7 +373,7 @@ export default {
|
|||
this.originalFunction = response;
|
||||
|
||||
this.originalFunction.parameters = [...this.originalFunction.parameters.map(param => {
|
||||
param._id = uidGen();
|
||||
param._antares_id = uidGen();
|
||||
return param;
|
||||
})];
|
||||
|
||||
|
|
|
@ -36,10 +36,10 @@
|
|||
<div ref="parametersPanel" class="panel-body p-0 pr-1">
|
||||
<div
|
||||
v-for="param in parametersProxy"
|
||||
:key="param._id"
|
||||
:key="param._antares_id"
|
||||
class="tile tile-centered c-hand mb-1 p-1"
|
||||
:class="{'selected-element': selectedParam === param._id}"
|
||||
@click="selectParameter($event, param._id)"
|
||||
:class="{'selected-element': selectedParam === param._antares_id}"
|
||||
@click="selectParameter($event, param._antares_id)"
|
||||
>
|
||||
<div class="tile-icon">
|
||||
<div>
|
||||
|
@ -56,7 +56,7 @@
|
|||
<button
|
||||
class="btn btn-link remove-field p-0 mr-2"
|
||||
:title="$t('word.delete')"
|
||||
@click.prevent="removeParameter(param._id)"
|
||||
@click.prevent="removeParameter(param._antares_id)"
|
||||
>
|
||||
<i class="mdi mdi-close" />
|
||||
</button>
|
||||
|
@ -196,7 +196,7 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
selectedParamObj () {
|
||||
return this.parametersProxy.find(param => param._id === this.selectedParam);
|
||||
return this.parametersProxy.find(param => param._antares_id === this.selectedParam);
|
||||
},
|
||||
isChanged () {
|
||||
return JSON.stringify(this.localParameters) !== JSON.stringify(this.parametersProxy);
|
||||
|
@ -238,7 +238,7 @@ export default {
|
|||
},
|
||||
addParameter () {
|
||||
this.parametersProxy = [...this.parametersProxy, {
|
||||
_id: uidGen(),
|
||||
_antares_id: uidGen(),
|
||||
name: `Param${this.i++}`,
|
||||
type: 'INT',
|
||||
context: 'IN',
|
||||
|
@ -253,7 +253,7 @@ export default {
|
|||
}, 20);
|
||||
},
|
||||
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)
|
||||
this.resetSelectedID();
|
||||
|
@ -266,7 +266,7 @@ export default {
|
|||
this.resetSelectedID();
|
||||
},
|
||||
resetSelectedID () {
|
||||
this.selectedParam = this.parametersProxy.length ? this.parametersProxy[0]._id : '';
|
||||
this.selectedParam = this.parametersProxy.length ? this.parametersProxy[0]._antares_id : '';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -318,7 +318,7 @@ export default {
|
|||
this.originalRoutine = response;
|
||||
|
||||
this.originalRoutine.parameters = [...this.originalRoutine.parameters.map(param => {
|
||||
param._id = uidGen();
|
||||
param._antares_id = uidGen();
|
||||
return param;
|
||||
})];
|
||||
|
||||
|
|
|
@ -36,10 +36,10 @@
|
|||
<div ref="parametersPanel" class="panel-body p-0 pr-1">
|
||||
<div
|
||||
v-for="param in parametersProxy"
|
||||
:key="param._id"
|
||||
:key="param._antares_id"
|
||||
class="tile tile-centered c-hand mb-1 p-1"
|
||||
:class="{'selected-element': selectedParam === param._id}"
|
||||
@click="selectParameter($event, param._id)"
|
||||
:class="{'selected-element': selectedParam === param._antares_id}"
|
||||
@click="selectParameter($event, param._antares_id)"
|
||||
>
|
||||
<div class="tile-icon">
|
||||
<div>
|
||||
|
@ -56,7 +56,7 @@
|
|||
<button
|
||||
class="btn btn-link remove-field p-0 mr-2"
|
||||
:title="$t('word.delete')"
|
||||
@click.prevent="removeParameter(param._id)"
|
||||
@click.prevent="removeParameter(param._antares_id)"
|
||||
>
|
||||
<i class="mdi mdi-close" />
|
||||
</button>
|
||||
|
@ -196,7 +196,7 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
selectedParamObj () {
|
||||
return this.parametersProxy.find(param => param._id === this.selectedParam);
|
||||
return this.parametersProxy.find(param => param._antares_id === this.selectedParam);
|
||||
},
|
||||
isChanged () {
|
||||
return JSON.stringify(this.localParameters) !== JSON.stringify(this.parametersProxy);
|
||||
|
@ -238,7 +238,7 @@ export default {
|
|||
},
|
||||
addParameter () {
|
||||
this.parametersProxy = [...this.parametersProxy, {
|
||||
_id: uidGen(),
|
||||
_antares_id: uidGen(),
|
||||
name: `param${this.i++}`,
|
||||
type: this.workspace.dataTypes[0].types[0].name,
|
||||
context: 'IN',
|
||||
|
@ -253,7 +253,7 @@ export default {
|
|||
}, 20);
|
||||
},
|
||||
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)
|
||||
this.resetSelectedID();
|
||||
|
@ -266,7 +266,7 @@ export default {
|
|||
this.resetSelectedID();
|
||||
},
|
||||
resetSelectedID () {
|
||||
this.selectedParam = this.parametersProxy.length ? this.parametersProxy[0]._id : '';
|
||||
this.selectedParam = this.parametersProxy.length ? this.parametersProxy[0]._antares_id : '';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -342,7 +342,7 @@ export default {
|
|||
field.default = `'${field.default}'`;
|
||||
}
|
||||
|
||||
return { ...field, _id: uidGen() };
|
||||
return { ...field, _antares_id: uidGen() };
|
||||
});
|
||||
this.localFields = JSON.parse(JSON.stringify(this.originalFields));
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ export default {
|
|||
|
||||
this.originalIndexes = Object.keys(indexesObj).map(index => {
|
||||
return {
|
||||
_id: uidGen(),
|
||||
_antares_id: uidGen(),
|
||||
name: index,
|
||||
fields: indexesObj[index].map(field => field.column),
|
||||
type: indexesObj[index][0].type,
|
||||
|
@ -391,7 +391,7 @@ export default {
|
|||
if (status === 'success') {
|
||||
this.originalKeyUsage = response.map(foreign => {
|
||||
return {
|
||||
_id: uidGen(),
|
||||
_antares_id: uidGen(),
|
||||
...foreign
|
||||
};
|
||||
});
|
||||
|
@ -411,25 +411,25 @@ export default {
|
|||
this.isSaving = true;
|
||||
|
||||
// FIELDS
|
||||
const originalIDs = this.originalFields.reduce((acc, curr) => [...acc, curr._id], []);
|
||||
const localIDs = this.localFields.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._antares_id], []);
|
||||
|
||||
// Fields Additions
|
||||
const additions = this.localFields.filter((field, i) => !originalIDs.includes(field._id)).map(field => {
|
||||
const lI = this.localFields.findIndex(localField => localField._id === field._id);
|
||||
const additions = this.localFields.filter((field, i) => !originalIDs.includes(field._antares_id)).map(field => {
|
||||
const lI = this.localFields.findIndex(localField => localField._antares_id === field._antares_id);
|
||||
const after = lI > 0 ? this.localFields[lI - 1].name : false;
|
||||
return { ...field, after };
|
||||
});
|
||||
|
||||
// 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
|
||||
const changes = [];
|
||||
this.originalFields.forEach((originalField, oI) => {
|
||||
const lI = this.localFields.findIndex(localField => localField._id === originalField._id);
|
||||
const originalSibling = oI > 0 ? this.originalFields[oI - 1]._id : false;
|
||||
const localSibling = lI > 0 ? this.localFields[lI - 1]._id : false;
|
||||
const lI = this.localFields.findIndex(localField => localField._antares_id === originalField._antares_id);
|
||||
const originalSibling = oI > 0 ? this.originalFields[oI - 1]._antares_id : false;
|
||||
const localSibling = lI > 0 ? this.localFields[lI - 1]._antares_id : false;
|
||||
const after = lI > 0 ? this.localFields[lI - 1].name : false;
|
||||
const orgName = originalField.name;
|
||||
|
||||
|
@ -450,15 +450,15 @@ export default {
|
|||
changes: [],
|
||||
deletions: []
|
||||
};
|
||||
const originalIndexIDs = this.originalIndexes.reduce((acc, curr) => [...acc, curr._id], []);
|
||||
const localIndexIDs = this.localIndexes.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._antares_id], []);
|
||||
|
||||
// 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
|
||||
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 (this.localIndexes[lI]) {
|
||||
indexChanges.changes.push({
|
||||
|
@ -471,7 +471,7 @@ export default {
|
|||
});
|
||||
|
||||
// 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
|
||||
const foreignChanges = {
|
||||
|
@ -479,15 +479,15 @@ export default {
|
|||
changes: [],
|
||||
deletions: []
|
||||
};
|
||||
const originalForeignIDs = this.originalKeyUsage.reduce((acc, curr) => [...acc, curr._id], []);
|
||||
const localForeignIDs = this.localKeyUsage.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._antares_id], []);
|
||||
|
||||
// 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
|
||||
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 (this.localKeyUsage[lI]) {
|
||||
foreignChanges.changes.push({
|
||||
|
@ -499,7 +499,7 @@ export default {
|
|||
});
|
||||
|
||||
// Foreigns Deletions
|
||||
foreignChanges.deletions = this.originalKeyUsage.filter(foreign => !localForeignIDs.includes(foreign._id));
|
||||
foreignChanges.deletions = this.originalKeyUsage.filter(foreign => !localForeignIDs.includes(foreign._antares_id));
|
||||
|
||||
// ALTER
|
||||
const params = {
|
||||
|
@ -555,7 +555,7 @@ export default {
|
|||
},
|
||||
addField () {
|
||||
this.localFields.push({
|
||||
_id: uidGen(),
|
||||
_antares_id: uidGen(),
|
||||
name: `${this.$tc('word.field', 1)}_${++this.newFieldsCounter}`,
|
||||
key: '',
|
||||
type: this.workspace.dataTypes[0].types[0].name,
|
||||
|
@ -597,8 +597,8 @@ export default {
|
|||
});
|
||||
},
|
||||
duplicateField (uid) {
|
||||
const fieldToClone = Object.assign({}, this.localFields.find(field => field._id === uid));
|
||||
fieldToClone._id = uidGen();
|
||||
const fieldToClone = Object.assign({}, this.localFields.find(field => field._antares_id === uid));
|
||||
fieldToClone._antares_id = uidGen();
|
||||
fieldToClone.name = `${fieldToClone.name}_copy`;
|
||||
fieldToClone.order = this.localFields.length + 1;
|
||||
this.localFields = [...this.localFields, fieldToClone];
|
||||
|
@ -609,11 +609,11 @@ export default {
|
|||
}, 20);
|
||||
},
|
||||
removeField (uid) {
|
||||
this.localFields = this.localFields.filter(field => field._id !== uid);
|
||||
this.localFields = this.localFields.filter(field => field._antares_id !== uid);
|
||||
},
|
||||
addNewIndex (payload) {
|
||||
this.localIndexes = [...this.localIndexes, {
|
||||
_id: uidGen(),
|
||||
_antares_id: uidGen(),
|
||||
name: payload.index === 'PRIMARY' ? 'PRIMARY' : payload.field,
|
||||
fields: [payload.field],
|
||||
type: payload.index,
|
||||
|
@ -625,7 +625,7 @@ export default {
|
|||
},
|
||||
addToIndex (payload) {
|
||||
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;
|
||||
});
|
||||
},
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
:key="index.name"
|
||||
class="context-element"
|
||||
: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>
|
||||
</div>
|
||||
|
|
|
@ -109,7 +109,7 @@
|
|||
>
|
||||
<TableRow
|
||||
v-for="row in fields"
|
||||
:key="row._id"
|
||||
:key="row._antares_id"
|
||||
:row="row"
|
||||
:indexes="getIndexes(row.name)"
|
||||
:foreigns="getForeigns(row.name)"
|
||||
|
@ -217,15 +217,15 @@ export default {
|
|||
this.resizeResults();
|
||||
},
|
||||
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.isContext = true;
|
||||
},
|
||||
duplicateField () {
|
||||
this.$emit('duplicate-field', this.selectedField._id);
|
||||
this.$emit('duplicate-field', this.selectedField._antares_id);
|
||||
},
|
||||
removeField () {
|
||||
this.$emit('remove-field', this.selectedField._id);
|
||||
this.$emit('remove-field', this.selectedField._antares_id);
|
||||
},
|
||||
getIndexes (field) {
|
||||
return this.indexes.reduce((acc, curr) => {
|
||||
|
|
|
@ -36,10 +36,10 @@
|
|||
<div ref="indexesPanel" class="panel-body p-0 pr-1">
|
||||
<div
|
||||
v-for="foreign in foreignProxy"
|
||||
:key="foreign._id"
|
||||
:key="foreign._antares_id"
|
||||
class="tile tile-centered c-hand mb-1 p-1"
|
||||
:class="{'selected-element': selectedForeignID === foreign._id}"
|
||||
@click="selectForeign($event, foreign._id)"
|
||||
:class="{'selected-element': selectedForeignID === foreign._antares_id}"
|
||||
@click="selectForeign($event, foreign._antares_id)"
|
||||
>
|
||||
<div class="tile-icon">
|
||||
<div>
|
||||
|
@ -68,7 +68,7 @@
|
|||
<button
|
||||
class="btn btn-link remove-field p-0 mr-2"
|
||||
:title="$t('word.delete')"
|
||||
@click.prevent="removeIndex(foreign._id)"
|
||||
@click.prevent="removeIndex(foreign._antares_id)"
|
||||
>
|
||||
<i class="mdi mdi-close" />
|
||||
</button>
|
||||
|
@ -238,7 +238,7 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
selectedForeignObj () {
|
||||
return this.foreignProxy.find(foreign => foreign._id === this.selectedForeignID);
|
||||
return this.foreignProxy.find(foreign => foreign._antares_id === this.selectedForeignID);
|
||||
},
|
||||
isChanged () {
|
||||
return JSON.stringify(this.localKeyUsage) !== JSON.stringify(this.foreignProxy);
|
||||
|
@ -288,7 +288,7 @@ export default {
|
|||
},
|
||||
addForeign () {
|
||||
this.foreignProxy = [...this.foreignProxy, {
|
||||
_id: uidGen(),
|
||||
_antares_id: uidGen(),
|
||||
constraintName: `FK_${this.foreignProxy.length + 1}`,
|
||||
refSchema: this.schema,
|
||||
table: this.table,
|
||||
|
@ -307,19 +307,19 @@ export default {
|
|||
}, 20);
|
||||
},
|
||||
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)
|
||||
this.resetSelectedID();
|
||||
},
|
||||
clearChanges () {
|
||||
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();
|
||||
},
|
||||
toggleField (field) {
|
||||
this.foreignProxy = this.foreignProxy.map(foreign => {
|
||||
if (foreign._id === this.selectedForeignID)
|
||||
if (foreign._antares_id === this.selectedForeignID)
|
||||
foreign.field = field;
|
||||
|
||||
return foreign;
|
||||
|
@ -327,14 +327,14 @@ export default {
|
|||
},
|
||||
toggleRefField (field) {
|
||||
this.foreignProxy = this.foreignProxy.map(foreign => {
|
||||
if (foreign._id === this.selectedForeignID)
|
||||
if (foreign._antares_id === this.selectedForeignID)
|
||||
foreign.refField = field;
|
||||
|
||||
return foreign;
|
||||
});
|
||||
},
|
||||
resetSelectedID () {
|
||||
this.selectedForeignID = this.foreignProxy.length ? this.foreignProxy[0]._id : '';
|
||||
this.selectedForeignID = this.foreignProxy.length ? this.foreignProxy[0]._antares_id : '';
|
||||
},
|
||||
async getRefFields () {
|
||||
if (!this.selectedForeignObj.refTable) return;
|
||||
|
|
|
@ -36,10 +36,10 @@
|
|||
<div ref="indexesPanel" class="panel-body p-0 pr-1">
|
||||
<div
|
||||
v-for="index in indexesProxy"
|
||||
:key="index._id"
|
||||
:key="index._antares_id"
|
||||
class="tile tile-centered c-hand mb-1 p-1"
|
||||
:class="{'selected-element': selectedIndexID === index._id}"
|
||||
@click="selectIndex($event, index._id)"
|
||||
:class="{'selected-element': selectedIndexID === index._antares_id}"
|
||||
@click="selectIndex($event, index._antares_id)"
|
||||
>
|
||||
<div class="tile-icon">
|
||||
<div>
|
||||
|
@ -56,7 +56,7 @@
|
|||
<button
|
||||
class="btn btn-link remove-field p-0 mr-2"
|
||||
:title="$t('word.delete')"
|
||||
@click.prevent="removeIndex(index._id)"
|
||||
@click.prevent="removeIndex(index._antares_id)"
|
||||
>
|
||||
<i class="mdi mdi-close" />
|
||||
</button>
|
||||
|
@ -163,7 +163,7 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
selectedIndexObj () {
|
||||
return this.indexesProxy.find(index => index._id === this.selectedIndexID);
|
||||
return this.indexesProxy.find(index => index._antares_id === this.selectedIndexID);
|
||||
},
|
||||
isChanged () {
|
||||
return JSON.stringify(this.localIndexes) !== JSON.stringify(this.indexesProxy);
|
||||
|
@ -200,7 +200,7 @@ export default {
|
|||
},
|
||||
addIndex () {
|
||||
this.indexesProxy = [...this.indexesProxy, {
|
||||
_id: uidGen(),
|
||||
_antares_id: uidGen(),
|
||||
name: 'NEW_INDEX',
|
||||
fields: [],
|
||||
type: 'INDEX',
|
||||
|
@ -218,19 +218,19 @@ export default {
|
|||
}, 20);
|
||||
},
|
||||
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)
|
||||
this.resetSelectedID();
|
||||
},
|
||||
clearChanges () {
|
||||
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();
|
||||
},
|
||||
toggleField (field) {
|
||||
this.indexesProxy = this.indexesProxy.map(index => {
|
||||
if (index._id === this.selectedIndexID) {
|
||||
if (index._antares_id === this.selectedIndexID) {
|
||||
if (index.fields.includes(field))
|
||||
index.fields = index.fields.filter(f => f !== field);
|
||||
else
|
||||
|
@ -240,7 +240,7 @@ export default {
|
|||
});
|
||||
},
|
||||
resetSelectedID () {
|
||||
this.selectedIndexID = this.indexesProxy.length ? this.indexesProxy[0]._id : '';
|
||||
this.selectedIndexID = this.indexesProxy.length ? this.indexesProxy[0]._antares_id : '';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<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="customizations.sortableFields ? 'row-draggable' : 'text-center'">
|
||||
<i v-if="customizations.sortableFields" class="mdi mdi-drag-horizontal row-draggable-icon" />
|
||||
|
|
|
@ -238,7 +238,7 @@ export default {
|
|||
this.originalFunction = response;
|
||||
|
||||
this.originalFunction.parameters = [...this.originalFunction.parameters.map(param => {
|
||||
param._id = uidGen();
|
||||
param._antares_id = uidGen();
|
||||
return param;
|
||||
})];
|
||||
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
<template>
|
||||
<div class="tr" @click="selectRow($event, row._id)">
|
||||
<div class="tr" @click="selectRow($event, row._antares_id)">
|
||||
<div
|
||||
v-for="(col, cKey) in row"
|
||||
v-show="cKey !== '_id'"
|
||||
v-show="cKey !== '_antares_id'"
|
||||
:key="cKey"
|
||||
class="td p-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
|
||||
v-if="!isInlineEditor[cKey] && fields[cKey]"
|
||||
class="cell-content"
|
||||
|
|
|
@ -142,7 +142,7 @@
|
|||
|
||||
code {
|
||||
background-color: #000;
|
||||
color: $body-font-color-dark;
|
||||
color: rgba($body-font-color-dark, 0.7);
|
||||
}
|
||||
|
||||
// Antares
|
||||
|
|
Loading…
Reference in New Issue