Skip to content

Commit 85f7664

Browse files
committed
MAGETWO-34253: CLONE - Postal code is still mandatory for Non-US addresses that don't use it
- Added component post-code-fix that contain logic with uniting {country_id} and {postcode}
1 parent 4b5a827 commit 85f7664

File tree

4 files changed

+24
-49
lines changed

4 files changed

+24
-49
lines changed

app/code/Magento/Customer/etc/data_source/customer_address.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@
4848
</constraints>
4949
</field>
5050
<field name="region" source="eav" formElement="input" visible="false"/>
51-
<field name="postcode" source="eav" dataType="post_code_fix">
51+
52+
<field name="postcode" source="eav" formElement="post_code_fix" >
5253
<constraints>
5354
<validate name="required-entry"/>
5455
</constraints>
5556
</field>
57+
5658
<field name="telephone" source="eav" label="Phone Number">
5759
<constraints>
5860
<validate name="required-entry"/>

app/code/Magento/Ui/view/base/layout/ui_components.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@
239239
<arguments>
240240
<argument name="js_config" xsi:type="array">
241241
<item name="component" xsi:type="string">Magento_Ui/js/form/element/post-code-fix</item>
242+
<item name="dependentFiled" xsi:type="string">country_id</item>
242243
</argument>
243244
</arguments>
244245
</block>

app/code/Magento/Ui/view/base/web/js/form/components/posCodeFix.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

app/code/Magento/Ui/view/base/web/js/form/element/post-code-fix.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
* See COPYING.txt for license details.
44
*/
55
define([
6+
'Magento_Ui/js/lib/registry/registry',
67
'./abstract'
7-
], function (Abstract) {
8+
], function (registry, Abstract) {
89
'use strict';
910

1011
return Abstract.extend({
@@ -13,25 +14,28 @@ define([
1314
*
1415
* @return {Boolean}
1516
*/
16-
getInititalValue: function(){
17-
debugger;
18-
return this._super();
17+
initListeners: function(){
18+
this._super();
19+
this.provider.data.on('update:'+this.parentScope+'.country_id', this.update.bind(this));
20+
return this;
1921
},
2022

21-
/**
22-
* Calls 'store' method of parent, if value is defined and instance's
23-
* 'unique' property set to true, calls 'setUnique' method
24-
*
25-
* @return {Object} - reference to instance
26-
*/
27-
store: function() {
28-
this._super();
23+
update: function(value){
24+
var parentScope = this.getPart(this.getPart(this.name, -2), -2),
25+
component = registry.get(parentScope + '.country_id.0'),
26+
element;
2927

30-
if (this.hasUnique) {
31-
this.setUnique();
32-
}
28+
component
29+
.options()
30+
.some(function (el, idx) {
31+
element = el;
32+
return el.value === value;
33+
});
3334

34-
return this;
35+
if(!element.is_region_required) {
36+
this.error(false);
37+
}
38+
this.required(!!element.is_region_required);
3539
}
3640
});
3741
});

0 commit comments

Comments
 (0)