diff --git a/app/code/Magento/PageCache/view/frontend/web/js/page-cache.js b/app/code/Magento/PageCache/view/frontend/web/js/page-cache.js index 8076048a5020853b3ce13ed6b8fa62a2e9022d88..ce9335138618305b1e71a1560b45bb2d60b7b690 100644 --- a/app/code/Magento/PageCache/view/frontend/web/js/page-cache.js +++ b/app/code/Magento/PageCache/view/frontend/web/js/page-cache.js @@ -37,7 +37,7 @@ define([ case 9: // DOCUMENT_NODE var hostName = window.location.hostname, iFrameHostName = $('<a>') - .prop('href', element.prop('src')) + .prop('href', $(element).prop('src')) .prop('hostname'); if (hostName === iFrameHostName) { diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php index 7ed85998bf520075a4a240795593cfcda37dd6b6..8984d2312db36840282fecc7f4abc811357837e2 100644 --- a/app/code/Magento/Sales/Model/Order.php +++ b/app/code/Magento/Sales/Model/Order.php @@ -1442,10 +1442,12 @@ class Order extends AbstractModel implements EntityInterface, OrderInterface */ public function setPayment(\Magento\Sales\Api\Data\OrderPaymentInterface $payment = null) { - $payment->setOrder($this)->setParentId($this->getId()); - if (!$payment->getId()) { - $this->setData(OrderInterface::PAYMENT, $payment); - $this->setDataChanges(true); + $this->setData(OrderInterface::PAYMENT, $payment); + if ($payment !== null) { + $payment->setOrder($this)->setParentId($this->getId()); + if (!$payment->getId()) { + $this->setDataChanges(true); + } } return $payment; } diff --git a/app/code/Magento/Sales/Setup/InstallSchema.php b/app/code/Magento/Sales/Setup/InstallSchema.php index 0801da31d117115b14b77de9a8f8313a98d612ca..6daa1b42b3a03734a1aeabcf46f3a91d0aa0198a 100644 --- a/app/code/Magento/Sales/Setup/InstallSchema.php +++ b/app/code/Magento/Sales/Setup/InstallSchema.php @@ -3216,12 +3216,6 @@ class InstallSchema implements InstallSchemaInterface '12,4', [], 'Grand Total' - )->addColumn( - 'base_grand_total', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Grand Total' )->addColumn( 'created_at', \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, @@ -3240,9 +3234,6 @@ class InstallSchema implements InstallSchemaInterface )->addIndex( $installer->getIdxName('sales_invoice_grid', ['grand_total']), ['grand_total'] - )->addIndex( - $installer->getIdxName('sales_invoice_grid', ['base_grand_total']), - ['base_grand_total'] )->addIndex( $installer->getIdxName('sales_invoice_grid', ['order_id']), ['order_id'] diff --git a/app/code/Magento/Sales/Setup/UpgradeSchema.php b/app/code/Magento/Sales/Setup/UpgradeSchema.php index fbf2e929a2f0f39ff19716c11e3209e33d5be3e8..907d782e8deafd5649712ead99a6d94cbc93c1f1 100644 --- a/app/code/Magento/Sales/Setup/UpgradeSchema.php +++ b/app/code/Magento/Sales/Setup/UpgradeSchema.php @@ -7,6 +7,7 @@ namespace Magento\Sales\Setup; use Magento\Framework\Setup\UpgradeSchemaInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\SchemaSetupInterface; +use Magento\Framework\DB\Adapter\AdapterInterface; /** * @codeCoverageIgnore @@ -53,5 +54,43 @@ class UpgradeSchema implements UpgradeSchemaInterface $installer->endSetup(); } + if (version_compare($context->getVersion(), '2.0.3', '<')) { + $this->addColumnBaseGrandTotal($installer); + $this->addIndexBaseGrandTotal($installer); + } + } + + /** + * @param SchemaSetupInterface $installer + * @return void + */ + private function addColumnBaseGrandTotal(SchemaSetupInterface $installer) + { + $connection = $installer->getConnection(); + $connection->addColumn( + $installer->getTable('sales_invoice_grid'), + 'base_grand_total', + [ + 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, + 'nullable' => true, + 'length' => '12,4', + 'comment' => 'Base Grand Total', + 'after' => 'grand_total' + ] + ); + } + + /** + * @param SchemaSetupInterface $installer + * @return void + */ + private function addIndexBaseGrandTotal(SchemaSetupInterface $installer) + { + $connection = $installer->getConnection(); + $connection->addIndex( + $installer->getTable('sales_invoice_grid'), + $installer->getIdxName('sales_invoice_grid', ['base_grand_total']), + ['base_grand_total'] + ); } -} \ No newline at end of file +} diff --git a/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php b/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php index 399092745977a5b480d2218ab145e9ea81e767e2..e8bf1ef1bfe4fc50982e7243ef13d127291a9b2b 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php @@ -5,6 +5,7 @@ */ namespace Magento\Sales\Test\Unit\Model; +use Magento\Sales\Api\Data\OrderInterface; use Magento\Sales\Model\Order; use Magento\Sales\Model\ResourceModel\Order\Status\History\CollectionFactory as HistoryCollectionFactory; @@ -757,6 +758,115 @@ class OrderTest extends \PHPUnit_Framework_TestCase $this->assertSame($this->order, $this->order->loadByIncrementIdAndStoreId($incrementId, $storeId)); } + public function testSetPaymentWithId() + { + $this->order->setId(123); + $payment = $this->getMockBuilder(\Magento\Sales\Model\Order\Payment::class) + ->disableOriginalConstructor() + ->getMock(); + $this->order->setData(OrderInterface::PAYMENT, $payment); + $this->order->setDataChanges(false); + + $payment->expects($this->once()) + ->method('setOrder') + ->with($this->order) + ->willReturnSelf(); + + $payment->expects($this->once()) + ->method('setParentId') + ->with(123) + ->willReturnSelf(); + + $payment->expects($this->any()) + ->method('getId') + ->willReturn(1); + + $this->order->setPayment($payment); + + $this->assertEquals( + $this->order->getData( + OrderInterface::PAYMENT + ), + $payment + ); + + $this->assertFalse( + $this->order->hasDataChanges() + ); + } + + public function testSetPaymentNoId() + { + $this->order->setId(123); + $this->order->setDataChanges(false); + + $payment = $this->getMockBuilder(\Magento\Sales\Model\Order\Payment::class) + ->disableOriginalConstructor() + ->getMock(); + + $payment->expects($this->once()) + ->method('setOrder') + ->with($this->order) + ->willReturnSelf(); + + $payment->expects($this->once()) + ->method('setParentId') + ->with(123) + ->willReturnSelf(); + + $payment->expects($this->any()) + ->method('getId') + ->willReturn(null); + + $this->order->setPayment($payment); + + $this->assertEquals( + $this->order->getData( + OrderInterface::PAYMENT + ), + $payment + ); + + $this->assertTrue( + $this->order->hasDataChanges() + ); + } + + public function testSetPaymentNull() + { + $this->assertEquals(null, $this->order->setPayment(null)); + + $this->assertEquals( + $this->order->getData( + OrderInterface::PAYMENT + ), + null + ); + + $this->assertTrue( + $this->order->hasDataChanges() + ); + } + + public function testResetOrderWillResetPayment() + { + $payment = $this->getMockBuilder(\Magento\Sales\Model\Order\Payment::class) + ->disableOriginalConstructor() + ->getMock(); + $this->order->setData(OrderInterface::PAYMENT, $payment); + $this->order->reset(); + $this->assertEquals( + $this->order->getData( + OrderInterface::PAYMENT + ), + null + ); + + $this->assertTrue( + $this->order->hasDataChanges() + ); + } + public function notInvoicingStatesProvider() { return [ diff --git a/app/code/Magento/Sales/etc/module.xml b/app/code/Magento/Sales/etc/module.xml index 19956e89184471dfb60b25b58e5ccba168e4e33d..88d6e25d31fb6c4ed9777595296e969028b154f2 100644 --- a/app/code/Magento/Sales/etc/module.xml +++ b/app/code/Magento/Sales/etc/module.xml @@ -6,7 +6,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> - <module name="Magento_Sales" setup_version="2.0.2"> + <module name="Magento_Sales" setup_version="2.0.3"> <sequence> <module name="Magento_Rule"/> <module name="Magento_Catalog"/> diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/address/form.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/address/form.phtml index 1a8985d2c3ccfb37782222bcd281f60509a54bcf..b2b7abf77acc9a938e7d0a6329ef05ca8aa6dd72 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/order/address/form.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/address/form.phtml @@ -18,7 +18,7 @@ <span><?php /* @escapeNotVerified */ echo $block->getHeaderText() ?></span> </legend> <br> - <div class="form-inline"> + <div class="form-inline" data-mage-init='{"Magento_Sales/order/edit/address/form":{}}'> <?php echo $block->getForm()->toHtml() ?> </div> </fieldset> diff --git a/app/code/Magento/Sales/view/adminhtml/web/order/edit/address/form.js b/app/code/Magento/Sales/view/adminhtml/web/order/edit/address/form.js new file mode 100644 index 0000000000000000000000000000000000000000..bdcb2cc8a574601d78ba7ae7ed70d7b3030108ba --- /dev/null +++ b/app/code/Magento/Sales/view/adminhtml/web/order/edit/address/form.js @@ -0,0 +1,34 @@ +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'jquery' +], function ($) { + 'use strict'; + + /** + * Currently Magento App stores both region_id and region (as text) values. + * To prevent missing region (as text) we need to copy it in hidden field. + * @param {Array} config + * @param {String} element + */ + return function (config, element) { + var form = $(element), + regionId = form.find('#region_id'), + + /** + * Set region callback + */ + setRegion = function () { + form.find('#region').val(regionId.filter(':visible').find(':selected').text()); + }; + + if (regionId.is('visible')) { + setRegion(); + } + + regionId.on('change', setRegion); + form.find('#country_id').on('change', setRegion); + }; +}); diff --git a/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml b/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml index a9a682be3194cbf91234dbcb837c394dc8b385fd..dea387e465685bb846e0368ba4f32f35e6531832 100644 --- a/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml +++ b/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml @@ -51,7 +51,7 @@ <fieldset name="general"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> - <item name="label" xsi:type="string">Currently Active</item> + <item name="label" xsi:type="string" translate="true">Currently Active</item> <item name="additionalClasses" xsi:type="string">fieldset-schedule</item> </item> </argument> diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js b/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js index b3db5d11b98a51bc166082a10ae351949f317d9c..01c8ef29029a9ef34f82885e3efbada75774a88b 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js @@ -16,6 +16,7 @@ define([ defaults: { elementSelector: 'textarea', value: '', + $wysiwygEditorButton: '', links: { value: '${ $.provider }:${ $.dataScope }' }, @@ -23,7 +24,10 @@ define([ elementTmpl: 'ui/form/element/wysiwyg', content: '', showSpinner: false, - loading: false + loading: false, + listens: { + disabled: 'setDisabled' + } }, /** @@ -34,6 +38,13 @@ define([ this._super() .initNodeListener(); + $.async({ + component: this, + selector: 'button' + }, function (element) { + this.$wysiwygEditorButton = $(element); + }.bind(this)); + return this; }, @@ -69,6 +80,26 @@ define([ $(node).bindings({ value: this.value }); + }, + + /** + * Set disabled property to wysiwyg component + * + * @param {Boolean} status + */ + setDisabled: function (status) { + this.$wysiwygEditorButton.attr('disabled', status); + + /* eslint-disable no-undef */ + if (tinyMCE) { + _.each(tinyMCE.activeEditor.controlManager.controls, function (property, index, controls) { + controls[property].setDisabled(status); + }); + + tinyMCE.activeEditor.getBody().setAttribute('contenteditable', !status); + } + + /* eslint-enable no-undef*/ } }); }); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/resize.js b/app/code/Magento/Ui/view/base/web/js/grid/resize.js index bad2061ec763562aa8bd927c9e6ba02911be4649..f7edde0ea47c422e48035f8254356edaa9091e46 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/resize.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/resize.js @@ -261,11 +261,10 @@ define([ */ initResizableElement: function (column) { var model = ko.dataFor(column), - ctx = ko.contextFor(column), - tempalteDragElement = '<div class="' + ctx.$parent.resizeConfig.classResize + '"></div>'; + templateDragElement = '<div class="' + this.resizableElementClass + '"></div>'; if (_.isUndefined(model.resizeEnabled) || model.resizeEnabled) { - $(column).append(tempalteDragElement); + $(column).append(templateDragElement); return true; } diff --git a/lib/web/mage/apply/scripts.js b/lib/web/mage/apply/scripts.js index 7f059a45ae5cd9acbb7c2c1f330419d8abe9f5a8..3b87f4fd2f40e6330f1577ca8dc2251a9f6a04d3 100644 --- a/lib/web/mage/apply/scripts.js +++ b/lib/web/mage/apply/scripts.js @@ -88,7 +88,7 @@ define([ /** * Parses 'script' tags with a custom type attribute and moves it's data - * to a 'data-mage-init' attribute of an elemennt found by provided selector. + * to a 'data-mage-init' attribute of an element found by provided selector. * Note: All found script nodes will be removed from DOM. * * @returns {Array} An array of components not assigned to the specific element. diff --git a/lib/web/mage/menu.js b/lib/web/mage/menu.js index a3f4ad36d0afa39f911f027754afab67e09925d7..3bed3dd4efcc72ad3554cc5f7546835c62f9b698 100644 --- a/lib/web/mage/menu.js +++ b/lib/web/mage/menu.js @@ -86,7 +86,7 @@ define([ //Add class for expanded option isExpanded: function () { var subMenus = this.element.find(this.options.menus), - expandedMenus = subMenus.find('ul'); + expandedMenus = subMenus.find(this.options.menus); expandedMenus.addClass('expanded'); }, @@ -105,7 +105,7 @@ define([ return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&"); } - if (this.active.closest('ul').attr('aria-expanded') != 'true') { + if (this.active.closest(this.options.menus).attr('aria-expanded') != 'true') { switch (event.keyCode) { case $.ui.keyCode.PAGE_UP: @@ -334,15 +334,16 @@ define([ }, "mouseenter .ui-menu-item": function (event) { var target = $(event.currentTarget), + submenu = this.options.menus, ulElement, ulElementWidth, width, targetPageX, rightBound; - if (target.has('ul')) { - ulElement = target.find('ul'); - ulElementWidth = target.find('ul').outerWidth(true); + if (target.has(submenu)) { + ulElement = target.find(submenu); + ulElementWidth = ulElement.outerWidth(true); width = target.outerWidth() * 2; targetPageX = target.offset().left; rightBound = $(window).width();