@@ -79,7 +79,7 @@ script;
79
79
$ scriptString .= 'this.regionsUrl = " ' . $ block ->escapeJs ($ block ->getUrl ('directory/json/countryRegion ' )) . '"; ' ;
80
80
$ countryFilter = $ block ->getData ('countryFilter ' );
81
81
$ euCountries = $ countryFilter ->getEuCountryList ();
82
- $ scriptString .= 'this.euCountryList = ' . json_encode ($ euCountries );
82
+ $ scriptString .= 'this.euCountryList = Object.values( ' . json_encode ($ euCountries ) . ' ); ' ;
83
83
84
84
$ scriptString .= <<<script
85
85
@@ -101,7 +101,6 @@ $scriptString .= <<<script
101
101
},
102
102
reloadVatNumberField : function(event)
103
103
{
104
- this.reload = true;
105
104
var countryElement = Event.element(event);
106
105
if (countryElement && countryElement.id) {
107
106
this.refreshVatNumberField(countryElement);
@@ -132,26 +131,21 @@ $scriptString .= <<<script
132
131
if (btnVatNumberElement) {
133
132
this.btnVatNumberElement = btnVatNumberElement;
134
133
if (countryElement.value.length) {
135
- this.btnValidateVatNumber (countryElement.value);
134
+ this.renderValidateVatNumberButton (countryElement.value);
136
135
}
137
136
}
138
137
},
139
- btnValidateVatNumber : function(countryCode)
138
+ renderValidateVatNumberButton : function(countryCode)
140
139
{
141
140
var resultElement = document.getElementById("validation_result");
142
- var isEuCountry = false;
143
- const fruits = Object.values(this.euCountryList);
144
-
145
- if ( fruits.includes(countryCode)) {
146
- isEuCountry = true;
147
- }
148
- if (isEuCountry) {
141
+ if (this.euCountryList.includes(countryCode)) {
149
142
this.btnVatNumberElement.classList.remove('disabled');
150
143
if (resultElement) {
151
144
resultElement.style.display = "block";
152
145
resultElement.innerHTML = '';
153
- if ( resultElement.classList.contains('admin__field-error') )
154
- resultElement.classList.remove('admin__field-error');
146
+ if (resultElement.classList.contains('admin__field-error')) {
147
+ resultElement.classList.remove('admin__field-error');
148
+ }
155
149
}
156
150
} else {
157
151
this.btnVatNumberElement.classList.add('disabled');
0 commit comments