Skip to content

Commit

Permalink
feat: Update displayed value when edit option translation before save…
Browse files Browse the repository at this point in the history
… changes - MEED-8055 - Meeds-io/MIPs#171 (#4330)

Update displayed value when edit option translation before save changes
  • Loading branch information
hakermi committed Jan 20, 2025
1 parent fb53bfe commit eb927d5
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export default {
userLocale: eXo.env.portal.language,
objectType: 'propertySettingOption',
fieldName: 'optionValue',
defaultLangValue: null
defaultLangValue: null,
optionObject: null
};
},
props: {
Expand All @@ -72,14 +73,23 @@ export default {
},
computed: {
displayedValue() {
return this.option?.translations?.[this.userLocale] || this.defaultLangValue
|| this.option.value;
return this.optionObject?.translations?.[this.userLocale] || this.defaultLangValue
|| this.optionObject.value;
}
},
created() {
this.getSavedTranslations();
this.cloneOptionObject();
},
watch: {
option() {
this.cloneOptionObject();
}
},
methods: {
cloneOptionObject() {
this.optionObject = structuredClone(this.option);
},
getSavedTranslations() {
if (this.option?.id) {
this.$translationService.getTranslations(this.objectType, this.option.id, this.fieldName).then(translations => {
Expand All @@ -88,6 +98,7 @@ export default {
}
},
translationUpdated(translations) {
this.optionObject = {...this.optionObject, translations};
this.$emit('translation-updated', this.option, translations);
},
updateFieldValue(value) {
Expand Down

0 comments on commit eb927d5

Please sign in to comment.