Skip to content

Commit 3689141

Browse files
committed
MC-3653: Can Drag & Drop Child Content Types Into Hidden Content Types
- Update variable naming - Add new variable for hidden class used by sortable
1 parent 90014b7 commit 3689141

File tree

8 files changed

+44
-30
lines changed

8 files changed

+44
-30
lines changed

app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type-menu/hide-show-option.js

Lines changed: 8 additions & 8 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/column-group/preview.js

Lines changed: 2 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/preview.js

Lines changed: 2 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/drag-drop/sortable.js

Lines changed: 11 additions & 4 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-menu/hide-show-option.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import OptionInterface from "./option.d";
1010

1111
export default class HideShowOption extends Option implements OptionInterface {
1212

13-
public static SHOW_TEXT = $t("Show");
14-
public static SHOW_ICON = "<i class='icon-pagebuilder-show'></i>";
13+
public static showText = $t("Show");
14+
public static showIcon = "<i class='icon-pagebuilder-show'></i>";
1515

16-
public static HIDE_TEXT = $t("Hide");
17-
public static HIDE_ICON = "<i class='icon-pagebuilder-hide'></i>";
16+
public static hideText = $t("Hide");
17+
public static hideIcon = "<i class='icon-pagebuilder-hide'></i>";
1818

1919
/**
2020
* @param {OptionConfigInterface} options
@@ -39,11 +39,11 @@ export default class HideShowOption extends Option implements OptionInterface {
3939
private onDisplayChange(state: DataObject) {
4040
const display: boolean = !!state.display;
4141
if (display) {
42-
this.icon(HideShowOption.HIDE_ICON);
43-
this.title(HideShowOption.HIDE_TEXT);
42+
this.icon(HideShowOption.hideIcon);
43+
this.title(HideShowOption.hideText);
4444
} else {
45-
this.icon(HideShowOption.SHOW_ICON);
46-
this.title(HideShowOption.SHOW_TEXT);
45+
this.icon(HideShowOption.showText);
46+
this.title(HideShowOption.showIcon);
4747
}
4848
}
4949
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {DataObject} from "../../data-store";
1616
import {animationTime} from "../../drag-drop/container-animation";
1717
import {moveContentType} from "../../drag-drop/move-content-type";
1818
import {getDraggedContentTypeConfig} from "../../drag-drop/registry";
19+
import {hiddenClass} from "../../drag-drop/sortable";
1920
import {createStyleSheet} from "../../utils/create-stylesheet";
2021
import {default as ColumnGroupPreview} from "../column-group/preview";
2122
import BindResizeHandleEventParamsInterface from "../column/bind-resize-handle-event-params";
@@ -542,7 +543,7 @@ export default class Preview extends PreviewCollection {
542543
private initMouseMove(group: JQuery): void {
543544
let intersects: boolean = false;
544545
$(document).on("mousemove touchmove", (event: JQueryEventObject) => {
545-
if (group.parents(".pagebuilder-content-type-hidden").length > 0) {
546+
if (group.parents(hiddenClass).length > 0) {
546547
return;
547548
}
548549

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,8 @@ export default class Preview {
420420
if (this.parent.config.is_hideable) {
421421
options.hideShow = new HideShowOption({
422422
preview: this,
423-
icon: HideShowOption.SHOW_ICON,
424-
title: HideShowOption.SHOW_TEXT,
423+
icon: HideShowOption.showIcon,
424+
title: HideShowOption.showText,
425425
action: this.onOptionVisibilityToggle,
426426
classes: ["hide-show-content-type"],
427427
sort: 40,

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/drag-drop/sortable.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ import {getAllowedContainersClasses} from "./matrix";
1616
import {moveContentType} from "./move-content-type";
1717
import {getDraggedContentTypeConfig, setDraggedContentTypeConfig} from "./registry";
1818

19+
/**
20+
* The class used when hiding a content type
21+
* @type {string}
22+
*/
23+
export const hiddenClass = ".pagebuilder-content-type-hidden";
24+
1925
/**
2026
* Return the sortable options for an instance which requires sorting / dropping functionality
2127
*
@@ -135,7 +141,7 @@ let placeholderContainer: Element;
135141
*/
136142
function onSort(preview: Preview, event: Event, ui: JQueryUI.SortableUIParams) {
137143
if ($(this).sortable("option", "disabled") ||
138-
ui.placeholder.parents(".pagebuilder-content-type-hidden").length > 0
144+
ui.placeholder.parents(hiddenClass).length > 0
139145
) {
140146
ui.placeholder.hide();
141147
} else {
@@ -189,7 +195,7 @@ function onSortReceive(preview: Preview, event: Event, ui: JQueryUI.SortableUIPa
189195
const contentTypeConfig = getDraggedContentTypeConfig();
190196
if (contentTypeConfig) {
191197
// If the sortable instance is disabled don't complete this operation
192-
if ($(this).sortable("option", "disabled") || $(this).parents(".pagebuilder-content-type-hidden").length > 0) {
198+
if ($(this).sortable("option", "disabled") || $(this).parents(hiddenClass).length > 0) {
193199
return;
194200
}
195201

@@ -238,7 +244,7 @@ function onSortReceive(preview: Preview, event: Event, ui: JQueryUI.SortableUIPa
238244
*/
239245
function onSortUpdate(preview: Preview, event: Event, ui: JQueryUI.SortableUIParams) {
240246
// If the sortable instance is disabled don't complete this operation
241-
if ($(this).sortable("option", "disabled") || ui.item.parents(".pagebuilder-content-type-hidden").length > 0) {
247+
if ($(this).sortable("option", "disabled") || ui.item.parents(hiddenClass).length > 0) {
242248
ui.item.remove();
243249
$(this).sortable("cancel");
244250

0 commit comments

Comments
 (0)