Skip to content

Commit 5834bc3

Browse files
committed
Merge remote-tracking branch 'origin/1.2.0-release' into PB-290
2 parents fa85d1a + 19b0dc9 commit 5834bc3

File tree

10 files changed

+146
-89
lines changed

10 files changed

+146
-89
lines changed

app/code/Magento/PageBuilder/Model/Wysiwyg/DefaultConfigProvider.php

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -39,41 +39,43 @@ public function __construct(
3939
*/
4040
public function getConfig(\Magento\Framework\DataObject $config): \Magento\Framework\DataObject
4141
{
42-
$config->addData([
43-
'tinymce4' => [
44-
'toolbar' => 'undo redo | styleselect | fontsizeselect | lineheightselect | forecolor backcolor ' .
45-
'| bold italic underline | alignleft aligncenter alignright | numlist bullist ' .
46-
'| link image table charmap',
42+
$config->addData(
43+
[
44+
'tinymce4' => [
45+
'toolbar' => 'undo redo | styleselect | fontsizeselect | lineheightselect | forecolor backcolor ' .
46+
'| bold italic underline | alignleft aligncenter alignright | numlist bullist ' .
47+
'| link image table charmap',
4748

48-
'plugins' => implode(
49-
' ',
50-
[
51-
'advlist',
52-
'autolink',
53-
'lists',
54-
'link',
55-
'charmap',
56-
'media',
57-
'noneditable',
58-
'table',
59-
'contextmenu',
60-
'paste',
61-
'code',
62-
'help',
63-
'table',
64-
'textcolor',
65-
'image',
66-
'colorpicker',
67-
'lineheight'
49+
'plugins' => implode(
50+
' ',
51+
[
52+
'advlist',
53+
'autolink',
54+
'lists',
55+
'link',
56+
'charmap',
57+
'media',
58+
'noneditable',
59+
'table',
60+
'contextmenu',
61+
'paste',
62+
'code',
63+
'help',
64+
'table',
65+
'textcolor',
66+
'image',
67+
'colorpicker',
68+
'lineheight'
69+
]
70+
),
71+
'content_css' => [
72+
$this->assetRepo->getUrl('mage/adminhtml/wysiwyg/tiny_mce/themes/ui.css'),
73+
$this->assetRepo->getUrl('Magento_PageBuilder::css/source/form/element/tinymce.css')
6874
]
69-
),
70-
'content_css' => [
71-
$this->assetRepo->getUrl('mage/adminhtml/wysiwyg/tiny_mce/themes/ui.css'),
72-
$this->assetRepo->getUrl('Magento_PageBuilder/css/source/form/element/tinymce.css')
73-
]
74-
],
75-
'settings' => $this->additionalSettings
76-
]);
75+
],
76+
'settings' => $this->additionalSettings
77+
]
78+
);
7779
return $config;
7880
}
7981
}

app/code/Magento/PageBuilder/etc/adminhtml/di.xml

Lines changed: 35 additions & 35 deletions
Large diffs are not rendered by default.

app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/products/mass-converter/carousel-widget-directive.js

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/products/mass-converter/widget-directive.js

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/products/preview.js

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/content-type/products/mass-converter/carousel-widget-directive.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default class WidgetDirective extends BaseWidgetDirective {
2929

3030
data.carousel_products_count = attributes.products_count;
3131
data.sort_order = attributes.sort_order;
32-
data.condition_option = attributes.condition_option;
32+
data.condition_option = attributes.condition_option || "condition";
3333
data[data.condition_option] = this.decodeWysiwygCharacters(attributes.condition_option_value || "");
3434
data.conditions_encoded = this.decodeWysiwygCharacters(attributes.conditions_encoded || "");
3535
data[data.condition_option + "_source"] = data.conditions_encoded;
@@ -51,12 +51,15 @@ export default class WidgetDirective extends BaseWidgetDirective {
5151
id_path: "",
5252
show_pager: 0,
5353
products_count: data.carousel_products_count,
54-
sort_order: data.sort_order,
5554
condition_option: data.condition_option,
5655
condition_option_value: "",
5756
type_name: "Catalog Products Carousel",
5857
conditions_encoded: this.encodeWysiwygCharacters(data.conditions_encoded || ""),
59-
};
58+
} as { [key: string]: any; };
59+
60+
if (data.sort_order) {
61+
attributes.sort_order = data.sort_order
62+
}
6063

6164
if (typeof data[data.condition_option] === "string") {
6265
attributes.condition_option_value = this.encodeWysiwygCharacters(data[data.condition_option]);

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/content-type/products/mass-converter/widget-directive.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default class WidgetDirective extends BaseWidgetDirective {
2929

3030
data.products_count = attributes.products_count;
3131
data.sort_order = attributes.sort_order;
32-
data.condition_option = attributes.condition_option;
32+
data.condition_option = attributes.condition_option || "condition";
3333
data[data.condition_option] = this.decodeWysiwygCharacters(attributes.condition_option_value || "");
3434
data.conditions_encoded = this.decodeWysiwygCharacters(attributes.conditions_encoded || "");
3535
data[data.condition_option + "_source"] = data.conditions_encoded;
@@ -51,12 +51,15 @@ export default class WidgetDirective extends BaseWidgetDirective {
5151
id_path: "",
5252
show_pager: 0,
5353
products_count: data.products_count,
54-
sort_order: data.sort_order,
5554
condition_option: data.condition_option,
5655
condition_option_value: "",
5756
type_name: "Catalog Products List",
58-
conditions_encoded: this.encodeWysiwygCharacters(data.conditions_encoded || ""),
59-
};
57+
conditions_encoded: this.encodeWysiwygCharacters(data.conditions_encoded || "")
58+
} as { [key: string]: any; };
59+
60+
if (data.sort_order) {
61+
attributes.sort_order = data.sort_order
62+
}
6063

6164
if (typeof data[data.condition_option] === "string") {
6265
attributes.condition_option_value = this.encodeWysiwygCharacters(data[data.condition_option]);

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/content-type/products/preview.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,12 @@ export default class Preview extends BasePreview {
6767

6868
// Redraw slider after content type gets redrawn
6969
events.on("contentType:redrawAfter", (args: ContentTypeAfterRenderEventParamsInterface) => {
70-
const $element = $(this.element.children);
70+
if (this.element && this.element.children) {
71+
const $element = $(this.element.children);
7172

72-
if (args.element && this.element && $element.closest(args.element).length) {
73-
$element.slick("setPosition");
73+
if (args.element && $element.closest(args.element).length) {
74+
$element.slick("setPosition");
75+
}
7476
}
7577
});
7678
}

dev/tests/js/jasmine/tests/app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/products/mass-converter/carousel-widget-directive.test.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ define([
6969
it('Should transform regular properties', function () {
7070
var data = {
7171
carousel_products_count: 123,
72-
conditions_encoded: '[]'
72+
conditions_encoded: '[]',
73+
condition_option: 'condition',
74+
sort_order: 'position'
7375
},
7476
config = {
7577
html_variable: 'myhtml'
@@ -86,6 +88,9 @@ define([
8688
expect(result.myhtml).toContain(' id_path=""');
8789
expect(result.myhtml).toContain(' show_pager="0"');
8890
expect(result.myhtml).toContain(' type_name="Catalog Products Carousel"');
91+
expect(result.myhtml).toContain(' condition_option="condition');
92+
expect(result.myhtml).toContain(' sort_order="position');
93+
expect(result.myhtml).toContain(' condition_option_value=""');
8994
});
9095
it('Should encode conditions_encoded', function () {
9196
var data = {
@@ -107,12 +112,25 @@ define([
107112
expect(result.myhtml).toContain(' show_pager="0"');
108113
expect(result.myhtml).toContain(' type_name="Catalog Products Carousel"');
109114
});
115+
it('Should not add empty sort_order attribute', function () {
116+
var data = {
117+
carousel_products_count: 123,
118+
conditions_encoded: '[]'
119+
},
120+
config = {
121+
html_variable: 'myhtml'
122+
},
123+
result = model.toDom(data, config);
124+
125+
expect(result.myhtml).not.toContain('sort_order');
126+
});
110127
});
111128
describe('fromDom', function () {
112129
it('Should parse regular properties without conditions_encoded', function () {
113130
var expected = {
114131
carousel_products_count: '123',
115-
conditions_encoded: ''
132+
conditions_encoded: '',
133+
condition_option: 'condition'
116134
},
117135
config = {
118136
html_variable: 'myhtml'
@@ -124,6 +142,7 @@ define([
124142

125143
expect(result.carousel_products_count).toBe(expected.carousel_products_count);
126144
expect(result.conditions_encoded).toBe(expected.conditions_encoded);
145+
expect(result.condition_option).toBe(expected.condition_option);
127146
// assert the automatically added properties do not get returned.
128147
expect(result.type).toBe(undefined);
129148
expect(result.id_path).toBe(undefined);

dev/tests/js/jasmine/tests/app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/products/mass-converter/widget-directive.test.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ define([
6969
it('Should transform regular properties', function () {
7070
var data = {
7171
products_count: 123,
72-
conditions_encoded: '[]'
72+
conditions_encoded: '[]',
73+
condition_option: 'condition',
74+
sort_order: 'position'
7375
},
7476
config = {
7577
html_variable: 'myhtml'
@@ -85,6 +87,9 @@ define([
8587
expect(result.myhtml).toContain(' id_path=""');
8688
expect(result.myhtml).toContain(' show_pager="0"');
8789
expect(result.myhtml).toContain(' type_name="Catalog Products List"');
90+
expect(result.myhtml).toContain(' condition_option="condition');
91+
expect(result.myhtml).toContain(' sort_order="position');
92+
expect(result.myhtml).toContain(' condition_option_value=""');
8893
});
8994
it('Should encode conditions_encoded', function () {
9095
var data = {
@@ -105,12 +110,25 @@ define([
105110
expect(result.myhtml).toContain(' show_pager="0"');
106111
expect(result.myhtml).toContain(' type_name="Catalog Products List"');
107112
});
113+
it('Should not add empty sort_order attribute', function () {
114+
var data = {
115+
products_count: 123,
116+
conditions_encoded: '[]'
117+
},
118+
config = {
119+
html_variable: 'myhtml'
120+
},
121+
result = model.toDom(data, config);
122+
123+
expect(result.myhtml).not.toContain('sort_order');
124+
});
108125
});
109126
describe('fromDom', function () {
110127
it('Should parse regular properties without conditions_encoded', function () {
111128
var expected = {
112129
products_count: '123',
113-
conditions_encoded: ''
130+
conditions_encoded: '',
131+
condition_option: 'condition'
114132
},
115133
config = {
116134
html_variable: 'myhtml'
@@ -122,6 +140,7 @@ define([
122140

123141
expect(result.products_count).toBe(expected.products_count);
124142
expect(result.conditions_encoded).toBe(expected.conditions_encoded);
143+
expect(result.condition_option).toBe(expected.condition_option);
125144
// assert the automatically added properties do not get returned.
126145
expect(result.type).toBe(undefined);
127146
expect(result.id_path).toBe(undefined);

0 commit comments

Comments
 (0)