Skip to content

Commit a49169e

Browse files
authored
Merge pull request #446 from magento-troll/MAGETWO-55838
MAGETWO-55838: [Add address] Same address can be added several times at once
2 parents f39ad29 + 40224b8 commit a49169e

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

app/code/Magento/Customer/view/frontend/requirejs-config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ var config = {
1010
address: 'Magento_Customer/address',
1111
changeEmailPassword: 'Magento_Customer/change-email-password',
1212
passwordStrengthIndicator: 'Magento_Customer/js/password-strength-indicator',
13-
zxcvbn: 'Magento_Customer/js/zxcvbn'
13+
zxcvbn: 'Magento_Customer/js/zxcvbn',
14+
addressValidation: 'Magento_Customer/js/addressValidation'
1415
}
1516
}
1617
};

app/code/Magento/Customer/view/frontend/templates/address/edit.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
<script type="text/x-magento-init">
204204
{
205205
"#form-validate": {
206-
"validation": {}
206+
"addressValidation": {}
207207
},
208208
"#country": {
209209
"regionUpdater": {
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* Copyright © 2016 Magento. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
/*jshint browser:true jquery:true*/
6+
define([
7+
'jquery',
8+
'jquery/ui',
9+
'validation'
10+
], function ($) {
11+
'use strict';
12+
13+
$.widget('mage.addressValidation', {
14+
options: {
15+
selectors: {
16+
button: '[data-action=save-address]'
17+
}
18+
},
19+
20+
/**
21+
* Validation creation
22+
* @protected
23+
*/
24+
_create: function () {
25+
var button = $(this.options.selectors.button, this.element);
26+
27+
this.element.validation({
28+
29+
/**
30+
* Submit Handler
31+
* @param {Element} form - address form
32+
*/
33+
submitHandler: function (form) {
34+
35+
button.attr('disabled', true);
36+
form.submit();
37+
}
38+
});
39+
}
40+
});
41+
42+
return $.mage.addressValidation;
43+
});

0 commit comments

Comments
 (0)