Skip to content

Commit 4b5a827

Browse files
committed
MAGETWO-34253: CLONE - Postal code is still mandatory for Non-US addresses that don't use it
- Partial fix
1 parent 43ad113 commit 4b5a827

File tree

6 files changed

+97
-4
lines changed

6 files changed

+97
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
</constraints>
4949
</field>
5050
<field name="region" source="eav" formElement="input" visible="false"/>
51-
<field name="postcode" source="eav">
51+
<field name="postcode" source="eav" dataType="post_code_fix">
5252
<constraints>
5353
<validate name="required-entry"/>
5454
</constraints>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Ui\Component\Form\Element\DataType;
7+
8+
/**
9+
* Class Number
10+
*/
11+
class PostCodeFix extends AbstractDataType
12+
{
13+
//
14+
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,12 @@
234234
</argument>
235235
</arguments>
236236
</block>
237+
238+
<block class="Magento\Ui\Component\Form\Element\DataType\PostCodeFix" name="post_code_fix">
239+
<arguments>
240+
<argument name="js_config" xsi:type="array">
241+
<item name="component" xsi:type="string">Magento_Ui/js/form/element/post-code-fix</item>
242+
</argument>
243+
</arguments>
244+
</block>
237245
</layout>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Copyright © 2015 Magento. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
define([], function () {
6+
'use strict';
7+
8+
var postCodeName = 'customer_form.groups.customer_addressCollection.new_0.postcode.0',
9+
countryName = 'customer_form.groups.customer_addressCollection.new_0.country_id.0';
10+
return {
11+
//'initProperties': function () {
12+
// this._super();
13+
// return this;
14+
//},
15+
'initListeners': function () {
16+
this._super();
17+
18+
if (this.name === countryName) {
19+
var options = this.options;
20+
this.value.subscribe(function (newValue) {
21+
var option = _.filter(options(), function (op) {
22+
return op.value === newValue;
23+
});
24+
console.log(newValue);
25+
console.log(option);
26+
});
27+
}
28+
29+
return this;
30+
}
31+
};
32+
});

app/code/Magento/Ui/view/base/web/js/form/element/abstract.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ define([
66
'underscore',
77
'mage/utils',
88
'Magento_Ui/js/form/component',
9-
'Magento_Ui/js/lib/validation/validator'
10-
], function (_, utils, Component, validator) {
9+
'Magento_Ui/js/lib/validation/validator',
10+
'Magento_Ui/js/form/components/posCodeFix'
11+
], function (_, utils, Component, validator, posCodeFix) {
1112
'use strict';
1213

1314
/**
@@ -261,5 +262,6 @@ define([
261262

262263
this.validate();
263264
}
264-
});
265+
})
266+
.extend(posCodeFix);
265267
});
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Copyright © 2015 Magento. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
define([
6+
'./abstract'
7+
], function (Abstract) {
8+
'use strict';
9+
10+
return Abstract.extend({
11+
/**
12+
* Converts the result of parent 'getInitialValue' call to boolean
13+
*
14+
* @return {Boolean}
15+
*/
16+
getInititalValue: function(){
17+
debugger;
18+
return this._super();
19+
},
20+
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();
29+
30+
if (this.hasUnique) {
31+
this.setUnique();
32+
}
33+
34+
return this;
35+
}
36+
});
37+
});

0 commit comments

Comments
 (0)