Skip to content

Commit 0619d9e

Browse files
committed
Merge branch 'develop' of github.com:magento/magento2ce into develop-prs
2 parents 7fdf23a + c98f85d commit 0619d9e

File tree

2 files changed

+56
-8
lines changed

2 files changed

+56
-8
lines changed

app/code/Magento/Checkout/view/frontend/web/js/checkout-data.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,29 @@ define([
259259

260260
obj.inputFieldEmailValue = email;
261261
saveData(obj);
262+
},
263+
264+
/**
265+
* Pulling the checked email value from persistence storage
266+
*
267+
* @return {*}
268+
*/
269+
getCheckedEmailValue: function () {
270+
var obj = getData();
271+
272+
return obj.checkedEmailValue ? obj.checkedEmailValue : '';
273+
},
274+
275+
/**
276+
* Setting the checked email value pulled from persistence storage
277+
*
278+
* @param {String} email
279+
*/
280+
setCheckedEmailValue: function (email) {
281+
var obj = getData();
282+
283+
obj.checkedEmailValue = email;
284+
saveData(obj);
262285
}
263286
};
264287
});

app/code/Magento/Checkout/view/frontend/web/js/view/form/element/email.js

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,19 @@ define([
4242
forgotPasswordUrl: window.checkoutConfig.forgotPasswordUrl,
4343
emailCheckTimeout: 0,
4444

45+
/**
46+
* Initializes regular properties of instance.
47+
*
48+
* @returns {Object} Chainable.
49+
*/
50+
initConfig: function () {
51+
this._super();
52+
53+
this.isPasswordVisible = this.resolveInitialPasswordVisibility();
54+
55+
return this;
56+
},
57+
4558
/**
4659
* Initializes observable properties of instance
4760
*
@@ -81,20 +94,19 @@ define([
8194
* Check email existing.
8295
*/
8396
checkEmailAvailability: function () {
84-
var self = this;
85-
8697
this.validateRequest();
8798
this.isEmailCheckComplete = $.Deferred();
8899
this.isLoading(true);
89100
this.checkRequest = checkEmailAvailability(this.isEmailCheckComplete, this.email());
90101

91102
$.when(this.isEmailCheckComplete).done(function () {
92-
self.isPasswordVisible(false);
93-
}).fail(function () {
94-
self.isPasswordVisible(true);
95-
}).always(function () {
96-
self.isLoading(false);
97-
});
103+
this.isPasswordVisible(false);
104+
}.bind(this)).fail(function () {
105+
this.isPasswordVisible(true);
106+
checkoutData.setCheckedEmailValue(this.email());
107+
}.bind(this)).always(function () {
108+
this.isLoading(false);
109+
}.bind(this));
98110
},
99111

100112
/**
@@ -153,6 +165,19 @@ define([
153165
fullScreenLoader.stopLoader();
154166
});
155167
}
168+
},
169+
170+
/**
171+
* Resolves an initial sate of a login form.
172+
*
173+
* @returns {Boolean} - initial visibility state.
174+
*/
175+
resolveInitialPasswordVisibility: function () {
176+
if (checkoutData.getInputFieldEmailValue() !== '') {
177+
return checkoutData.getInputFieldEmailValue() === checkoutData.getCheckedEmailValue();
178+
}
179+
180+
return false;
156181
}
157182
});
158183
});

0 commit comments

Comments
 (0)