Skip to content

Commit 3b770f7

Browse files
author
Mike Weis
committed
Merge remote-tracking branch 'mainline/develop' into develop
2 parents 0d20774 + a5be15b commit 3b770f7

File tree

36 files changed

+505
-117
lines changed

36 files changed

+505
-117
lines changed

app/code/Magento/Backend/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
<argument name="storage" xsi:type="object">Magento\Backend\Model\Session\Quote\Storage</argument>
150150
</arguments>
151151
</type>
152-
<type name="Magento\Framework\Console\CommandList">
152+
<type name="Magento\Framework\Console\CommandListInterface">
153153
<arguments>
154154
<argument name="commands" xsi:type="array">
155155
<item name="cacheEnableCommand" xsi:type="object">Magento\Backend\Console\Command\CacheEnableCommand</item>

app/code/Magento/Bundle/view/base/web/js/price-bundle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ define([
180180
};
181181
});
182182

183-
$option.text(template(toTemplate));
183+
$option.html(template(toTemplate));
184184
});
185185
});
186186
},

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AbstractModifier.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Magento\Catalog\Ui\DataProvider\Product\Form\Modifier;
77

88
use Magento\Ui\DataProvider\Modifier\ModifierInterface;
9-
use Magento\Framework\Stdlib\ArrayManager;
9+
use Magento\Framework\Pricing\PriceCurrencyInterface;
1010

1111
/**
1212
* Class AbstractModifier
@@ -195,13 +195,24 @@ protected function getGroupCodeByField(array $meta, $field)
195195
}
196196

197197
/**
198-
* Format number to have only two decimals after delimiter
198+
* Format price to have only two decimals after delimiter
199199
*
200200
* @param mixed $value
201201
* @return string
202202
*/
203-
protected function formatFloat($value)
203+
protected function formatPrice($value)
204204
{
205-
return $value !== null ? number_format((float)$value, 2, '.', '') : '';
205+
return $value !== null ? number_format((float)$value, PriceCurrencyInterface::DEFAULT_PRECISION, '.', '') : '';
206+
}
207+
208+
/**
209+
* Strip excessive decimal digits from weight number
210+
*
211+
* @param mixed $value
212+
* @return string
213+
*/
214+
protected function formatWeight($value)
215+
{
216+
return (float)$value;
206217
}
207218
}

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,12 @@ public function modifyData(array $data)
156156

157157
/** @var \Magento\Catalog\Model\Product\Option $option */
158158
foreach ($productOptions as $index => $option) {
159-
$options[$index] = $this->formatFloatByPath(static::FIELD_PRICE_NAME, $option->getData());
159+
$options[$index] = $this->formatPriceByPath(static::FIELD_PRICE_NAME, $option->getData());
160160
$values = $option->getValues() ?: [];
161161

162162
/** @var \Magento\Catalog\Model\Product\Option $value */
163163
foreach ($values as $value) {
164-
$options[$index][static::GRID_TYPE_SELECT_NAME][] = $this->formatFloatByPath(
164+
$options[$index][static::GRID_TYPE_SELECT_NAME][] = $this->formatPriceByPath(
165165
static::FIELD_PRICE_NAME,
166166
$value->getData()
167167
);
@@ -188,12 +188,12 @@ public function modifyData(array $data)
188188
* @param array $data
189189
* @return array
190190
*/
191-
protected function formatFloatByPath($path, array $data)
191+
protected function formatPriceByPath($path, array $data)
192192
{
193193
$value = $this->arrayManager->get($path, $data);
194194

195195
if (is_numeric($value)) {
196-
$data = $this->arrayManager->replace($path, $data, $this->formatFloat($value));
196+
$data = $this->arrayManager->replace($path, $data, $this->formatPrice($value));
197197
}
198198

199199
return $data;

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ public function modifyData(array $data)
354354
foreach ($attributes as $attribute) {
355355
if (null !== ($attributeValue = $this->setupAttributeData($attribute))) {
356356
if ($attribute->getFrontendInput() === 'price' && is_scalar($attributeValue)) {
357-
$attributeValue = $this->formatFloat($attributeValue);
357+
$attributeValue = $this->formatPrice($attributeValue);
358358
}
359359
$data[$productId][self::DATA_SOURCE_DEFAULT][$attribute->getAttributeCode()] = $attributeValue;
360360
}

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct(
4242
*/
4343
public function modifyData(array $data)
4444
{
45-
$data = $this->customizeNumberFormat($data);
45+
$data = $this->customizeWeightFormat($data);
4646
$data = $this->customizeAdvancedPriceFormat($data);
4747
$modelId = $this->locator->getProduct()->getId();
4848

@@ -54,42 +54,29 @@ public function modifyData(array $data)
5454
}
5555

5656
/**
57-
* Customizing number fields
57+
* Customizing weight fields
5858
*
5959
* @param array $data
6060
* @return array
6161
*/
62-
protected function customizeNumberFormat(array $data)
62+
protected function customizeWeightFormat(array $data)
6363
{
6464
$model = $this->locator->getProduct();
6565
$modelId = $model->getId();
66-
$numberFields = [ProductAttributeInterface::CODE_WEIGHT];
66+
$weightFields = [ProductAttributeInterface::CODE_WEIGHT];
6767

68-
foreach ($numberFields as $fieldCode) {
68+
foreach ($weightFields as $fieldCode) {
6969
$path = $modelId . '/' . self::DATA_SOURCE_DEFAULT . '/' . $fieldCode;
70-
$number = (float)$this->arrayManager->get($path, $data);
7170
$data = $this->arrayManager->replace(
7271
$path,
7372
$data,
74-
$this->formatNumber($number)
73+
$this->formatWeight($this->arrayManager->get($path, $data))
7574
);
7675
}
7776

7877
return $data;
7978
}
8079

81-
/**
82-
* Formatting numeric field
83-
*
84-
* @param float $number
85-
* @param int $decimals
86-
* @return string
87-
*/
88-
protected function formatNumber($number, $decimals = 2)
89-
{
90-
return number_format($number, $decimals);
91-
}
92-
9380
/**
9481
* Customizing number fields for advanced price
9582
*
@@ -104,7 +91,7 @@ protected function customizeAdvancedPriceFormat(array $data)
10491
if (isset($data[$modelId][self::DATA_SOURCE_DEFAULT][$fieldCode])) {
10592
foreach ($data[$modelId][self::DATA_SOURCE_DEFAULT][$fieldCode] as &$value) {
10693
$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE] =
107-
$this->formatNumber($value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE]);
94+
$this->formatPrice($value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE]);
10895
$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY] =
10996
(int)$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY];
11097
}

app/code/Magento/Catalog/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@
499499
</argument>
500500
</arguments>
501501
</type>
502-
<type name="Magento\Framework\Console\CommandList">
502+
<type name="Magento\Framework\Console\CommandListInterface">
503503
<arguments>
504504
<argument name="commands" xsi:type="array">
505505
<item name="imagesResizeCommand" xsi:type="object">Magento\Catalog\Console\Command\ImagesResizeCommand</item>

app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_form.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
</argument>
2222
</arguments>
2323
<block class="Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery\Content" as="content">
24+
<arguments>
25+
<argument name="config" xsi:type="array">
26+
<item name="parentComponent" xsi:type="string">product_form.product_form.block_gallery.block_gallery</item>
27+
</argument>
28+
</arguments>
2429
<block class="Magento\ProductVideo\Block\Adminhtml\Product\Edit\NewVideo" name="new-video"
2530
template="Magento_ProductVideo::product/edit/slideout/form.phtml"/>
2631
</block>

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/helper/gallery.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ $formName = $block->getFormName();
1313
<div id="<?php echo $block->getHtmlId() ?>"
1414
class="gallery"
1515
data-mage-init='{"productGallery":{"template":"#<?php echo $block->getHtmlId() ?>-template"}}'
16+
data-parent-component="<?php echo $block->escapeHtml($block->getData('config/parentComponent')) ?>"
1617
data-images="<?php echo $block->escapeHtml($block->getImagesJson()) ?>"
1718
data-types="<?php echo $block->escapeHtml(
1819
$this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($block->getImageTypes())

app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ define([
77
'jquery',
88
'underscore',
99
'mage/template',
10+
'uiRegistry',
1011
'jquery/ui',
1112
'baseImage'
12-
], function ($, _, mageTemplate) {
13+
], function ($, _, mageTemplate, registry) {
1314
'use strict';
1415

1516
/**
@@ -53,6 +54,7 @@ define([
5354
_create: function () {
5455
this.options.types = this.options.types || this.element.data('types');
5556
this.options.images = this.options.images || this.element.data('images');
57+
this.options.parentComponent = this.options.parentComponent || this.element.data('parent-component');
5658

5759
this.imgTmpl = mageTemplate(this.element.find(this.options.template).html().trim());
5860

@@ -153,6 +155,19 @@ define([
153155
}).first();
154156
},
155157

158+
/**
159+
* Mark parent fieldset that content was updated
160+
*/
161+
_contentUpdated: function () {
162+
if (this.options.initialized && this.options.parentComponent) {
163+
registry.async(this.options.parentComponent)(
164+
function (parentComponent) {
165+
parentComponent.bubble('update', true);
166+
}
167+
);
168+
}
169+
},
170+
156171
/**
157172
* Add image
158173
* @param event
@@ -205,6 +220,7 @@ define([
205220
}, this));
206221

207222
this._updateImagesRoles();
223+
this._contentUpdated();
208224
},
209225

210226
/**
@@ -284,6 +300,8 @@ define([
284300
imageData.label;
285301

286302
$title.text(value);
303+
304+
this._contentUpdated();
287305
},
288306

289307
/**
@@ -297,6 +315,8 @@ define([
297315

298316
imageData.isRemoved = true;
299317
$imageContainer.addClass('removed').hide().find('.is-removed').val(1);
318+
319+
this._contentUpdated();
300320
},
301321

302322
/**
@@ -321,6 +341,7 @@ define([
321341
}
322342
this.element.find('.image-' + data.type).val(this.options.types[data.type].value || 'no_selection');
323343
this._updateImagesRoles();
344+
this._contentUpdated();
324345
},
325346

326347
/**
@@ -339,6 +360,8 @@ define([
339360
$(element).val(index);
340361
}
341362
}, this));
363+
364+
this._contentUpdated();
342365
},
343366

344367
/**
@@ -362,6 +385,8 @@ define([
362385
}
363386
this.element.trigger('resort');
364387
}
388+
389+
this._contentUpdated();
365390
}
366391
});
367392

@@ -572,6 +597,8 @@ define([
572597

573598
$imageContainer.find('[name*="disabled"]').val(disabled);
574599
imageData.disabled = disabled;
600+
601+
this._contentUpdated();
575602
},
576603

577604
/**

0 commit comments

Comments
 (0)