diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php
index 683ab3ed7e798..a869a26f64731 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php
@@ -170,10 +170,6 @@ public function initializeFromData(\Magento\Catalog\Model\Product $product, arra
$product->lockAttribute('media');
}
- if ($this->storeManager->hasSingleStore() && empty($product->getWebsiteIds())) {
- $product->setWebsiteIds([$this->storeManager->getStore(true)->getWebsite()->getId()]);
- }
-
/**
* Check "Use Default Value" checkboxes values
*/
diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product.php b/app/code/Magento/Catalog/Model/ResourceModel/Product.php
index ff12a316129f8..9f505fcbbb220 100644
--- a/app/code/Magento/Catalog/Model/ResourceModel/Product.php
+++ b/app/code/Magento/Catalog/Model/ResourceModel/Product.php
@@ -315,8 +315,9 @@ public function delete($object)
*/
protected function _saveWebsiteIds($product)
{
- if (empty(array_diff($product->getWebsiteIds(), [0]))) {
- $product->setWebsiteIds([1]);
+ if ($this->_storeManager->isSingleStoreMode()) {
+ $id = $this->_storeManager->getDefaultStoreView()->getWebsiteId();
+ $product->setWebsiteIds([$id]);
}
$websiteIds = $product->getWebsiteIds();
diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Link/Product/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Link/Product/Collection.php
index caf6fcd09152d..239f94e1286b8 100644
--- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Link/Product/Collection.php
+++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Link/Product/Collection.php
@@ -56,7 +56,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection
/**
* @var MetadataPool
*/
- protected $metadataPool;
+ private $metadataPool;
/**
* @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
@@ -219,7 +219,8 @@ public function addProductFilter($products)
if (!is_array($products)) {
$products = [$products];
}
- $this->getSelect()->where('links.product_id IN (?)', $products);
+ $identifierField = $this->getMetadataPool()->getMetadata(ProductInterface::class)->getIdentifierField();
+ $this->getSelect()->where("product_entity_table.$identifierField IN (?)", $products);
$this->_hasLinkFilter = true;
}
@@ -258,6 +259,7 @@ protected function _beforeLoad()
{
if ($this->getLinkModel()) {
$this->_joinLinks();
+ $this->joinProductsToLinks();
}
return parent::_beforeLoad();
}
@@ -423,12 +425,28 @@ public function addLinkAttributeToFilter($code, $condition)
/**
* Get MetadataPool instance
* @return MetadataPool
+ * @deprecated
*/
- protected function getMetadataPool()
+ private function getMetadataPool()
{
if (!$this->metadataPool) {
$this->metadataPool = ObjectManager::getInstance()->get(MetadataPool::class);
}
return $this->metadataPool;
}
+
+ /**
+ * Join Product To Links
+ * @return void
+ */
+ private function joinProductsToLinks()
+ {
+ if ($this->_hasLinkFilter) {
+ $metaDataPool = $this->getMetadataPool()->getMetadata(ProductInterface::class);
+ $linkField = $metaDataPool->getLinkField();
+ $entityTable = $metaDataPool->getEntityTable();
+ $this->getSelect()
+ ->join(['product_entity_table' => $entityTable], "links.product_id = product_entity_table.$linkField", []);
+ }
+ }
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/HelperTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/HelperTest.php
index bbc9b9a174e97..4f19d2f0117ed 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/HelperTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/HelperTest.php
@@ -196,16 +196,6 @@ protected function setUp()
*/
public function testInitialize()
{
- $this->websiteMock->expects($this->once())
- ->method('getId')
- ->willReturn($this->websiteId);
- $this->storeMock->expects($this->once())
- ->method('getWebsite')
- ->willReturn($this->websiteMock);
- $this->storeManagerMock->expects($this->once())
- ->method('getStore')
- ->with(true)
- ->willReturn($this->storeMock);
$this->customOptionMock->expects($this->once())
->method('setProductSku');
$this->customOptionMock->expects($this->once())
@@ -270,9 +260,6 @@ public function testInitialize()
->method('filter')
->with(['stock_data'])
->willReturn(['stock_data']);
- $this->storeManagerMock->expects($this->once())
- ->method('hasSingleStore')
- ->willReturn(true);
$this->productMock->expects($this->once())
->method('isLockedAttribute')
->with('media')
@@ -300,9 +287,6 @@ public function testInitialize()
$this->productMock->expects($this->once())
->method('getSku')
->willReturn('sku');
- $this->productMock->expects($this->once())
- ->method('setWebsiteIds')
- ->with([$this->websiteId]);
$this->productMock->expects($this->any())
->method('getOptionsReadOnly')
->willReturn(false);
diff --git a/app/code/Magento/Downloadable/etc/di.xml b/app/code/Magento/Downloadable/etc/di.xml
index 606c41442e07a..815868824ed25 100644
--- a/app/code/Magento/Downloadable/etc/di.xml
+++ b/app/code/Magento/Downloadable/etc/di.xml
@@ -14,6 +14,16 @@
+
+
+ Magento\Framework\Url
+
+
+
+
+ context_for_downloadable
+
+
diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo/Item.php b/app/code/Magento/Sales/Model/Order/Creditmemo/Item.php
index 70681f8dee82f..4489655e36af9 100644
--- a/app/code/Magento/Sales/Model/Order/Creditmemo/Item.php
+++ b/app/code/Magento/Sales/Model/Order/Creditmemo/Item.php
@@ -127,28 +127,16 @@ public function setOrderItem(\Magento\Sales\Model\Order\Item $item)
public function getOrderItem()
{
if ($this->_orderItem === null) {
- $this->_orderItem = $this->getOrderItemWithoutCaching();
+ if ($this->getCreditmemo()) {
+ $orderItem = $this->getCreditmemo()->getOrder()->getItemById($this->getOrderItemId());
+ } else {
+ $orderItem = $this->_orderItemFactory->create()->load($this->getOrderItemId());
+ }
+ $this->_orderItem = $orderItem;
}
return $this->_orderItem;
}
- /**
- * Retrieve order item instance without set it to property.
- * It is need for ability to process setQty on api when credit memo and order has not built yet.
- *
- * @return \Magento\Sales\Model\Order\Item
- */
- private function getOrderItemWithoutCaching()
- {
- if ($this->getCreditmemo()) {
- $orderItem = $this->getCreditmemo()->getOrder()->getItemById($this->getOrderItemId());
- } else {
- $orderItem = $this->_orderItemFactory->create()->load($this->getOrderItemId());
- }
-
- return $orderItem;
- }
-
/**
* Checks if quantity available for refund
*
@@ -164,26 +152,12 @@ private function isQtyAvailable($qty, \Magento\Sales\Model\Order\Item $orderItem
/**
* Declare qty
*
- * @param float $qty
+ * @param float $qty
* @return $this
- * @throws \Magento\Framework\Exception\LocalizedException
*/
public function setQty($qty)
{
- $orderItem = $this->getOrderItemWithoutCaching();
- if ($orderItem->getIsQtyDecimal()) {
- $qty = (double)$qty;
- } else {
- $qty = (int)$qty;
- }
- $qty = $qty > 0 ? $qty : 0;
- if ($this->isQtyAvailable($qty, $orderItem)) {
- $this->setData('qty', $qty);
- } else {
- throw new \Magento\Framework\Exception\LocalizedException(
- __('We found an invalid quantity to refund item "%1".', $this->getName())
- );
- }
+ $this->setData(CreditmemoItemInterface::QTY, $qty);
return $this;
}
@@ -196,7 +170,8 @@ public function register()
{
$orderItem = $this->getOrderItem();
- $orderItem->setQtyRefunded($orderItem->getQtyRefunded() + $this->getQty());
+ $qty = $this->processQty();
+ $orderItem->setQtyRefunded($orderItem->getQtyRefunded() + $qty);
$orderItem->setTaxRefunded($orderItem->getTaxRefunded() + $this->getTaxAmount());
$orderItem->setBaseTaxRefunded($orderItem->getBaseTaxRefunded() + $this->getBaseTaxAmount());
$orderItem->setDiscountTaxCompensationRefunded(
@@ -213,22 +188,46 @@ public function register()
return $this;
}
+ /**
+ * @return int|float
+ * @throws \Magento\Framework\Exception\LocalizedException
+ */
+ private function processQty()
+ {
+ $orderItem = $this->getOrderItem();
+ $qty = $this->getQty();
+ if ($orderItem->getIsQtyDecimal()) {
+ $qty = (double)$qty;
+ } else {
+ $qty = (int)$qty;
+ }
+ $qty = $qty > 0 ? $qty : 0;
+ if ($this->isQtyAvailable($qty, $orderItem)) {
+ return $qty;
+ } else {
+ throw new \Magento\Framework\Exception\LocalizedException(
+ __('We found an invalid quantity to refund item "%1".', $this->getName())
+ );
+ }
+ }
+
/**
* @return $this
*/
public function cancel()
{
- $this->getOrderItem()->setQtyRefunded($this->getOrderItem()->getQtyRefunded() - $this->getQty());
+ $qty = $this->processQty();
+ $this->getOrderItem()->setQtyRefunded($this->getOrderItem()->getQtyRefunded() - $qty);
$this->getOrderItem()->setTaxRefunded(
$this->getOrderItem()->getTaxRefunded() -
$this->getOrderItem()->getBaseTaxAmount() *
- $this->getQty() /
+ $qty /
$this->getOrderItem()->getQtyOrdered()
);
$this->getOrderItem()->setDiscountTaxCompensationRefunded(
$this->getOrderItem()->getDiscountTaxCompensationRefunded() -
$this->getOrderItem()->getDiscountTaxCompensationAmount() *
- $this->getQty() /
+ $qty /
$this->getOrderItem()->getQtyOrdered()
);
return $this;
@@ -250,10 +249,11 @@ public function calcRowTotal()
$rowTotalInclTax = $orderItem->getRowTotalInclTax();
$baseRowTotalInclTax = $orderItem->getBaseRowTotalInclTax();
- if (!$this->isLast() && $orderItemQtyInvoiced > 0 && $this->getQty() >= 0) {
+ $qty = $this->processQty();
+ if (!$this->isLast() && $orderItemQtyInvoiced > 0 && $qty >= 0) {
$availableQty = $orderItemQtyInvoiced - $orderItem->getQtyRefunded();
- $rowTotal = $creditmemo->roundPrice($rowTotal / $availableQty * $this->getQty());
- $baseRowTotal = $creditmemo->roundPrice($baseRowTotal / $availableQty * $this->getQty(), 'base');
+ $rowTotal = $creditmemo->roundPrice($rowTotal / $availableQty * $qty);
+ $baseRowTotal = $creditmemo->roundPrice($baseRowTotal / $availableQty * $qty, 'base');
}
$this->setRowTotal($rowTotal);
$this->setBaseRowTotal($baseRowTotal);
@@ -261,10 +261,10 @@ public function calcRowTotal()
if ($rowTotalInclTax && $baseRowTotalInclTax) {
$orderItemQty = $orderItem->getQtyOrdered();
$this->setRowTotalInclTax(
- $creditmemo->roundPrice($rowTotalInclTax / $orderItemQty * $this->getQty(), 'including')
+ $creditmemo->roundPrice($rowTotalInclTax / $orderItemQty * $qty, 'including')
);
$this->setBaseRowTotalInclTax(
- $creditmemo->roundPrice($baseRowTotalInclTax / $orderItemQty * $this->getQty(), 'including_base')
+ $creditmemo->roundPrice($baseRowTotalInclTax / $orderItemQty * $qty, 'including_base')
);
}
return $this;
@@ -278,7 +278,8 @@ public function calcRowTotal()
public function isLast()
{
$orderItem = $this->getOrderItem();
- if ((string)(double)$this->getQty() == (string)(double)$orderItem->getQtyToRefund()) {
+ $qty = $this->processQty();
+ if ((string)(double)$qty == (string)(double)$orderItem->getQtyToRefund()) {
return true;
}
return false;
diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/ItemTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/ItemTest.php
index 4949ba60bf489..629beeb589f36 100644
--- a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/ItemTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/ItemTest.php
@@ -92,87 +92,9 @@ public function testGetOrderItemFromFactory()
$this->assertInstanceOf('Magento\Sales\Model\Order\Item', $result);
}
- /**
- * @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage We found an invalid quantity to refund item "test_item_name".
- */
- public function testSetQtyDecimalException()
- {
- $qty = 100;
- $orderItemQty = 10;
- $name = 'test_item_name';
-
- $orderItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item')
- ->disableOriginalConstructor()
- ->getMock();
- $orderItemMock->expects($this->once())
- ->method('getIsQtyDecimal')
- ->willReturn(true);
- $orderItemMock->expects($this->once())
- ->method('getQtyToRefund')
- ->willReturn($orderItemQty);
- $orderItemMock->expects($this->atLeastOnce())
- ->method('load')
- ->willReturnSelf();
- $this->orderItemFactoryMock->expects($this->atLeastOnce())
- ->method('create')
- ->willReturn($orderItemMock);
- $this->item->setData(CreditmemoItemInterface::NAME, $name);
- $this->item->setOrderItem($orderItemMock);
- $this->item->setQty($qty);
- }
-
- /**
- * @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage We found an invalid quantity to refund item "test_item_name2".
- */
- public function testSetQtyNumericException()
- {
- $qty = 100;
- $orderItemQty = 10;
- $name = 'test_item_name2';
-
- $orderItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item')
- ->disableOriginalConstructor()
- ->getMock();
- $orderItemMock->expects($this->once())
- ->method('getIsQtyDecimal')
- ->willReturn(false);
- $orderItemMock->expects($this->once())
- ->method('getQtyToRefund')
- ->willReturn($orderItemQty);
- $orderItemMock->expects($this->atLeastOnce())
- ->method('load')
- ->willReturnSelf();
- $this->orderItemFactoryMock->expects($this->atLeastOnce())
- ->method('create')
- ->willReturn($orderItemMock);
- $this->item->setData(CreditmemoItemInterface::NAME, $name);
- $this->item->setOrderItem($orderItemMock);
- $this->item->setQty($qty);
- }
-
public function testSetQty()
{
$qty = 10;
- $orderItemQty = 100;
-
- $orderItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item')
- ->disableOriginalConstructor()
- ->getMock();
- $orderItemMock->expects($this->once())
- ->method('getIsQtyDecimal')
- ->willReturn(false);
- $orderItemMock->expects($this->once())
- ->method('getQtyToRefund')
- ->willReturn($orderItemQty);
- $orderItemMock->expects($this->atLeastOnce())
- ->method('load')
- ->willReturnSelf();
- $this->orderItemFactoryMock->expects($this->atLeastOnce())
- ->method('create')
- ->willReturn($orderItemMock);
- $this->item->setOrderItem($orderItemMock);
$this->item->setQty($qty);
$this->assertEquals($qty, $this->item->getQty());
}
@@ -209,19 +131,39 @@ public function testRegister()
$orderItemMock->expects($this->once())
->method('getBaseDiscountRefunded')
->willReturn(1);
- $data = [
- 'qty' => 1,
- 'tax_amount' => 1,
- 'base_tax_amount' => 1,
- 'discount_tax_compensation_amount' => 1,
- 'base_discount_tax_compensation_amount' => 1,
- 'row_total' => 1,
- 'base_row_total' => 1,
- 'discount_amount' => 1,
- 'base_discount_amount' => 1
- ];
+ $orderItemMock->expects($this->once())
+ ->method('getQtyToRefund')
+ ->willReturn(1);
+ $this->item->setQty(1);
+ $this->item->setTaxAmount(1);
+ $this->item->setBaseTaxAmount(1);
+ $this->item->setDiscountTaxCompensationAmount(1);
+ $this->item->setBaseDiscountTaxCompensationAmount(1);
+ $this->item->setRowTotal(1);
+ $this->item->setBaseRowTotal(1);
+ $this->item->setDiscountAmount(1);
+ $this->item->setBaseDiscountAmount(1);
+ $this->item->setOrderItem($orderItemMock);
+ $result = $this->item->register();
+ $this->assertInstanceOf('Magento\Sales\Model\Order\Creditmemo\Item', $result);
+ }
+
+ /**
+ * @expectedException \Magento\Framework\Exception\LocalizedException
+ * @expectedExceptionMessage We found an invalid quantity to refund item "test".
+ */
+ public function testRegisterWithException()
+ {
+ $orderItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item')
+ ->disableOriginalConstructor()
+ ->setMethods(['getQtyRefunded'])
+ ->getMock();
+ $orderItemMock->expects($this->once())
+ ->method('getQtyRefunded')
+ ->willReturn(1);
+ $this->item->setQty(2);
$this->item->setOrderItem($orderItemMock);
- $this->item->setData($data);
+ $this->item->setName('test');
$result = $this->item->register();
$this->assertInstanceOf('Magento\Sales\Model\Order\Creditmemo\Item', $result);
}
@@ -230,19 +172,6 @@ public function testCancel()
{
$orderItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item')
->disableOriginalConstructor()
- ->setMethods(
- [
- 'setQtyRefunded',
- 'getQtyRefunded',
- 'getTaxRefunded',
- 'getBaseTaxAmount',
- 'getQtyOrdered',
- 'setTaxRefunded',
- 'setDiscountTaxCompensationRefunded',
- 'getDiscountTaxCompensationRefunded',
- 'getDiscountTaxCompensationAmount'
- ]
- )
->getMock();
$orderItemMock->expects($this->once())
->method('getQtyRefunded')
@@ -272,8 +201,11 @@ public function testCancel()
$orderItemMock->expects($this->once())
->method('getDiscountTaxCompensationAmount')
->willReturn(10);
+ $orderItemMock->expects($this->once())
+ ->method('getQtyToRefund')
+ ->willReturn(1);
- $this->item->setData('qty', 1);
+ $this->item->setQty(1);
$this->item->setOrderItem($orderItemMock);
$result = $this->item->cancel();
$this->assertInstanceOf('Magento\Sales\Model\Order\Creditmemo\Item', $result);
@@ -342,7 +274,7 @@ function ($arg) {
->method('getQtyToRefund')
->willReturn($qtyAvailable);
- $this->item->setData('qty', $qty);
+ $this->item->setQty($qty);
$this->item->setCreditmemo($creditmemoMock);
$this->item->setOrderItem($orderItemMock);
$result = $this->item->calcRowTotal();
diff --git a/app/code/Magento/Sales/Ui/Component/Control/PdfAction.php b/app/code/Magento/Sales/Ui/Component/Control/PdfAction.php
new file mode 100644
index 0000000000000..4839f387b88ae
--- /dev/null
+++ b/app/code/Magento/Sales/Ui/Component/Control/PdfAction.php
@@ -0,0 +1,31 @@
+getConfiguration();
+ $context = $this->getContext();
+ $config['url'] = $context->getUrl(
+ $config['pdfAction'],
+ ['order_id' => $context->getRequestParam('order_id')]
+ );
+ $this->setData('config', (array)$config);
+ parent::prepare();
+ }
+}
diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_creditmemo_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_creditmemo_grid.xml
index 8c16c79e6cd02..cb1a60eb081f2 100644
--- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_creditmemo_grid.xml
+++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_creditmemo_grid.xml
@@ -54,12 +54,12 @@
-
+
-
- pdfcreditmemos_order
- PDF Creditmemos
-
+ - sales/creditmemo/pdfcreditmemos
diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml
index 125a801b5524f..97650870dc451 100644
--- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml
+++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml
@@ -54,12 +54,12 @@
-
+
-
- pdfinvoices_order
- PDF Invoices
-
+ - sales/invoice/pdfinvoices
diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_shipment_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_shipment_grid.xml
index c2faef8c1ff72..973986b77fbb6 100644
--- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_shipment_grid.xml
+++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_shipment_grid.xml
@@ -54,12 +54,12 @@
-
+
-
- pdfshipments_order
- PDF Shipments
-
+ - sales/shipment/pdfshipments
diff --git a/app/code/Magento/Ui/Component/Form/Element/DataType/Date.php b/app/code/Magento/Ui/Component/Form/Element/DataType/Date.php
index f384cdd3f9dd1..c074fcc056fc3 100644
--- a/app/code/Magento/Ui/Component/Form/Element/DataType/Date.php
+++ b/app/code/Magento/Ui/Component/Form/Element/DataType/Date.php
@@ -70,14 +70,6 @@ public function prepare()
))->getOffset();
}
- if (!isset($config['timeFormat'])) {
- $config['timeFormat'] = $this->localeDate->getTimeFormat(\IntlDateFormatter::SHORT);
- }
-
- if (!isset($config['dateFormat'])) {
- $config['dateFormat'] = $this->localeDate->getDateFormat(\IntlDateFormatter::MEDIUM);
- }
-
$this->setData('config', $config);
parent::prepare();
diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/date.js b/app/code/Magento/Ui/view/base/web/js/form/element/date.js
index 809a5201966cf..1c9f0b9b3e81c 100644
--- a/app/code/Magento/Ui/view/base/web/js/form/element/date.js
+++ b/app/code/Magento/Ui/view/base/web/js/form/element/date.js
@@ -15,10 +15,6 @@ define([
timeOffset: 0,
- showsTime: false,
-
- dateFormat: 'MM/dd/y', // ICU Date Format
- timeFormat: 'HH:mm', // ICU Time Format
validationParams: {
dateFormat: '${ $.outputDateFormat }'
},
@@ -28,7 +24,7 @@ define([
* server (ICU Date Format).
*
* Used only in date picker mode
- * (this.showsTime == false).
+ * (this.options.showsTime == false).
*
* @type {String}
*/
@@ -39,7 +35,7 @@ define([
* server (ICU Date Format).
*
* Used only in date picker mode
- * (this.showsTime == false).
+ * (this.options.showsTime == false).
*
* @type {String}
*/
@@ -51,7 +47,10 @@ define([
*
* @type {String}
*/
- datetimeFormat: '',
+ pickerDateTimeFormat: '',
+
+ pickerDefaultDateFormat: 'MM/dd/y', // ICU Date Format
+ pickerDefaultTimeFormat: 'h:mm a', // ICU Time Format
elementTmpl: 'ui/form/element/date',
@@ -78,13 +77,15 @@ define([
initConfig: function () {
this._super();
- utils.extend(this.options, {
- showsTime: this.showsTime,
- timeFormat: this.timeFormat,
- dateFormat: this.dateFormat
- });
+ if (!this.options.dateFormat) {
+ this.options.dateFormat = this.pickerDefaultDateFormat;
+ }
+
+ if (!this.options.timeFormat) {
+ this.options.timeFormat = this.pickerDefaultTimeFormat;
+ }
- this.prepareDatetimeFormats();
+ this.prepareDateTimeFormats();
return this;
},
@@ -107,7 +108,7 @@ define([
shiftedValue;
if (value) {
- if (this.showsTime) {
+ if (this.options.showsTime) {
shiftedValue = moment.utc(value).add(this.timeOffset, 'seconds');
} else {
dateFormat = this.shiftedValue() ? this.outputDateFormat : this.inputDateFormat;
@@ -115,7 +116,7 @@ define([
shiftedValue = moment(value, dateFormat);
}
- shiftedValue = shiftedValue.format(this.datetimeFormat);
+ shiftedValue = shiftedValue.format(this.pickerDateTimeFormat);
} else {
shiftedValue = '';
}
@@ -135,12 +136,11 @@ define([
var value;
if (shiftedValue) {
-
- if (this.showsTime) {
- value = moment.utc(shiftedValue, this.datetimeFormat);
+ if (this.options.showsTime) {
+ value = moment.utc(shiftedValue, this.pickerDateTimeFormat);
value = value.subtract(this.timeOffset, 'seconds').toISOString();
} else {
- value = moment(shiftedValue, this.datetimeFormat);
+ value = moment(shiftedValue, this.pickerDateTimeFormat);
value = value.format(this.outputDateFormat);
}
} else {
@@ -156,17 +156,22 @@ define([
* Prepares and converts all date/time formats to be compatible
* with moment.js library.
*/
- prepareDatetimeFormats: function () {
- this.datetimeFormat = this.dateFormat;
+ prepareDateTimeFormats: function () {
+ this.pickerDateTimeFormat = this.options.dateFormat;
- if (this.showsTime) {
- this.datetimeFormat += ' ' + this.timeFormat;
+ if (this.options.showsTime) {
+ this.pickerDateTimeFormat += ' ' + this.options.timeFormat;
}
- this.datetimeFormat = utils.normalizeDate(this.datetimeFormat);
+ this.pickerDateTimeFormat = utils.normalizeDate(this.pickerDateTimeFormat);
+
+ if (this.dateFormat) {
+ this.inputDateFormat = this.dateFormat;
+ }
this.inputDateFormat = utils.normalizeDate(this.inputDateFormat);
this.outputDateFormat = utils.normalizeDate(this.outputDateFormat);
+
this.validationParams.dateFormat = this.outputDateFormat;
}
});
diff --git a/app/code/Magento/Ui/view/base/web/js/grid/massactions.js b/app/code/Magento/Ui/view/base/web/js/grid/massactions.js
index 70371ff2ac955..fda02be219b58 100644
--- a/app/code/Magento/Ui/view/base/web/js/grid/massactions.js
+++ b/app/code/Magento/Ui/view/base/web/js/grid/massactions.js
@@ -147,7 +147,7 @@ define([
* @param {Object} data - Selections data.
*/
defaultCallback: function (action, data) {
- var itemsType = data.excludeMode && data.excluded.length !== 0 ? 'excluded' : 'selected',
+ var itemsType = data.excludeMode ? 'excluded' : 'selected',
selections = {};
selections[itemsType] = data[itemsType];