Skip to content

Commit 9d9b422

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-59856' into PR-2.2
2 parents a8cd746 + f999af4 commit 9d9b422

File tree

6 files changed

+45
-38
lines changed

6 files changed

+45
-38
lines changed

app/code/Magento/Checkout/view/frontend/web/js/model/full-screen-loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ define([
2424
/**
2525
* Stop full page loader action
2626
*
27-
* @param {Boolean} forceStop
27+
* @param {Boolean} [forceStop]
2828
*/
2929
stopLoader: function (forceStop) {
3030
var $elem = $(containerId),

app/code/Magento/SalesRule/view/frontend/web/js/action/cancel-coupon.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,20 @@ define(
1717
'mage/storage',
1818
'Magento_Checkout/js/action/get-payment-information',
1919
'Magento_Checkout/js/model/totals',
20-
'mage/translate'
20+
'mage/translate',
21+
'Magento_Checkout/js/model/full-screen-loader'
2122
],
22-
function ($, quote, urlManager, errorProcessor, messageContainer, storage, getPaymentInformationAction, totals, $t) {
23+
function ($, quote, urlManager, errorProcessor, messageContainer, storage, getPaymentInformationAction, totals, $t,
24+
fullScreenLoader) {
2325
'use strict';
2426

25-
return function (isApplied, isLoading) {
27+
return function (isApplied) {
2628
var quoteId = quote.getQuoteId(),
2729
url = urlManager.getCancelCouponUrl(quoteId),
2830
message = $t('Your coupon was successfully removed.');
31+
2932
messageContainer.clear();
33+
fullScreenLoader.startLoader();
3034

3135
return storage.delete(
3236
url,
@@ -39,6 +43,7 @@ define(
3943
$.when(deferred).done(function () {
4044
isApplied(false);
4145
totals.isLoading(false);
46+
fullScreenLoader.stopLoader();
4247
});
4348
messageContainer.addSuccessMessage({
4449
'message': message
@@ -47,12 +52,9 @@ define(
4752
).fail(
4853
function (response) {
4954
totals.isLoading(false);
55+
fullScreenLoader.stopLoader();
5056
errorProcessor.process(response, messageContainer);
5157
}
52-
).always(
53-
function () {
54-
isLoading(false);
55-
}
5658
);
5759
};
5860
}

app/code/Magento/SalesRule/view/frontend/web/js/action/set-coupon-code.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,22 @@ define(
1818
'mage/storage',
1919
'mage/translate',
2020
'Magento_Checkout/js/action/get-payment-information',
21-
'Magento_Checkout/js/model/totals'
21+
'Magento_Checkout/js/model/totals',
22+
'Magento_Checkout/js/model/full-screen-loader'
2223
],
2324
function (
24-
ko,
25-
$,
26-
quote,
27-
urlManager,
28-
errorProcessor,
29-
messageContainer,
30-
storage,
31-
$t,
32-
getPaymentInformationAction,
33-
totals
25+
ko, $, quote, urlManager, errorProcessor, messageContainer, storage, $t, getPaymentInformationAction, totals,
26+
fullScreenLoader
3427
) {
3528
'use strict';
36-
return function (couponCode, isApplied, isLoading) {
37-
var quoteId = quote.getQuoteId();
38-
var url = urlManager.getApplyCouponUrl(couponCode, quoteId);
39-
var message = $t('Your coupon was successfully applied.');
29+
30+
return function (couponCode, isApplied) {
31+
var quoteId = quote.getQuoteId(),
32+
url = urlManager.getApplyCouponUrl(couponCode, quoteId),
33+
message = $t('Your coupon was successfully applied.');
34+
35+
fullScreenLoader.startLoader();
36+
4037
return storage.put(
4138
url,
4239
{},
@@ -45,19 +42,22 @@ define(
4542
function (response) {
4643
if (response) {
4744
var deferred = $.Deferred();
48-
isLoading(false);
45+
4946
isApplied(true);
5047
totals.isLoading(true);
5148
getPaymentInformationAction(deferred);
5249
$.when(deferred).done(function () {
50+
fullScreenLoader.stopLoader();
5351
totals.isLoading(false);
5452
});
55-
messageContainer.addSuccessMessage({'message': message});
53+
messageContainer.addSuccessMessage({
54+
'message': message
55+
});
5656
}
5757
}
5858
).fail(
5959
function (response) {
60-
isLoading(false);
60+
fullScreenLoader.stopLoader();
6161
totals.isLoading(false);
6262
errorProcessor.process(response, messageContainer);
6363
}

app/code/Magento/SalesRule/view/frontend/web/js/view/payment/discount.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,49 +13,53 @@ define(
1313
],
1414
function ($, ko, Component, quote, setCouponCodeAction, cancelCouponAction) {
1515
'use strict';
16-
var totals = quote.getTotals();
17-
var couponCode = ko.observable(null);
16+
17+
var totals = quote.getTotals(),
18+
couponCode = ko.observable(null),
19+
isApplied = ko.observable(couponCode() != null);
20+
1821
if (totals()) {
1922
couponCode(totals()['coupon_code']);
2023
}
21-
var isApplied = ko.observable(couponCode() != null);
22-
var isLoading = ko.observable(false);
24+
2325
return Component.extend({
2426
defaults: {
2527
template: 'Magento_SalesRule/payment/discount'
2628
},
2729
couponCode: couponCode,
30+
2831
/**
2932
* Applied flag
3033
*/
3134
isApplied: isApplied,
32-
isLoading: isLoading,
35+
3336
/**
3437
* Coupon code application procedure
3538
*/
3639
apply: function() {
3740
if (this.validate()) {
38-
isLoading(true);
39-
setCouponCodeAction(couponCode(), isApplied, isLoading);
41+
setCouponCodeAction(couponCode(), isApplied);
4042
}
4143
},
44+
4245
/**
4346
* Cancel using coupon
4447
*/
4548
cancel: function() {
4649
if (this.validate()) {
47-
isLoading(true);
4850
couponCode('');
49-
cancelCouponAction(isApplied, isLoading);
51+
cancelCouponAction(isApplied);
5052
}
5153
},
54+
5255
/**
5356
* Coupon form validation
5457
*
55-
* @returns {boolean}
58+
* @returns {Boolean}
5659
*/
57-
validate: function() {
60+
validate: function () {
5861
var form = '#discount-form';
62+
5963
return $(form).validation() && $(form).validation('isValid');
6064
}
6165
});

app/code/Magento/SalesRule/view/frontend/web/template/payment/discount.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<!-- ko foreach: getRegion('messages') -->
1616
<!-- ko template: getTemplate() --><!-- /ko -->
1717
<!--/ko-->
18-
<form class="form form-discount" id="discount-form" data-bind="blockLoader: isLoading">
18+
<form class="form form-discount" id="discount-form">
1919
<div class="payment-option-inner">
2020
<div class="field">
2121
<label class="label" for="discount-code">

dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public function selectPaymentMethod(array $payment, InjectableFixture $creditCar
8585
$paymentLabelSelector = sprintf($this->paymentMethodLabel, $payment['method']);
8686

8787
try {
88+
$this->waitForElementNotVisible($this->waitElement);
8889
$this->waitForElementVisible($paymentLabelSelector);
8990
} catch (\Exception $exception) {
9091
throw new \Exception('Such payment method is absent.');

0 commit comments

Comments
 (0)