From 76a4b24aa182809a0103fa7af54d95e4602f32e0 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 12 Aug 2021 15:39:18 +0200 Subject: [PATCH] improve vue Address options (to be checked in all context) --- .../vuejs/Address/components/AddAddress.vue | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue index e6c3085a7..13d3cc150 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue @@ -205,25 +205,38 @@ export default { return step2; }, getTextTitle() { - if (this.options.title && (this.options.title.edit !== null || this.options.title.create !== null)) { + if ( typeof this.options.title !== 'undefined' + && ( this.options.title.edit !== null + || this.options.title.create !== null + )) { return (this.context.edit) ? this.options.title.edit : this.options.title.create; } return (this.context.edit) ? this.$t(this.default.title.edit) : this.$t(this.default.title.create); }, getTextButton() { - if (this.options.button && this.options.button.text && (this.options.button.text.edit !== null || this.options.button.text.create !== null)) { + if ( typeof this.options.button.text !== 'undefined' + && ( this.options.button.text.edit !== null + || this.options.button.text.create !== null + )) { return (this.context.edit) ? this.options.button.text.edit : this.options.button.text.create; } return (this.context.edit) ? this.default.button.text.edit : this.default.button.text.create; }, getClassButton() { - let size = (this.options.button && this.options.button.size !== null) ? this.options.button.size : ''; - let type = (this.options.button && this.options.button.type !== null) ? this.options.button.type : this.default.button.type; - return size ? size + ' ' + type : type; + let type = this.default.button.type, + size = ''; + if (typeof this.options.button !== 'undefined') { + type = typeof this.options.button.type !== 'undefined' ? this.options.button.type : type; + size = typeof this.options.button.size !== 'undefined' ? this.options.button.size : size; + } + return size ? `${size} ${type}` : type; }, displayTextButton() { - return (this.options.button !== null && typeof this.options.button.display !== 'undefined') ? + return (typeof this.options.button !== 'undefined' && typeof this.options.button.display !== 'undefined') ? this.options.button.display : this.default.button.display; + }, + context() { + return this.context; } }, mounted() { @@ -462,6 +475,7 @@ export default { // TODO change the condition because it writes new postal code in edit mode now: !writeNewPostalCode this.flag.loading = true; if ('newPostcode' in payload.newAddress) { + let postcodeBody = payload.newAddress.newPostcode; postcodeBody = Object.assign(postcodeBody, {'origin': 3});