From 19d58c3368babd2089202765e5e16631d5cd6e57 Mon Sep 17 00:00:00 2001 From: PaulWijnberg Date: Wed, 22 Mar 2023 00:04:28 +0100 Subject: [PATCH] Issue: #77 Check in Javascript if childHouseNumberSelect and this.settings are defined --- .../web/js/form/components/address-autofill-nl.js | 5 ++++- .../web/js/form/element/address-autofill-field.js | 8 +++++--- .../web/js/form/element/address-autofill-intl.js | 14 ++++++++------ .../web/js/form/element/house-number-select.js | 14 ++++++++------ 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/view/frontend/web/js/form/components/address-autofill-nl.js b/view/frontend/web/js/form/components/address-autofill-nl.js index 50fc3a5..02d6288 100644 --- a/view/frontend/web/js/form/components/address-autofill-nl.js +++ b/view/frontend/web/js/form/components/address-autofill-nl.js @@ -168,7 +168,10 @@ define([ }, resetHouseNumberSelect: function () { - this.childHouseNumberSelect().setOptions([]).hide(); + const childHouseNumberSelect = this.childHouseNumberSelect(); + if(childHouseNumberSelect){ + childHouseNumberSelect.setOptions([]).hide(); + } }, getAddressParts: function (address) { diff --git a/view/frontend/web/js/form/element/address-autofill-field.js b/view/frontend/web/js/form/element/address-autofill-field.js index 95ad5a8..93ce4e1 100644 --- a/view/frontend/web/js/form/element/address-autofill-field.js +++ b/view/frontend/web/js/form/element/address-autofill-field.js @@ -14,9 +14,11 @@ define([ initialize: function () { this._super(); - if (this.settings.show_hide_address_fields !== 'show') { - this.validation['required-entry'] = true; - this.required(true); + if(this.settings) { + if (this.settings.show_hide_address_fields !== 'show') { + this.validation['required-entry'] = true; + this.required(true); + } } return this; diff --git a/view/frontend/web/js/form/element/address-autofill-intl.js b/view/frontend/web/js/form/element/address-autofill-intl.js index 7f07421..ea89152 100644 --- a/view/frontend/web/js/form/element/address-autofill-intl.js +++ b/view/frontend/web/js/form/element/address-autofill-intl.js @@ -15,12 +15,14 @@ define([ initialize: function (config) { this._super(); - if (this.settings.show_hide_address_fields !== 'show') { - this.validation['validate-callback'] = { - message: $t('Please enter an address and select it.'), - isValid: this.isValid.bind(this), - }; - this.required(true); + if (this.settings){ + if (this.settings.show_hide_address_fields !== 'show') { + this.validation['validate-callback'] = { + message: $t('Please enter an address and select it.'), + isValid: this.isValid.bind(this), + }; + this.required(true); + } } this.additionalClasses['loading'] = this.loading; diff --git a/view/frontend/web/js/form/element/house-number-select.js b/view/frontend/web/js/form/element/house-number-select.js index d17cb63..d50594b 100644 --- a/view/frontend/web/js/form/element/house-number-select.js +++ b/view/frontend/web/js/form/element/house-number-select.js @@ -15,12 +15,14 @@ define([ initialize: function () { this._super(); - if (this.settings.show_hide_address_fields !== 'show') { - this.validation['validate-callback'] = { - message: $t('Please select a house number.'), - isValid: this.isValid.bind(this), - }; - this.required(true); + if (this.settings){ + if (this.settings.show_hide_address_fields !== 'show') { + this.validation['validate-callback'] = { + message: $t('Please select a house number.'), + isValid: this.isValid.bind(this), + }; + this.required(true); + } } return this;