Skip to content

Commit f17f0d5

Browse files
author
Olga Kopylova
committed
Merge remote-tracking branch 'origin/MAGETWO-38561-exception-static-deploy' into MAGETWO-38010-warnings-static-view-files-deployment
2 parents 5de68c4 + f915940 commit f17f0d5

File tree

37 files changed

+1237
-351
lines changed

37 files changed

+1237
-351
lines changed

app/code/Magento/Catalog/view/frontend/web/js/catalog-add-to-cart.js

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
*/
55
define([
66
'jquery',
7+
'mage/translate',
78
'jquery/ui'
8-
], function($) {
9+
], function($, $t) {
910
"use strict";
1011

1112
$.widget('mage.catalogAddToCart', {
@@ -16,7 +17,13 @@ define([
1617
bindSubmit: true,
1718
minicartSelector: '[data-block="minicart"]',
1819
messagesSelector: '[data-placeholder="messages"]',
19-
productStatusSelector: '.stock.available'
20+
productStatusSelector: '.stock.available',
21+
addToCartButtonSelector: '.action.tocart',
22+
addToCartButtonDisabledClass: 'disabled',
23+
addToCartButtonTextWhileAdding: $t('Adding...'),
24+
addToCartButtonTextAdded: $t('Added'),
25+
addToCartButtonTextDefault: $t('Add to Cart')
26+
2027
},
2128

2229
_create: function() {
@@ -49,6 +56,9 @@ define([
4956

5057
ajaxSubmit: function(form) {
5158
var self = this;
59+
$(self.options.minicartSelector).trigger('contentLoading');
60+
self.disableAddToCartButton(form);
61+
5262
$.ajax({
5363
url: form.attr('action'),
5464
data: form.serialize(),
@@ -82,8 +92,30 @@ define([
8292
.find('span')
8393
.html(res.product.statusText);
8494
}
95+
self.enableAddToCartButton(form);
8596
}
8697
});
98+
},
99+
100+
disableAddToCartButton: function(form) {
101+
var addToCartButton = $(form).find(this.options.addToCartButtonSelector);
102+
addToCartButton.addClass(this.options.addToCartButtonDisabledClass);
103+
addToCartButton.attr('title', this.options.addToCartButtonTextWhileAdding);
104+
addToCartButton.find('span').text(this.options.addToCartButtonTextWhileAdding);
105+
},
106+
107+
enableAddToCartButton: function(form) {
108+
var self = this,
109+
addToCartButton = $(form).find(this.options.addToCartButtonSelector);
110+
111+
addToCartButton.find('span').text(this.options.addToCartButtonTextAdded);
112+
addToCartButton.attr('title', this.options.addToCartButtonTextAdded);
113+
114+
setTimeout(function() {
115+
addToCartButton.removeClass(self.options.addToCartButtonDisabledClass);
116+
addToCartButton.find('span').text(self.options.addToCartButtonTextDefault);
117+
addToCartButton.attr('title', self.options.addToCartButtonTextDefault);
118+
}, 1000);
87119
}
88120
});
89121

app/code/Magento/Checkout/Model/ShippingInformationManagement.php

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ public function __construct(
9494

9595
/**
9696
* {@inheritDoc}
97-
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
9897
* @SuppressWarnings(PHPMD.NPathComplexity)
9998
*/
10099
public function saveAddressInformation(
@@ -107,15 +106,7 @@ public function saveAddressInformation(
107106

108107
/** @var \Magento\Quote\Model\Quote $quote */
109108
$quote = $this->quoteRepository->getActive($cartId);
110-
if ($quote->isVirtual()) {
111-
throw new NoSuchEntityException(
112-
__('Cart contains virtual product(s) only. Shipping address is not applicable.')
113-
);
114-
}
115-
116-
if (0 == $quote->getItemsCount()) {
117-
throw new InputException(__('Shipping method is not applicable for empty cart'));
118-
}
109+
$this->validateQuote($quote);
119110

120111
$saveInAddressBook = $address->getSaveInAddressBook() ? 1 : 0;
121112
$sameAsBilling = $address->getSameAsBilling() ? 1 : 0;
@@ -139,6 +130,7 @@ public function saveAddressInformation(
139130
$address->setShippingMethod($carrierCode . '_' . $methodCode);
140131

141132
try {
133+
/** TODO: refactor this code. Eliminate save operation */
142134
$address->save();
143135
$address->collectTotals();
144136
} catch (\Exception $e) {
@@ -175,4 +167,25 @@ public function saveAddressInformation(
175167
$paymentDetails->setTotals($this->cartTotalsRepository->get($cartId));
176168
return $paymentDetails;
177169
}
170+
171+
/**
172+
* Validate quote
173+
*
174+
* @param \Magento\Quote\Model\Quote $quote
175+
* @throws InputException
176+
* @throws NoSuchEntityException
177+
* @return void
178+
*/
179+
protected function validateQuote(\Magento\Quote\Model\Quote $quote)
180+
{
181+
if ($quote->isVirtual()) {
182+
throw new NoSuchEntityException(
183+
__('Cart contains virtual product(s) only. Shipping address is not applicable.')
184+
);
185+
}
186+
187+
if (0 == $quote->getItemsCount()) {
188+
throw new InputException(__('Shipping method is not applicable for empty cart'));
189+
}
190+
}
178191
}

app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
/** @var $block \Magento\Checkout\Block\Cart\Sidebar */
1010
?>
1111

12-
<div data-block="minicart" class="minicart-wrapper" >
12+
<div data-block="minicart" class="minicart-wrapper">
1313
<a class="action showcart" href="<?php echo $block->getShoppingCartUrl(); ?>"
1414
data-bind="scope: 'minicart_content'">
1515
<span class="text"><?php echo __('My Cart'); ?></span>
1616
<span class="counter qty empty"
17-
data-bind="css: { empty: cart().summary_count == 0 }">
17+
data-bind="css: { empty: cart().summary_count == 0 }, blockLoader: isLoading">
1818
<span class="counter-number"><!-- ko text: cart().summary_count --><!-- /ko --></span>
1919
<span class="counter-label">
2020
<!-- ko if: cart().summary_count -->

app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ define([
1313
'use strict';
1414

1515
var sidebarInitialized = false;
16-
16+
var addToCartCalls = 0;
1717
url.setBaseUrl(window.checkout.baseUrl);
1818

1919
function initSidebar() {
@@ -60,12 +60,20 @@ define([
6060
return Component.extend({
6161
shoppingCartUrl: window.checkout.shoppingCartUrl,
6262
initialize: function () {
63+
var self = this;
6364
this._super();
6465
this.cart = customerData.get('cart');
6566
this.cart.subscribe(function () {
67+
addToCartCalls--;
68+
this.isLoading(addToCartCalls > 0);
6669
sidebarInitialized = false;
70+
}, this);
71+
$('[data-block="minicart"]').on('contentLoading', function(event) {
72+
addToCartCalls++;
73+
self.isLoading(true);
6774
});
6875
},
76+
isLoading: ko.observable(false),
6977
initSidebar: ko.observable(initSidebar),
7078
closeSidebar: function() {
7179
var minicart = $('[data-block="minicart"]');

app/code/Magento/Checkout/view/frontend/web/js/view/payment/default.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ define(
4545
/**
4646
* Place order.
4747
*/
48-
placeOrder: function () {
48+
placeOrder: function (data, event) {
49+
if (event) {
50+
event.preventDefault();
51+
}
4952
var self = this,
5053
placeOrder,
5154
emailValidationResult = customer.isLoggedIn(),
@@ -61,7 +64,9 @@ define(
6164
$.when(placeOrder).fail(function(){
6265
self.isPlaceOrderActionAllowed(true);
6366
});
67+
return true;
6468
}
69+
return false;
6570
},
6671

6772
selectPaymentMethod: function() {

app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php

Lines changed: 51 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -185,70 +185,94 @@ public function __construct(
185185
}
186186

187187
/**
188-
* Return one-level child directories for specified path
188+
* Create sub directories if DB storage is used
189189
*
190-
* @param string $path Parent directory path
191-
* @return \Magento\Framework\Data\Collection\Filesystem
192-
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
193-
* @SuppressWarnings(PHPMD.NPathComplexity)
190+
* @param string $path
191+
* @return void
194192
*/
195-
public function getDirsCollection($path)
193+
protected function createSubDirectories($path)
196194
{
197195
if ($this->_coreFileStorageDb->checkDbUsage()) {
198196
/** @var \Magento\MediaStorage\Model\File\Storage\Directory\Database $subDirectories */
199197
$subDirectories = $this->_directoryDatabaseFactory->create();
200-
$subDirectories->getSubdirectories($path);
201-
foreach ($subDirectories as $directory) {
198+
$directories = $subDirectories->getSubdirectories($path);
199+
foreach ($directories as $directory) {
202200
$fullPath = rtrim($path, '/') . '/' . $directory['name'];
203201
$this->_directory->create($fullPath);
204202
}
205203
}
204+
}
206205

206+
/**
207+
* Prepare and get conditions for exclude directories
208+
*
209+
* @return array
210+
*/
211+
protected function getConditionsForExcludeDirs()
212+
{
207213
$conditions = ['reg_exp' => [], 'plain' => []];
208214

209215
if ($this->_dirs['exclude']) {
210216
foreach ($this->_dirs['exclude'] as $dir) {
211-
$conditions[$dir->getAttribute('regexp') ? 'reg_exp' : 'plain'][$dir] = true;
217+
$conditions[!empty($dir['regexp']) ? 'reg_exp' : 'plain'][$dir['name']] = true;
212218
}
213219
}
214220

215221
// "include" section takes precedence and can revoke directory exclusion
216222
if ($this->_dirs['include']) {
217223
foreach ($this->_dirs['include'] as $dir) {
218-
unset($conditions['regexp'][(string)$dir], $conditions['plain'][$dir]);
224+
unset($conditions['reg_exp'][$dir['name']], $conditions['plain'][$dir['name']]);
219225
}
220226
}
221227

228+
return $conditions;
229+
}
230+
231+
/**
232+
* Remove excluded directories from collection
233+
*
234+
* @param \Magento\Framework\Data\Collection\Filesystem $collection
235+
* @param array $conditions
236+
* @return \Magento\Framework\Data\Collection\Filesystem
237+
*/
238+
protected function removeItemFromCollection($collection, $conditions)
239+
{
222240
$regExp = $conditions['reg_exp'] ? '~' . implode('|', array_keys($conditions['reg_exp'])) . '~i' : null;
223-
$collection = $this->getCollection(
224-
$path
225-
)->setCollectDirs(
226-
true
227-
)->setCollectFiles(
228-
false
229-
)->setCollectRecursively(
230-
false
231-
);
232241
$storageRootLength = strlen($this->_cmsWysiwygImages->getStorageRoot());
233242

234243
foreach ($collection as $key => $value) {
235244
$rootChildParts = explode('/', substr($value->getFilename(), $storageRootLength));
236245

237-
if (array_key_exists(
238-
$rootChildParts[0],
239-
$conditions['plain']
240-
) || $regExp && preg_match(
241-
$regExp,
242-
$value->getFilename()
243-
)
244-
) {
246+
if (array_key_exists($rootChildParts[1], $conditions['plain'])
247+
|| ($regExp && preg_match($regExp, $value->getFilename()))) {
248+
245249
$collection->removeItemByKey($key);
246250
}
247251
}
248252

249253
return $collection;
250254
}
251255

256+
/**
257+
* Return one-level child directories for specified path
258+
*
259+
* @param string $path Parent directory path
260+
* @return \Magento\Framework\Data\Collection\Filesystem
261+
*/
262+
public function getDirsCollection($path)
263+
{
264+
$this->createSubDirectories($path);
265+
266+
$collection = $this->getCollection($path)
267+
->setCollectDirs(true)
268+
->setCollectFiles(false)
269+
->setCollectRecursively(false);
270+
271+
$conditions = $this->getConditionsForExcludeDirs();
272+
273+
return $this->removeItemFromCollection($collection, $conditions);
274+
}
275+
252276
/**
253277
* Return files
254278
*

app/code/Magento/Cms/Setup/InstallData.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,12 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
111111
</span>
112112
</div>
113113
<p>
114-
This privacy policy sets out how {{config path="general/store_information/name"}} uses and protects any
115-
information that you give {{config path="general/store_information/name"}} when you use this website.
116-
{{config path="general/store_information/name"}} is committed to ensuring that your privacy is protected.
117-
Should we ask you to provide certain information by which you can be identified when using this website,
118-
then you can be assured that it will only be used in accordance with this privacy statement.
119-
{{config path="general/store_information/name"}} may change this policy from time to time by updating this page.
120-
You should check this page from time to time to ensure that you are happy with any changes.
114+
This privacy policy sets out how this website (hereafter "the Store") uses and protects any information that
115+
you give the Store while using this website. The Store is committed to ensuring that your privacy is protected.
116+
Should we ask you to provide certain information by which you can be identified when using this website, then
117+
you can be assured that it will only be used in accordance with this privacy statement. The Store may change
118+
this policy from time to time by updating this page. You should check this page from time to time to ensure
119+
that you are happy with any changes.
121120
</p>
122121
<h2>What we collect</h2>
123122
<p>We may collect the following information:</p>
@@ -191,8 +190,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
191190
</li>
192191
<li>
193192
if you have previously agreed to us using your personal information for direct marketing purposes,
194-
you may change your mind at any time by writing to or emailing us at
195-
{{config path="trans_email/ident_general/email"}}
193+
you may change your mind at any time by letting us know using our Contact Us information
196194
</li>
197195
</ul>
198196
<p>
@@ -202,8 +200,8 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
202200
</p>
203201
<p>
204202
You may request details of personal information which we hold about you under the Data Protection Act 1998.
205-
A small fee will be payable. If you would like a copy of the information held on you please write to
206-
{{config path="general/store_information/address"}}.
203+
A small fee will be payable. If you would like a copy of the information held on you please email us this
204+
request using our Contact Us information.
207205
</p>
208206
<p>
209207
If you believe that any information we are holding on you is incorrect or incomplete,

0 commit comments

Comments
 (0)