fixed issue with cleartext tt-position-manager <-> tt-autocomplete

This commit is contained in:
Luca Haid
2025-03-06 11:38:41 +01:00
parent a729e77781
commit b1038e542d

View File

@@ -34,11 +34,11 @@ Vue.component('tt-positions-manager',
},
data() {
return {
window: window,
positions: this.value,
formData: {},
groupName: '',
selectedIndex: null,
window: window,
positions: this.value,
formData: {},
groupName: '',
selectedIndex: null,
}
},
template: `
@@ -62,8 +62,8 @@ Vue.component('tt-positions-manager',
:label="field.label"
:emit-display-value="field.emitDisplayValue || false"
v-model="formData[key]"
@input="delete formData[key + '_text']; $emit('updateField-' + key, $event)"
@displayValue="delete formData[key];formData[key + '_text'] = $event"
@input="$emit('updateField-' + key, $event)"
:ref="'autocomplete-' + key"
:api-url="window.TT_CONFIG['BASE_PATH'] + field.apiUrl"
sm
/>
@@ -121,7 +121,7 @@ Vue.component('tt-positions-manager',
<tr v-for="(position, index) in group" :key="groupMode ? groupName + index : index">
<td v-for="(field, key) in config.fields">
<tt-resolver
v-if="field.customFieldReference && position[key]"
v-if="field.customFieldReference && position[key]"
:reference="field.customFieldReference"
:value="position[key]"
/>
@@ -147,17 +147,24 @@ Vue.component('tt-positions-manager',
this.$set(this.formData, key, value);
},
defaultValidateForm(formData) {
console.log(this.config["validateFormOptions"], formData);
for (const field of this.config["validateFormOptions"]) {
if (!(formData[field.key] || formData[field.key + '_text'])) {
window.notify('error', field.message);
return false;
}
}
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() {
this.checkEmitDisplayValueAutocomplete();
if (this.config.hasOwnProperty('validateFormOptions') && !this.defaultValidateForm(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;
},
positionsToRender() {
return this.groupMode ? this.groupedPositions : { '': this.positions };
return this.groupMode ? this.groupedPositions : {'': this.positions};
},
allGroups() {
return Object.keys(this.groupedPositions);
}
},
watch: {
value: {
value: {
handler() {
this.positions = this.value;
},