Skip to content

Commit f4beaf8

Browse files
author
Lukasz Borowiec
committed
#514: User sees content snapshot on Category Page in Admin Panel - #3 Added content snapshot only for category page
1 parent 7e6078e commit f4beaf8

File tree

7 files changed

+126
-32
lines changed

7 files changed

+126
-32
lines changed

app/code/Magento/PageBuilder/view/adminhtml/web/js/form/element/wysiwyg.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,12 @@ define([
9393
selector: this.stageSelector
9494
}, this.disableDomObserver.bind(this));
9595

96-
if (!this.wysiwygConfigData()['pagebuilder_button'] ||
97-
this.wysiwygConfigData()['pagebuilder_content_snapshot']) {
96+
if (!this.wysiwygConfigData()['pagebuilder_button']) {
97+
this.visiblePageBuilder(true);
98+
}
99+
100+
if (this.wysiwygConfigData()['pagebuilder_content_snapshot']) {
101+
this.pageBuilder.setContentSnapshotMode(true);
98102
this.visiblePageBuilder(true);
99103
}
100104
}

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

Lines changed: 57 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/js/panel.js

Lines changed: 3 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/template/page-builder.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<div class="pagebuilder-stage-wrapper"
88
css="'stage-full-screen': isFullScreen"
99
ko-style="wrapperStyles">
10-
<div class="admin__field pagebuilder-header" css="visible: isFullScreen">
10+
<div class="admin__field pagebuilder-header" css="visible: !panel.isContentSnapshotMode()">
1111
<button type="button" translate="'Apply Template'" if="isAllowedTemplateApply" click="toggleTemplateManger"/>
1212
<button type="button" translate="'Save as Template'" if="isAllowedTemplateSave" click="saveAsTemplate"/>
1313
<i click="function() { toggleFullScreen($element); }"
@@ -24,5 +24,7 @@
2424
</with>
2525
<iframe width="1" height="1" attr="id: 'render_frame_' + id" sandbox="allow-scripts" style="display: none;"></iframe>
2626
</if>
27-
<div class="page-builder-stage-cover-div" css="'stage-full-screen': isFullScreen"></div>
27+
<if args="isContentSnapshotMode">
28+
<div class="page-builder-stage-cover-div" css="'stage-full-screen': isFullScreen"></div>
29+
</if>
2830
</div>

app/code/Magento/PageBuilder/view/adminhtml/web/template/panel.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<div id="pagebuilder-panel-wrapper" class="pagebuilder-panel-wrapper"
99
css="visible: isVisible, 'sticky-top': isStickyTop, 'sticky-bottom': isStickyBottom"
1010
afterRender="afterRender">
11-
<div id="pagebuilder-panel" class="pagebuilder-panel" visible="isFullScreenMode()">
11+
<div id="pagebuilder-panel" class="pagebuilder-panel" visible="!isContentSnapshotMode()">
1212
<div class="search-content-types">
1313
<label for="search-content-types-input"></label>
1414
<a href="" class="close" click="clearSearch" attr="title: searchTitle" visible="searching"></a>

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

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ 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;
3435
public isFullScreen: KnockoutObservable<boolean> = ko.observable(false);
3536
public loading: KnockoutObservable<boolean> = ko.observable(true);
3637
public wrapperStyles: KnockoutObservable<{[key: string]: string}> = ko.observable({});
@@ -85,24 +86,35 @@ export default class PageBuilder implements PageBuilderInterface {
8586
* @param {StageToggleFullScreenParamsInterface} args
8687
*/
8788
public toggleFullScreen(args: StageToggleFullScreenParamsInterface): void {
88-
if (args.animate === false) {
89-
if (!this.isFullScreen()) {
90-
this.isFullScreen(true);
91-
this.panel.setFullScreenMode(true);
92-
93-
} else {
94-
this.isFullScreen(false);
95-
this.panel.setFullScreenMode(false);
89+
if (this.isContentSnapshotMode) {
90+
if (args.animate === false) {
91+
if (!this.isFullScreen()) {
92+
this.isFullScreen(true);
93+
this.panel.setContentSnapshotMode(false);
94+
95+
} else {
96+
this.isFullScreen(false);
97+
this.panel.setContentSnapshotMode(true);
98+
}
99+
return;
100+
}
101+
} else {
102+
this.panel.setContentSnapshotMode(false);
103+
if (args.animate === false) {
104+
this.isFullScreen(!this.isFullScreen());
105+
return;
96106
}
97-
return;
98107
}
99108

100109
const stageWrapper = $("#" + this.stage.id).parent();
101110
const pageBuilderWrapper = stageWrapper.parents(".pagebuilder-wysiwyg-wrapper");
102111
const panel = stageWrapper.find(".pagebuilder-panel");
103112
if (!this.isFullScreen()) {
104113
pageBuilderWrapper.css("height", pageBuilderWrapper.outerHeight());
105-
this.panel.setFullScreenMode(false);
114+
if (this.isContentSnapshotMode) {
115+
this.panel.setContentSnapshotMode(true);
116+
}
117+
106118
this.previousPanelHeight = panel.outerHeight();
107119
panel.css("height", this.previousPanelHeight + "px");
108120
/**
@@ -134,7 +146,23 @@ export default class PageBuilder implements PageBuilderInterface {
134146
// When leaving full screen mode just transition back to the original state
135147
this.wrapperStyles(this.previousWrapperStyles);
136148
this.isFullScreen(false);
137-
this.panel.setFullScreenMode(false);
149+
if (!this.isContentSnapshotMode) {
150+
panel.css("height", this.previousPanelHeight + "px");
151+
// Wait for the 350ms animation to complete before changing these properties back
152+
_.delay(() => {
153+
panel.css("height", "");
154+
pageBuilderWrapper.css("height", "");
155+
this.wrapperStyles(Object.keys(this.previousWrapperStyles)
156+
.reduce((object: object, styleName: string) => {
157+
return Object.assign(object, {[styleName]: ""});
158+
}, {}),
159+
);
160+
this.previousWrapperStyles = {};
161+
this.previousPanelHeight = null;
162+
}, 350);
163+
} else {
164+
this.panel.setContentSnapshotMode(true);
165+
}
138166
}
139167
}
140168

@@ -153,6 +181,19 @@ export default class PageBuilder implements PageBuilderInterface {
153181
});
154182
}
155183

184+
/**
185+
* Set the content snapshot mode to show the page builder stage
186+
* when page builder is enabled
187+
* @param flag
188+
*/
189+
public setContentSnapshotMode(flag: boolean): void
190+
{
191+
this.isContentSnapshotMode = flag;
192+
if (this.isContentSnapshotMode) {
193+
this.panel.setContentSnapshotMode(true);
194+
}
195+
}
196+
156197
/**
157198
* Get template.
158199
*

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default class Panel {
2727
public searchResults: KnockoutObservableArray<any> = ko.observableArray([]);
2828
public isVisible: KnockoutObservable<boolean> = ko.observable(false);
2929
public isStickyBottom: KnockoutObservable<boolean> = ko.observable(false);
30-
public isFullScreenMode: KnockoutObservable<boolean> = ko.observable(false);
30+
public isContentSnapshotMode: KnockoutObservable<boolean> = ko.observable(false);
3131
public isStickyTop: KnockoutObservable<boolean> = ko.observable(false);
3232
public searching: KnockoutObservable<boolean> = ko.observable(false);
3333
public searchValue: KnockoutObservable<string> = ko.observable("");
@@ -58,8 +58,8 @@ export default class Panel {
5858
* Set full screen flag
5959
* @param flag
6060
*/
61-
public setFullScreenMode(flag: boolean): void {
62-
this.isFullScreenMode(flag);
61+
public setContentSnapshotMode(flag: boolean): void {
62+
this.isContentSnapshotMode(flag);
6363
}
6464

6565
/**

0 commit comments

Comments
 (0)