-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from magento-vanilla/PR
[Vanilla] Bugs
- Loading branch information
Showing
12 changed files
with
129 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
app/code/Magento/Ui/view/base/web/js/form/element/post-code.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
define([ | ||
'underscore', | ||
'Magento_Ui/js/lib/registry/registry', | ||
'./abstract' | ||
], function (_, registry, Abstract) { | ||
'use strict'; | ||
|
||
return Abstract.extend({ | ||
/** | ||
* Extended list of Listeners | ||
* | ||
* @return {this} | ||
*/ | ||
initListeners: function () { | ||
this._super() | ||
.update() | ||
.provider.data.on('update:' + this.parentScope + '.country_id', this.update.bind(this)); | ||
|
||
return this; | ||
}, | ||
|
||
/** | ||
* Fix _postcode_ depend on _country_id_ change: | ||
* - If country in list "Zip/Postal Code is Optional countries" then | ||
* - field "postcode" should not be required | ||
* | ||
* @returns {this} | ||
*/ | ||
update: function () { | ||
var parentScope = this.getPart(this.getPart(this.name, -2), -2), | ||
option, | ||
postcode = this; | ||
|
||
registry.get(parentScope + '.country_id.0', function (countryComponent) { | ||
var value = countryComponent.value(); | ||
|
||
if (!value) { // empty value discard logic | ||
return; | ||
} | ||
|
||
countryComponent | ||
.options() | ||
.some(function (el) { | ||
option = el; | ||
|
||
return el.value === value; | ||
}); | ||
|
||
if (!option.is_region_required) { | ||
postcode.error(false); | ||
postcode.validation = _.omit(postcode.validation, 'required-entry'); | ||
} else { | ||
postcode.validation['required-entry'] = true; | ||
} | ||
postcode.required(!!option.is_region_required); | ||
}); | ||
|
||
return this; | ||
} | ||
}); | ||
}); |