fixed issue with cleartext tt-position-manager <-> tt-autocomplete
This commit is contained in:
@@ -34,11 +34,11 @@ Vue.component('tt-positions-manager',
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
window: window,
|
window: window,
|
||||||
positions: this.value,
|
positions: this.value,
|
||||||
formData: {},
|
formData: {},
|
||||||
groupName: '',
|
groupName: '',
|
||||||
selectedIndex: null,
|
selectedIndex: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
template: `
|
template: `
|
||||||
@@ -62,8 +62,8 @@ Vue.component('tt-positions-manager',
|
|||||||
:label="field.label"
|
:label="field.label"
|
||||||
:emit-display-value="field.emitDisplayValue || false"
|
:emit-display-value="field.emitDisplayValue || false"
|
||||||
v-model="formData[key]"
|
v-model="formData[key]"
|
||||||
@input="delete formData[key + '_text']; $emit('updateField-' + key, $event)"
|
@input="$emit('updateField-' + key, $event)"
|
||||||
@displayValue="delete formData[key];formData[key + '_text'] = $event"
|
:ref="'autocomplete-' + key"
|
||||||
:api-url="window.TT_CONFIG['BASE_PATH'] + field.apiUrl"
|
:api-url="window.TT_CONFIG['BASE_PATH'] + field.apiUrl"
|
||||||
sm
|
sm
|
||||||
/>
|
/>
|
||||||
@@ -121,7 +121,7 @@ Vue.component('tt-positions-manager',
|
|||||||
<tr v-for="(position, index) in group" :key="groupMode ? groupName + index : index">
|
<tr v-for="(position, index) in group" :key="groupMode ? groupName + index : index">
|
||||||
<td v-for="(field, key) in config.fields">
|
<td v-for="(field, key) in config.fields">
|
||||||
<tt-resolver
|
<tt-resolver
|
||||||
v-if="field.customFieldReference && position[key]"
|
v-if="field.customFieldReference && position[key]"
|
||||||
:reference="field.customFieldReference"
|
:reference="field.customFieldReference"
|
||||||
:value="position[key]"
|
:value="position[key]"
|
||||||
/>
|
/>
|
||||||
@@ -147,17 +147,24 @@ Vue.component('tt-positions-manager',
|
|||||||
this.$set(this.formData, key, value);
|
this.$set(this.formData, key, value);
|
||||||
},
|
},
|
||||||
defaultValidateForm(formData) {
|
defaultValidateForm(formData) {
|
||||||
console.log(this.config["validateFormOptions"], formData);
|
|
||||||
for (const field of this.config["validateFormOptions"]) {
|
for (const field of this.config["validateFormOptions"]) {
|
||||||
if (!(formData[field.key] || formData[field.key + '_text'])) {
|
if (!(formData[field.key] || formData[field.key + '_text'])) {
|
||||||
window.notify('error', field.message);
|
window.notify('error', field.message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
checkEmitDisplayValueAutocomplete() {
|
||||||
|
for (const [key, field] of Object.entries(this.config.fields)) {
|
||||||
|
if (field.type === 'autocomplete' && field.emitDisplayValue && isNaN(this.formData[key])) {
|
||||||
|
this.$set(this.formData, key + '_text', this.$refs['autocomplete-' + key][0].displayValue);
|
||||||
|
this.$delete(this.formData, key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
async saveEntry() {
|
async saveEntry() {
|
||||||
|
this.checkEmitDisplayValueAutocomplete();
|
||||||
if (this.config.hasOwnProperty('validateFormOptions') && !this.defaultValidateForm(this.formData)) return;
|
if (this.config.hasOwnProperty('validateFormOptions') && !this.defaultValidateForm(this.formData)) return;
|
||||||
else if (this.config.validateForm && !await this.config.validateForm(this.formData)) return;
|
else if (this.config.validateForm && !await this.config.validateForm(this.formData)) return;
|
||||||
|
|
||||||
@@ -216,14 +223,14 @@ Vue.component('tt-positions-manager',
|
|||||||
return groups;
|
return groups;
|
||||||
},
|
},
|
||||||
positionsToRender() {
|
positionsToRender() {
|
||||||
return this.groupMode ? this.groupedPositions : { '': this.positions };
|
return this.groupMode ? this.groupedPositions : {'': this.positions};
|
||||||
},
|
},
|
||||||
allGroups() {
|
allGroups() {
|
||||||
return Object.keys(this.groupedPositions);
|
return Object.keys(this.groupedPositions);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
value: {
|
value: {
|
||||||
handler() {
|
handler() {
|
||||||
this.positions = this.value;
|
this.positions = this.value;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user