diff --git a/public/plugins/vue/tt-components/tt-position-manager.js b/public/plugins/vue/tt-components/tt-position-manager.js
index a42fcaf3b..d66e9a34e 100644
--- a/public/plugins/vue/tt-components/tt-position-manager.js
+++ b/public/plugins/vue/tt-components/tt-position-manager.js
@@ -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',
|
@@ -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;
},
|