Skip to content

Commit 42f1137

Browse files
committed
MC-5423: Scheduled Update slide out issues
- Restrict drag and drop operations to individual stage instances
1 parent 5a08db0 commit 42f1137

File tree

12 files changed

+62
-36
lines changed

12 files changed

+62
-36
lines changed

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

Lines changed: 3 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/matrix.js

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

Lines changed: 8 additions & 7 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/group.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/js/panel/group/content-type.js

Lines changed: 4 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/ts/js/drag-drop/drop-indicators.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ let headDropIndicatorStyles: HTMLStyleElement;
1414
* CSS engine to display these for us than manually iterating through the DOM and applying a class to the elements.
1515
*
1616
* @param {string} contentType
17+
* @param {string} stageId
1718
* @returns {HTMLStyleElement}
1819
*/
19-
export function showDropIndicators(contentType: string) {
20+
export function showDropIndicators(contentType: string, stageId: string) {
2021
const acceptedContainers = getContainersFor(contentType);
2122
if (acceptedContainers.length > 0) {
2223
const classNames = acceptedContainers.map((container: string) => {
23-
return ".content-type-container." + container + "-container > .pagebuilder-drop-indicator, " +
24-
".pagebuilder-content-type.type-container.empty-container > .content-type-container." +
25-
container + "-container:before";
24+
return `#${stageId} .content-type-container.${container}-container > .pagebuilder-drop-indicator, ` +
25+
`#${stageId} .pagebuilder-content-type.type-container.empty-container > .content-type-container.` +
26+
`${container}-container:before`;
2627
});
2728
const styles = createStyleSheet({
2829
[classNames.join(", ")]: {

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@ export function getContainersFor(contentType: string): string[] {
3737
* Generate classes of containers the content type is allowed within
3838
*
3939
* @param {string} contentType
40+
* @param {string} stageId
4041
* @returns {string}
4142
*/
42-
export function getAllowedContainersClasses(contentType: string) {
43+
export function getAllowedContainersClasses(contentType: string, stageId: string) {
44+
console.log(getContainersFor(contentType)
45+
.map((value) => `#${stageId} .content-type-container.${value}-container`).join(", "));
4346
return getContainersFor(contentType)
44-
.map((value) => ".content-type-container." + value + "-container").join(", ");
47+
.map((value) => `#${stageId} .content-type-container.${value}-container`).join(", ");
4548
}

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,18 @@ function onSortStart(preview: Preview, event: Event, ui: JQueryUI.SortableUIPara
120120
ui.item.prev(".pagebuilder-drop-indicator").css("display", "none").addClass("hidden-drop-indicator");
121121
}
122122

123-
showDropIndicators(contentTypeInstance.config.name);
123+
showDropIndicators(contentTypeInstance.config.name, preview.parent.stageId);
124124

125125
sortedContentType = contentTypeInstance;
126126

127127
// Dynamically change the connect with option to restrict content types
128-
$(this).sortable("option", "connectWith", getAllowedContainersClasses(contentTypeInstance.config.name));
128+
$(this).sortable(
129+
"option", "connectWith",
130+
getAllowedContainersClasses(
131+
contentTypeInstance.config.name,
132+
preview.parent.stageId
133+
)
134+
);
129135
$(this).sortable("refresh");
130136
}
131137
}

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export default class Panel implements PanelInterface {
102102
),
103103
(contentType, identifier: string) => {
104104
// Create a new instance of GroupContentType for each result
105-
return new GroupContentType(identifier, contentType);
105+
return new GroupContentType(identifier, contentType, this.parent.stage.id);
106106
}),
107107
);
108108
}
@@ -216,7 +216,7 @@ export default class Panel implements PanelInterface {
216216
$(this).sortable("option", "tolerance", "intersect");
217217
}
218218
});
219-
showDropIndicators(block.config.name);
219+
showDropIndicators(block.config.name, self.parent.stage.id);
220220
setDraggedContentTypeConfig(block.config);
221221
events.trigger("stage:interactionStart", {stage: self.parent.stage});
222222
}
@@ -255,10 +255,14 @@ export default class Panel implements PanelInterface {
255255
is_visible: true,
256256
}), /* Retrieve content types with group id */
257257
(contentType: ContentTypeConfigInterface, identifier: string) => {
258-
const groupContentType = new GroupContentType(identifier, contentType);
259-
return groupContentType;
258+
return new GroupContentType(
259+
identifier,
260+
contentType,
261+
this.parent.stage.id
262+
);
260263
},
261264
),
265+
this.parent.stage.id
262266
));
263267
});
264268

@@ -271,7 +275,7 @@ export default class Panel implements PanelInterface {
271275
}
272276

273277
} else {
274-
console.warn( "Configuration is not properly initialized, please check the Ajax response." );
278+
console.warn("Configuration is not properly initialized, please check the Ajax response.");
275279
}
276280
}
277281
}

0 commit comments

Comments
 (0)