Skip to content

Commit a395f00

Browse files
Lukasz Borowiecomiroshnichenko
authored andcommitted
#514: User sees content snapshot on Category Page in Admin Panel - Added accessibility for the page builder file and fixes for mftf tests
1 parent e3e1536 commit a395f00

File tree

7 files changed

+126
-49
lines changed

7 files changed

+126
-49
lines changed

app/code/Magento/PageBuilder/view/adminhtml/web/css/source/_page-builder.less

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
}
2828
}
2929

30-
.pagebuilder_content_snapshot {
30+
.pagebuilder-content-snapshot {
3131
.pagebuilder-header {
3232
display: none;
3333

@@ -58,7 +58,7 @@
5858
pointer-events: none;
5959
}
6060

61-
&.pagebuilder_content_snapshot {
61+
&.pagebuilder-content-snapshot {
6262
&.stage-full-screen {
6363
.pagebuilder-header {
6464
display: block;
@@ -307,7 +307,7 @@
307307
}
308308
}
309309

310-
.pagebuilder_content_snapshot {
310+
.pagebuilder-content-snapshot {
311311
.pagebuilder-stage {
312312
-moz-transition: none;
313313
-webkit-transition: none;

app/code/Magento/PageBuilder/view/adminhtml/web/js/config.js

Lines changed: 11 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/js/page-builder.js

Lines changed: 37 additions & 10 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/template/form/element/uploader/preview/image.html

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,31 @@
55
*/
66
-->
77
<div class="pagebuilder-image-uploader-container" data-role="drop-zone" css="_loading: isLoading, 'has-data': hasData()">
8-
<div class="pagebuilder-options" data-bind="visible: hasData() || isShowImageUploadOptions">
9-
<div class="pagebuilder-options-wrapper">
10-
<ul class="pagebuilder-options-links">
11-
<li class="pagebuilder-options-link">
12-
<label
13-
data-bind="event: {mousedown: stopEvent}"
14-
class="file-uploader-button action-default"
15-
attr="for: uid"
16-
disable="disabled"
17-
translate="translations.uploadNewImage"/>
18-
</li>
19-
<li class="pagebuilder-options-link">
20-
<label
21-
data-bind="event: {change: addFileFromMediaGallery, click: openMediaBrowserDialog, mousedown: stopEvent}"
22-
class="file-uploader-button action-default"
23-
attr="id: mediaGalleryUid, 'data-id': getFileId()"
24-
disable="disabled"
25-
data-force_static_path="1"
26-
translate="translations.selectFromGallery"/>
27-
</li>
28-
</ul>
8+
<if args="$parent.accessibility()">
9+
<div class="pagebuilder-options" data-bind="visible: hasData() || isShowImageUploadOptions">
10+
<div class="pagebuilder-options-wrapper">
11+
<ul class="pagebuilder-options-links">
12+
<li class="pagebuilder-options-link">
13+
<label
14+
data-bind="event: {mousedown: stopEvent}"
15+
class="file-uploader-button action-default"
16+
attr="for: uid"
17+
disable="disabled"
18+
translate="translations.uploadNewImage"/>
19+
</li>
20+
<li class="pagebuilder-options-link">
21+
<label
22+
data-bind="event: {change: addFileFromMediaGallery, click: openMediaBrowserDialog, mousedown: stopEvent}"
23+
class="file-uploader-button action-default"
24+
attr="id: mediaGalleryUid, 'data-id': getFileId()"
25+
disable="disabled"
26+
data-force_static_path="1"
27+
translate="translations.selectFromGallery"/>
28+
</li>
29+
</ul>
30+
</div>
2931
</div>
30-
</div>
32+
</if>
3133
<div class="file-uploader-spinner"></div>
3234
<div class="preview-image-container-loading-overlay"></div>
3335
<if args="$parent.accessibility()">

app/code/Magento/PageBuilder/view/adminhtml/web/template/page-builder.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@
55
*/
66
-->
77
<div class="pagebuilder-stage-wrapper"
8-
css="'stage-full-screen': isFullScreen,'pagebuilder_content_snapshot': !panel.isVisible()"
8+
css="'stage-full-screen': isFullScreen, 'pagebuilder-content-snapshot': !isFullScreen() && getContentSnapshotMode()"
99
ko-style="wrapperStyles">
10-
<div class="admin__field pagebuilder-header" css="visible: panel.isVisible()">
10+
<div class="admin__field pagebuilder-header"
11+
css="visible: panel.isVisible()"
12+
if="(isFullScreen() && getContentSnapshotMode()) || !getContentSnapshotMode()">
1113
<button type="button" translate="'Apply Template'" if="isAllowedTemplateApply" click="toggleTemplateManger"/>
1214
<button type="button" translate="'Save as Template'" if="isAllowedTemplateSave" click="saveAsTemplate"/>
1315
<i click="function() { toggleFullScreen($element); }"
1416
css="'icon-pagebuilder-fullscreen': !isFullScreen(), 'icon-pagebuilder-fullscreen-exit': isFullScreen()"
1517
attr="{title: isFullScreen() ? $t('Close Full Screen') : $t('Open in Full Screen')}">
1618
</i>
1719
</div>
18-
<with args="panel">
20+
<with args="panel" if="(isFullScreen() && getContentSnapshotMode()) || !getContentSnapshotMode()">
1921
<render/>
2022
</with>
21-
<if args="isStageReady">
23+
<if args="isStageReady && accessibility()">
2224
<with args="stage">
2325
<render/>
2426
</with>

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ export default class Config {
5656
Config.contentSnapshot.isFullScreen = flag;
5757
}
5858

59+
/**
60+
* Set the content snapshot page builder id
61+
*
62+
* @param id
63+
*/
64+
public static setContentSnapshotPageBuilderId(id: string): void
65+
{
66+
Config.contentSnapshot.pageBuilderId = id;
67+
}
68+
5969
/**
6070
* Retrieve the current instances mode
6171
*/

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/page-builder.ts

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export default class PageBuilder implements PageBuilderInterface {
3131
public initialValue: string;
3232
public id: string = utils.uniqueid();
3333
public originalScrollTop: number = 0;
34-
public isContentSnapshotMode = false;
3534
public isFullScreen: KnockoutObservable<boolean> = ko.observable(false);
35+
public accessibility: KnockoutObservable<boolean> = ko.observable(true);
3636
public loading: KnockoutObservable<boolean> = ko.observable(true);
3737
public wrapperStyles: KnockoutObservable<{[key: string]: string}> = ko.observable({});
3838
public isAllowedTemplateSave: boolean;
@@ -70,10 +70,6 @@ export default class PageBuilder implements PageBuilderInterface {
7070

7171
this.panel = new Panel(this);
7272

73-
if (Config.getContentSnapshot().contentSnapshotMode) {
74-
this.panel.isVisible(false);
75-
}
76-
7773
this.initListeners();
7874
}
7975

@@ -89,9 +85,18 @@ export default class PageBuilder implements PageBuilderInterface {
8985
*/
9086
public initListeners() {
9187
events.on(`stage:${ this.id }:toggleFullscreen`, this.toggleFullScreen.bind(this));
88+
events.on(`stage:accessibilityChangeAfter`, this.toggleAccessibility.bind(this));
9289
this.isFullScreen.subscribe(() => this.onFullScreenChange());
9390
}
9491

92+
/**
93+
* Get content snapshot mode
94+
*/
95+
public getContentSnapshotMode(): boolean
96+
{
97+
return Config.getContentSnapshot().contentSnapshotMode;
98+
}
99+
95100
/**
96101
* Tells the stage wrapper to expand to fullScreen
97102
*
@@ -139,7 +144,7 @@ export default class PageBuilder implements PageBuilderInterface {
139144
// When leaving full screen mode just transition back to the original state
140145
this.wrapperStyles(this.previousWrapperStyles);
141146
this.isFullScreen(false);
142-
if (!this.isContentSnapshotMode) {
147+
if (!Config.getContentSnapshot().contentSnapshotMode) {
143148
panel.css("height", this.previousPanelHeight + "px");
144149
// Wait for the 350ms animation to complete before changing these properties back
145150
_.delay(() => {
@@ -157,6 +162,18 @@ export default class PageBuilder implements PageBuilderInterface {
157162
}
158163
}
159164

165+
/**
166+
* Sets stage accessibility for the content snapshot mode
167+
* @param args
168+
*/
169+
public toggleAccessibility(args: any): void {
170+
if ((args.activePageBuilderId === this.id && this.isFullScreen()) || (!args.activeFullScreen)) {
171+
this.accessibility(true);
172+
} else {
173+
this.accessibility(false);
174+
}
175+
}
176+
160177
/**
161178
* Change window scroll base on full screen mode.
162179
*/
@@ -167,7 +184,18 @@ export default class PageBuilder implements PageBuilderInterface {
167184
$("body").css("overflow", "");
168185
}
169186

170-
events.trigger(`stage:${ this.id }:fullScreenModeChangeAfter`, {
187+
if (Config.getContentSnapshot().contentSnapshotMode) {
188+
189+
Config.setContentSnapshotPageBuilderId(this.id);
190+
Config.setContentSnapshotFullScreenMode(this.isFullScreen());
191+
192+
events.trigger(`stage:accessibilityChangeAfter`, {
193+
activePageBuilderId: this.id,
194+
activeFullScreen: this.isFullScreen(),
195+
});
196+
}
197+
198+
events.trigger(`stage:${this.id}:fullScreenModeChangeAfter`, {
171199
fullScreen: this.isFullScreen(),
172200
});
173201
}

0 commit comments

Comments
 (0)