Skip to content

Commit 49e0c57

Browse files
committed
PB-108 disable remove button for the last remaining column in a column group
1 parent ff2842c commit 49e0c57

File tree

2 files changed

+23
-12
lines changed
  • app/code/Magento/PageBuilder/view/adminhtml/web

2 files changed

+23
-12
lines changed

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

Lines changed: 10 additions & 5 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/column/preview.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export default class Preview extends PreviewCollection {
9595
this.resetRemoveOnLastColumn(args.sourceParent);
9696
});
9797
events.on("column:initializeAfter", (args: InitElementEventParamsInterface) => {
98-
this.resetRemoveOnLastColumn(args.columnGroup);
98+
this.resetRemoveOnLastColumn(args.columnLine);
9999
});
100100
events.on("column:dropAfter", (args: ContentTypeDroppedCreateEventParamsInterface) => {
101101
this.resetRemoveOnLastColumn(this.contentType.parentContentType);
@@ -308,19 +308,25 @@ export default class Preview extends PreviewCollection {
308308
return;
309309
}
310310
const siblings = parentContentType.children();
311-
if (siblings.length < 1) {
311+
const siblingColumnLines = parentContentType.parentContentType.children();
312+
if (siblings.length < 1 ) {
312313
return;
313314
}
314-
if (siblings.length === 1) {
315+
if (siblings.length === 1 && siblingColumnLines.length === 1) {
315316
const lastColumn = siblings[0];
316317
const options = lastColumn.preview.getOptions();
317318
options.getOption("remove").isDisabled(true);
318319
return;
319320
}
320-
siblings.forEach((column) => {
321-
const removeOption = column.preview.getOptions().getOption("remove");
322-
removeOption.isDisabled(false);
323-
});
321+
debugger;
322+
siblingColumnLines.forEach((columnLine) => {
323+
let columns = columnLine.children();
324+
columns.forEach((column : ContentTypeCollectionInterface) => {
325+
const removeOption = column.preview.getOptions().getOption("remove");
326+
removeOption.isDisabled(false);
327+
});
328+
})
329+
324330
}
325331

326332
/**

0 commit comments

Comments
 (0)