mirror of https://github.com/Fabio286/antares.git
feat: aliases support
This commit is contained in:
parent
8390f8aa55
commit
264de9c568
|
@ -124,8 +124,15 @@ export default {
|
|||
};
|
||||
|
||||
const { status, response } = await Tables.getTableColumns(params);
|
||||
|
||||
if (status === 'success') {
|
||||
const fields = response.filter(field => this.selectedFields.includes(field.name));
|
||||
let fields = response.filter(field => this.selectedFields.includes(field.name));
|
||||
if (this.selectedFields.length) {
|
||||
fields = fields.map((field, index) => {
|
||||
return { ...field, alias: this.results.fields[index].name };
|
||||
});
|
||||
}
|
||||
|
||||
this.setTabFields({ cUid: this.connection.uid, tUid: this.tabUid, fields });
|
||||
}
|
||||
else
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
class="tr"
|
||||
:class="{'selected': selectedRows.includes(row._id)}"
|
||||
@select-row="selectRow($event, row._id)"
|
||||
@update-field="updateField($event, row[primaryField.name])"
|
||||
@update-field="updateField($event, row[primaryField.alias || primaryField.name])"
|
||||
@contextmenu="contextMenu"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -7,15 +7,14 @@
|
|||
class="td p-0"
|
||||
tabindex="0"
|
||||
@contextmenu.prevent="$emit('contextmenu', $event, {id: row._id, field: cKey})"
|
||||
@update-field="updateField($event, row[primaryField.name])"
|
||||
>
|
||||
<template v-if="cKey !== '_id'">
|
||||
<span
|
||||
v-if="!isInlineEditor[cKey]"
|
||||
class="cell-content px-2"
|
||||
:class="`${isNull(col)} type-${fieldType(cKey)}`"
|
||||
:class="`${isNull(col)} type-${getFieldType(cKey)}`"
|
||||
@dblclick="editON($event, col, cKey)"
|
||||
>{{ col | typeFormat(fieldType(cKey), fieldPrecision(cKey)) | cutText }}</span>
|
||||
>{{ col | typeFormat(getFieldType(cKey), getFieldPrecision(cKey)) | cutText }}</span>
|
||||
<ForeignKeySelect
|
||||
v-else-if="foreignKeys.includes(cKey)"
|
||||
class="editable-field"
|
||||
|
@ -218,7 +217,7 @@ export default {
|
|||
|
||||
if (TIME.includes(this.editingType)) {
|
||||
let timeMask = '##:##:##';
|
||||
const precision = this.fieldPrecision(this.editingField);
|
||||
const precision = this.getFieldPrecision(this.editingField);
|
||||
|
||||
for (let i = 0; i < precision; i++)
|
||||
timeMask += i === 0 ? '.#' : '#';
|
||||
|
@ -231,7 +230,7 @@ export default {
|
|||
|
||||
if (DATETIME.includes(this.editingType)) {
|
||||
let datetimeMask = '####-##-## ##:##:##';
|
||||
const precision = this.fieldPrecision(this.editingField);
|
||||
const precision = this.getFieldPrecision(this.editingField);
|
||||
|
||||
for (let i = 0; i < precision; i++)
|
||||
datetimeMask += i === 0 ? '.#' : '#';
|
||||
|
@ -260,22 +259,25 @@ export default {
|
|||
});
|
||||
},
|
||||
methods: {
|
||||
fieldType (cKey) {
|
||||
getFieldType (cKey) {
|
||||
let type = 'unknown';
|
||||
const field = this.fields.filter(field => field.name === cKey)[0];
|
||||
const field = this.getFieldObj(cKey);
|
||||
if (field)
|
||||
type = field.type;
|
||||
|
||||
return type;
|
||||
},
|
||||
fieldPrecision (cKey) {
|
||||
getFieldPrecision (cKey) {
|
||||
let length = 0;
|
||||
const field = this.fields.filter(field => field.name === cKey)[0];
|
||||
const field = this.getFieldObj(cKey);
|
||||
if (field)
|
||||
length = field.datePrecision;
|
||||
|
||||
return length;
|
||||
},
|
||||
getFieldObj (cKey) {
|
||||
return this.fields.filter(field => field.name === cKey || field.alias === cKey)[0];
|
||||
},
|
||||
isNull (value) {
|
||||
return value === null ? ' is-null' : '';
|
||||
},
|
||||
|
@ -283,7 +285,7 @@ export default {
|
|||
return bufferToBase64(val);
|
||||
},
|
||||
editON (event, content, field) {
|
||||
const type = this.fieldType(field);
|
||||
const type = this.getFieldType(field);
|
||||
this.originalContent = content;
|
||||
this.editingType = type;
|
||||
this.editingField = field;
|
||||
|
@ -316,7 +318,7 @@ export default {
|
|||
}
|
||||
|
||||
// Inline editable fields
|
||||
this.editingContent = this.$options.filters.typeFormat(this.originalContent, type, this.fieldPrecision(field));
|
||||
this.editingContent = this.$options.filters.typeFormat(this.originalContent, type, this.getFieldPrecision(field));
|
||||
this.$nextTick(() => { // Focus on input
|
||||
event.target.blur();
|
||||
|
||||
|
@ -347,7 +349,7 @@ export default {
|
|||
}
|
||||
|
||||
this.$emit('update-field', {
|
||||
field: this.editingField,
|
||||
field: this.getFieldObj(this.editingField).name,
|
||||
type: this.editingType,
|
||||
content
|
||||
});
|
||||
|
@ -385,9 +387,6 @@ export default {
|
|||
};
|
||||
this.willBeDeleted = true;
|
||||
},
|
||||
updateField (event, id) {
|
||||
this.$emit('update-field', event, id);
|
||||
},
|
||||
contextMenu (event, cell) {
|
||||
this.$emit('update-field', event, cell);
|
||||
},
|
||||
|
|
|
@ -133,12 +133,12 @@ body {
|
|||
}
|
||||
|
||||
.form-select,
|
||||
.form-select:not([multiple]):not([size]),
|
||||
.form-input,
|
||||
.form-select:not([multiple]):not([size]),
|
||||
.form-checkbox .form-icon,
|
||||
.form-radio .form-icon {
|
||||
border-color: $bg-color-light;
|
||||
background: $bg-color-gray;
|
||||
background-color: $bg-color-gray;
|
||||
}
|
||||
|
||||
.form-input:not(:placeholder-shown):invalid:focus {
|
||||
|
|
Loading…
Reference in New Issue