Skip to content

Commit a7432e4

Browse files
author
Hwashiang Yu
committed
Merge remote-tracking branch 'origin/MC-17806' into borg-pr-2.3.3-develop
2 parents 6f9e063 + 64421d8 commit a7432e4

File tree

6 files changed

+48
-16
lines changed

6 files changed

+48
-16
lines changed

app/code/Magento/Store/Model/System/Store.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public function getStoreValuesForForm($empty = false, $all = false)
118118
$options[] = ['label' => __('All Store Views'), 'value' => 0];
119119
}
120120

121+
//phpcs:ignore Magento2.Functions.DiscouragedFunction
121122
$nonEscapableNbspChar = html_entity_decode(' ', ENT_NOQUOTES, 'UTF-8');
122123

123124
foreach ($this->_websiteCollection as $website) {
@@ -152,6 +153,12 @@ public function getStoreValuesForForm($empty = false, $all = false)
152153
}
153154
}
154155
}
156+
array_walk(
157+
$options,
158+
function (&$item) {
159+
$item['__disableTmpl'] = true;
160+
}
161+
);
155162
return $options;
156163
}
157164

@@ -398,6 +405,7 @@ public function getStoreCollection()
398405

399406
/**
400407
* Load/Reload collection(s) by type
408+
*
401409
* Allowed types: website, group, store or null for all
402410
*
403411
* @param string $type

app/code/Magento/Store/Test/Unit/Model/System/StoreTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
namespace Magento\Store\Test\Unit\Model\System;
88

9+
/**
10+
* Class StoreTest covers Magento\Store\Model\System\Store.
11+
*/
912
class StoreTest extends \PHPUnit\Framework\TestCase
1013
{
1114
/**
@@ -262,14 +265,15 @@ public function getStoreValuesForFormDataProvider()
262265
'storeGroupId' => $groupId,
263266
'groupWebsiteId' => $websiteId,
264267
'expectedResult' => [
265-
['label' => '', 'value' => ''],
266-
['label' => __('All Store Views'), 'value' => 0],
267-
['label' => $websiteName, 'value' => []],
268+
['label' => '', 'value' => '','__disableTmpl' => true],
269+
['label' => __('All Store Views'), 'value' => 0,'__disableTmpl' => true],
270+
['label' => $websiteName, 'value' => [],'__disableTmpl' => true],
268271
[
269272
'label' => str_repeat($nonEscapableNbspChar, 4) . $groupName,
270273
'value' => [
271274
['label' => str_repeat($nonEscapableNbspChar, 4) . $storeName, 'value' => $storeId]
272-
]
275+
],
276+
'__disableTmpl' => true
273277
],
274278
]
275279
],

app/code/Magento/Ui/view/base/web/js/grid/editing/record.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ define([
134134

135135
field = utils.extend({}, fields.base, field);
136136

137+
field.__disableTmpl = {
138+
label: true,
139+
options: true
140+
};
141+
137142
return utils.template(field, {
138143
record: this,
139144
column: column

app/code/Magento/Ui/view/base/web/js/lib/knockout/bindings/optgroup.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,14 @@ define([
222222
ko.utils.setTextContent(option, allBindings.get('optionsCaption'));
223223
ko.selectExtensions.writeValue(option, undefined);
224224
} else if (typeof arrayEntry[optionsValue] === 'undefined') { // empty value === optgroup
225-
option = utils.template(optgroupTmpl, {
226-
label: arrayEntry[optionsText],
227-
title: arrayEntry[optionsText + 'title']
228-
});
225+
if (arrayEntry.__disableTmpl) {
226+
option = '<optgroup label="' + arrayEntry[optionsText] + '"></optgroup>';
227+
} else {
228+
option = utils.template(optgroupTmpl, {
229+
label: arrayEntry[optionsText],
230+
title: arrayEntry[optionsText + 'title']
231+
});
232+
}
229233
option = ko.utils.parseHtmlFragment(option)[0];
230234

231235
} else {
@@ -307,6 +311,10 @@ define([
307311
obj.disabled = disabled;
308312
}
309313

314+
if (option.hasOwnProperty('__disableTmpl')) {
315+
obj.__disableTmpl = option.__disableTmpl;
316+
}
317+
310318
label = label.replace(nbspRe, '').trim();
311319

312320
if (Array.isArray(value)) {

dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Catalog/Edit/FormTest.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ public function testGetEntityStoresCategoryStoresException()
190190
*
191191
* @static
192192
* @return array
193+
* phpcs:disable Magento2.Functions.StaticFunction
193194
*/
194195
public static function formPostInitDataProvider()
195196
{
@@ -226,6 +227,7 @@ public static function formPostInitDataProvider()
226227
*
227228
* @static
228229
* @return array
230+
* phpcs:disable Magento2.Functions.StaticFunction
229231
*/
230232
public static function getEntityStoresDataProvider()
231233
{
@@ -234,32 +236,35 @@ public static function getEntityStoresDataProvider()
234236
null,
235237
['entity_id' => 3, 'store_ids' => [1]],
236238
[
237-
['label' => 'Main Website', 'value' => []],
239+
['label' => 'Main Website', 'value' => [], '__disableTmpl' => true],
238240
[
239241
'label' => '    Main Website Store',
240-
'value' => [['label' => '    Default Store View', 'value' => 1]]
242+
'value' => [['label' => '    Default Store View', 'value' => 1]],
243+
'__disableTmpl' => true
241244
]
242245
],
243246
],
244247
[
245248
['entity_id' => 2, 'name' => 'product2', 'url_key' => 'product2', 'store_ids' => [1]],
246249
null,
247250
[
248-
['label' => 'Main Website', 'value' => []],
251+
['label' => 'Main Website', 'value' => [], '__disableTmpl' => true],
249252
[
250253
'label' => '    Main Website Store',
251-
'value' => [['label' => '    Default Store View', 'value' => 1]]
254+
'value' => [['label' => '    Default Store View', 'value' => 1]],
255+
'__disableTmpl' => true
252256
]
253257
]
254258
],
255259
[
256260
['entity_id' => 2, 'name' => 'product2', 'url_key' => 'product2', 'store_ids' => [1]],
257261
['entity_id' => 3, 'name' => 'product3', 'url_key' => 'product3', 'store_ids' => [1]],
258262
[
259-
['label' => 'Main Website', 'value' => []],
263+
['label' => 'Main Website', 'value' => [], '__disableTmpl' => true],
260264
[
261265
'label' => '    Main Website Store',
262-
'value' => [['label' => '    Default Store View', 'value' => 1]]
266+
'value' => [['label' => '    Default Store View', 'value' => 1]],
267+
'__disableTmpl' => true
263268
]
264269
]
265270
]

dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Cms/Page/Edit/FormTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,11 @@ public function testGetEntityStores()
7878
$form = $this->_getFormInstance($args);
7979

8080
$expectedStores = [
81-
['label' => 'Main Website', 'value' => []],
81+
['label' => 'Main Website', 'value' => [], '__disableTmpl' => true],
8282
[
8383
'label' => '    Main Website Store',
84-
'value' => [['label' => '    Default Store View', 'value' => 1]]
84+
'value' => [['label' => '    Default Store View', 'value' => 1]],
85+
'__disableTmpl' => true
8586
],
8687
];
8788
$this->assertEquals($expectedStores, $form->getElement('store_id')->getValues());
@@ -110,6 +111,7 @@ public function testGetEntityStoresProductStoresException()
110111
*
111112
* @static
112113
* @return array
114+
* phpcs:disable Magento2.Functions.StaticFunction
113115
*/
114116
public static function formPostInitDataProvider()
115117
{

0 commit comments

Comments
 (0)