Skip to content

Commit

Permalink
Merge pull request #5770 from magento-mpi/PR-2020-06-05
Browse files Browse the repository at this point in the history
PR-2.3
  • Loading branch information
zakdma authored Jun 16, 2020
2 parents eda6da9 + 9ac20f4 commit a68e299
Show file tree
Hide file tree
Showing 15 changed files with 356 additions and 53 deletions.
8 changes: 5 additions & 3 deletions app/code/Magento/Config/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ public function save()
);

$groupChangedPaths = $this->getChangedPaths($sectionId, $groupId, $groupData, $oldConfig, $extraOldGroups);
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
$changedPaths = \array_merge($changedPaths, $groupChangedPaths);
}

Expand Down Expand Up @@ -370,6 +371,7 @@ private function getChangedPaths(
$oldConfig,
$extraOldGroups
);
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
$changedPaths = \array_merge($changedPaths, $subGroupChangedPaths);
}
}
Expand Down Expand Up @@ -435,11 +437,11 @@ protected function _processGroup(
if (!isset($fieldData['value'])) {
$fieldData['value'] = null;
}

if ($field->getType() == 'multiline' && is_array($fieldData['value'])) {
$fieldData['value'] = trim(implode(PHP_EOL, $fieldData['value']));
}

$data = [
'field' => $fieldId,
'groups' => $groups,
Expand All @@ -453,7 +455,7 @@ protected function _processGroup(
$backendModel->addData($data);
$this->_checkSingleStoreMode($field, $backendModel);

$path = $this->getFieldPath($field, $fieldId, $extraOldGroups, $oldConfig);
$path = $this->getFieldPath($field, $fieldId, $oldConfig, $extraOldGroups);
$backendModel->setPath($path)->setValue($fieldData['value']);

$inherit = !empty($fieldData['inherit']);
Expand Down
30 changes: 27 additions & 3 deletions app/code/Magento/Contact/view/frontend/templates/form.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* See COPYING.txt for license details.
*/

// phpcs:disable Magento2.Templates.ThisInTemplate
// phpcs:disable Generic.Files.LineLength.TooLong

/** @var \Magento\Contact\Block\ContactForm $block */
?>
<form class="form contact"
Expand All @@ -18,19 +21,31 @@
<div class="field name required">
<label class="label" for="name"><span><?= $block->escapeHtml(__('Name')) ?></span></label>
<div class="control">
<input name="name" id="name" title="<?= $block->escapeHtmlAttr(__('Name')) ?>" value="<?= $block->escapeHtmlAttr($this->helper(\Magento\Contact\Helper\Data::class)->getPostValue('name') ?: $this->helper(\Magento\Contact\Helper\Data::class)->getUserName()) ?>" class="input-text" type="text" data-validate="{required:true}"/>
<input name="name" id="name" title="<?= $block->escapeHtmlAttr(__('Name')) ?>"
value="<?= $block->escapeHtmlAttr($this->helper(\Magento\Contact\Helper\Data::class)
->getPostValue('name')
?: $this->helper(\Magento\Contact\Helper\Data::class)->getUserName()) ?>"
class="input-text" type="text" data-validate="{required:true}"/>
</div>
</div>
<div class="field email required">
<label class="label" for="email"><span><?= $block->escapeHtml(__('Email')) ?></span></label>
<div class="control">
<input name="email" id="email" title="<?= $block->escapeHtmlAttr(__('Email')) ?>" value="<?= $block->escapeHtmlAttr($this->helper(\Magento\Contact\Helper\Data::class)->getPostValue('email') ?: $this->helper(\Magento\Contact\Helper\Data::class)->getUserEmail()) ?>" class="input-text" type="email" data-validate="{required:true, 'validate-email':true}"/>
<input name="email" id="email"
title="<?= $block->escapeHtmlAttr(__('Email')) ?>"
value="<?= $block->escapeHtmlAttr($this->helper(\Magento\Contact\Helper\Data::class)
->getPostValue('email')
?: $this->helper(\Magento\Contact\Helper\Data::class)->getUserEmail()) ?>"
class="input-text" type="email" data-validate="{required:true, 'validate-email':true}"/>
</div>
</div>
<div class="field telephone">
<label class="label" for="telephone"><span><?= $block->escapeHtml(__('Phone Number')) ?></span></label>
<div class="control">
<input name="telephone" id="telephone" title="<?= $block->escapeHtmlAttr(__('Phone Number')) ?>" value="<?= $block->escapeHtmlAttr($this->helper(\Magento\Contact\Helper\Data::class)->getPostValue('telephone')) ?>" class="input-text" type="text" />
<input name="telephone" id="telephone" title="<?= $block->escapeHtmlAttr(__('Phone Number')) ?>"
value="<?= $block->escapeHtmlAttr($this->helper(\Magento\Contact\Helper\Data::class)
->getPostValue('telephone')) ?>"
class="input-text" type="text" />
</div>
</div>
<div class="field comment required">
Expand All @@ -50,3 +65,12 @@
</div>
</div>
</form>
<script type="text/x-magento-init">
{
"*": {
"Magento_Customer/js/block-submit-on-send": {
"formId": "contact-form"
}
}
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @var $block \Magento\Customer\Block\Account\Forgotpassword
*/

// phpcs:disable Generic.Files.LineLength.TooLong

/** @var \Magento\Customer\Block\Account\Forgotpassword $block */
?>
<form class="form password forget"
Expand All @@ -32,3 +34,12 @@
</div>
</div>
</form>
<script type="text/x-magento-init">
{
"*": {
"Magento_Customer/js/block-submit-on-send": {
"formId": "form-validate"
}
}
}
</script>
24 changes: 22 additions & 2 deletions app/code/Magento/Customer/view/frontend/templates/form/login.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* See COPYING.txt for license details.
*/

// phpcs:disable Generic.Files.LineLength.TooLong

/** @var \Magento\Customer\Block\Form\Login $block */
?>
<div class="block block-customer-login">
Expand All @@ -22,13 +24,22 @@
<div class="field email required">
<label class="label" for="email"><span><?= $block->escapeHtml(__('Email')) ?></span></label>
<div class="control">
<input name="login[username]" value="<?= $block->escapeHtmlAttr($block->getUsername()) ?>" <?php if ($block->isAutocompleteDisabled()) : ?> autocomplete="off"<?php endif; ?> id="email" type="email" class="input-text" title="<?= $block->escapeHtmlAttr(__('Email')) ?>" data-mage-init='{"mage/trim-input":{}}' data-validate="{required:true, 'validate-email':true}">
<input name="login[username]" value="<?= $block->escapeHtmlAttr($block->getUsername()) ?>"
<?php if ($block->isAutocompleteDisabled()): ?> autocomplete="off"<?php endif; ?>
id="email" type="email" class="input-text"
title="<?= $block->escapeHtmlAttr(__('Email')) ?>"
data-mage-init='{"mage/trim-input":{}}'
data-validate="{required:true, 'validate-email':true}">
</div>
</div>
<div class="field password required">
<label for="pass" class="label"><span><?= $block->escapeHtml(__('Password')) ?></span></label>
<div class="control">
<input name="login[password]" type="password" <?php if ($block->isAutocompleteDisabled()) : ?> autocomplete="off"<?php endif; ?> class="input-text" id="pass" title="<?= $block->escapeHtmlAttr(__('Password')) ?>" data-validate="{required:true}">
<input name="login[password]" type="password"
<?php if ($block->isAutocompleteDisabled()): ?> autocomplete="off"<?php endif; ?>
class="input-text" id="pass"
title="<?= $block->escapeHtmlAttr(__('Password')) ?>"
data-validate="{required:true}">
</div>
</div>
<?= $block->getChildHtml('form_additional_info') ?>
Expand All @@ -41,3 +52,12 @@
</div>
</div>

<script type="text/x-magento-init">
{
"*": {
"Magento_Customer/js/block-submit-on-send": {
"formId": "login-form"
}
}
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,6 @@ require([
ignore: ignore ? ':hidden:not(' + ignore + ')' : ':hidden'
<?php endif ?>
}).find('input:text').attr('autocomplete', 'off');
dataForm.submit(function () {
$(this).find(':submit').attr('disabled', 'disabled');
});
dataForm.bind("invalid-form.validate", function () {
$(this).find(':submit').prop('disabled', false);
});
});
</script>
<?php if ($block->getShowAddressFields()): ?>
Expand All @@ -225,13 +219,17 @@ require([
}
</script>
<?php endif; ?>

<script type="text/x-magento-init">
{
".field.password": {
"passwordStrengthIndicator": {
"formSelector": "form.form-create-account"
}
},
"*": {
"Magento_Customer/js/block-submit-on-send": {
"formId": "form-validate"
}
}
}
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

define([
'jquery',
'mage/mage'
], function ($) {
'use strict';

return function (config) {
var dataForm = $('#' + config.formId);

dataForm.submit(function () {
$(this).find(':submit').attr('disabled', 'disabled');
});
dataForm.bind('invalid-form.validate', function () {
$(this).find(':submit').prop('disabled', false);
});
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,12 @@
</form>
</div>
</div>
<script type="text/x-magento-init">
{
"*": {
"Magento_Customer/js/block-submit-on-send": {
"formId": "newsletter-validate-detail"
}
}
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<severity value="CRITICAL"/>
<testCaseId value="MC-13690"/>
<group value="paypal"/>
<skip>
<issueId value="MC-35014"/>
</skip>
</annotations>
<before>

Expand Down
20 changes: 13 additions & 7 deletions app/code/Magento/Quote/Model/Quote/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,13 @@ public function collectShippingRates()
*/
public function requestShippingRates(AbstractItem $item = null)
{
$storeId = $this->getQuote()->getStoreId() ?: $this->storeManager->getStore()->getId();
$taxInclude = $this->_scopeConfig->getValue(
'tax/calculation/price_includes_tax',
ScopeInterface::SCOPE_STORE,
$storeId
);

/** @var $request RateRequest */
$request = $this->_rateRequestFactory->create();
$request->setAllItems($item ? [$item] : $this->getAllItems());
Expand All @@ -1028,31 +1035,30 @@ public function requestShippingRates(AbstractItem $item = null)
$request->setDestStreet($this->getStreetFull());
$request->setDestCity($this->getCity());
$request->setDestPostcode($this->getPostcode());
$request->setPackageValue($item ? $item->getBaseRowTotal() : $this->getBaseSubtotal());
$baseSubtotal = $taxInclude ? $this->getBaseSubtotalTotalInclTax() : $this->getBaseSubtotal();
$request->setPackageValue($item ? $item->getBaseRowTotal() : $baseSubtotal);
$baseSubtotalWithDiscount = $baseSubtotal + $this->getBaseDiscountAmount();
$packageWithDiscount = $item ? $item->getBaseRowTotal() -
$item->getBaseDiscountAmount() : $this->getBaseSubtotalWithDiscount();
$item->getBaseDiscountAmount() : $baseSubtotalWithDiscount;
$request->setPackageValueWithDiscount($packageWithDiscount);
$request->setPackageWeight($item ? $item->getRowWeight() : $this->getWeight());
$request->setPackageQty($item ? $item->getQty() : $this->getItemQty());

/**
* Need for shipping methods that use insurance based on price of physical products
*/
$packagePhysicalValue = $item ? $item->getBaseRowTotal() : $this->getBaseSubtotal() -
$this->getBaseVirtualAmount();
$packagePhysicalValue = $item ? $item->getBaseRowTotal() : $baseSubtotal - $this->getBaseVirtualAmount();
$request->setPackagePhysicalValue($packagePhysicalValue);

$request->setFreeMethodWeight($item ? 0 : $this->getFreeMethodWeight());

/**
* Store and website identifiers specified from StoreManager
*/
$request->setStoreId($storeId);
if ($this->getQuote()->getStoreId()) {
$storeId = $this->getQuote()->getStoreId();
$request->setStoreId($storeId);
$request->setWebsiteId($this->storeManager->getStore($storeId)->getWebsiteId());
} else {
$request->setStoreId($this->storeManager->getStore()->getId());
$request->setWebsiteId($this->storeManager->getWebsite()->getId());
}
$request->setFreeShipping($this->getFreeShipping());
Expand Down
43 changes: 31 additions & 12 deletions app/code/Magento/Quote/Test/Unit/Model/Quote/AddressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,40 @@ public function testRequestShippingRates()

$currentCurrencyCode = 'UAH';

$this->quote->expects($this->any())
->method('getStoreId')
->willReturn($storeId);

$this->storeManager->expects($this->at(0))
->method('getStore')
->with($storeId)
->willReturn($this->store);
$this->store->expects($this->any())
->method('getWebsiteId')
->willReturn($webSiteId);

$this->scopeConfig->expects($this->exactly(1))
->method('getValue')
->with(
'tax/calculation/price_includes_tax',
ScopeInterface::SCOPE_STORE,
$storeId
)
->willReturn(1);

/** @var RateRequest */
$request = $this->getMockBuilder(RateRequest::class)
->disableOriginalConstructor()
->setMethods(['setStoreId', 'setWebsiteId', 'setBaseCurrency', 'setPackageCurrency'])
->setMethods(
[
'setStoreId',
'setWebsiteId',
'setBaseCurrency',
'setPackageCurrency',
'getBaseSubtotalTotalInclTax',
'getBaseSubtotal'
]
)
->getMock();

/** @var Collection */
Expand Down Expand Up @@ -427,13 +457,6 @@ public function testRequestShippingRates()
$this->storeManager->method('getStore')
->willReturn($this->store);

$this->storeManager->expects($this->once())
->method('getWebsite')
->willReturn($this->website);

$this->store->method('getId')
->willReturn($storeId);

$this->store->method('getBaseCurrency')
->willReturn($baseCurrency);

Expand All @@ -445,10 +468,6 @@ public function testRequestShippingRates()
->method('getCurrentCurrencyCode')
->willReturn($currentCurrencyCode);

$this->website->expects($this->once())
->method('getId')
->willReturn($webSiteId);

$this->addressRateFactory->expects($this->once())
->method('create')
->willReturn($rate);
Expand Down
3 changes: 3 additions & 0 deletions app/code/Magento/SalesRule/view/frontend/requirejs-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ var config = {
mixins: {
'Magento_Checkout/js/action/select-payment-method': {
'Magento_SalesRule/js/action/select-payment-method-mixin': true
},
'Magento_Checkout/js/model/shipping-save-processor': {
'Magento_SalesRule/js/model/shipping-save-processor-mixin': true
}
}
}
Expand Down
Loading

0 comments on commit a68e299

Please sign in to comment.