Skip to content

Commit b909ece

Browse files
committed
PB-108 static test fixes and fix to allow dropping column group between consecutive column groups
1 parent 5ed6464 commit b909ece

File tree

4 files changed

+75
-41
lines changed

4 files changed

+75
-41
lines changed

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

Lines changed: 25 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/content-type/column/preview.js

Lines changed: 7 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/ts/js/content-type/column-line/preview.ts

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,7 @@ export default class Preview extends PreviewCollection {
360360
}
361361

362362
// Move the content type
363-
if (this.columnLineDropPlaceholder.hasClass("active")
364-
|| this.columnLineBottomDropPlaceholder.hasClass("active")) {
363+
if (this.columnLineDropPlaceholder.hasClass("active")) {
365364
// if new column line placeholders are visible, add new column line and move column there
366365
createColumnLine(
367366
this.contentType.parentContentType,
@@ -377,7 +376,23 @@ export default class Preview extends PreviewCollection {
377376
this.fireMountEvent(this.contentType, column);
378377

379378
});
380-
} else {
379+
} else if (this.columnLineBottomDropPlaceholder.hasClass("active")) {
380+
// if new column line placeholders are visible, add new column line and move column there
381+
createColumnLine(
382+
this.contentType.parentContentType,
383+
this.resizeUtils.getSmallestColumnWidth(),
384+
this.getNewColumnLineIndex(),
385+
).then((columnLine) => {
386+
387+
moveContentType(column, 0, columnLine);
388+
updateColumnWidth(column, 100);
389+
if (modifyOldNeighbour) {
390+
updateColumnWidth(modifyOldNeighbour, oldNeighbourWidth);
391+
}
392+
this.fireMountEvent(this.contentType, column);
393+
394+
});
395+
} else {
381396
moveContentType(column, movePosition.insertIndex, this.contentType);
382397
if (modifyOldNeighbour) {
383398
updateColumnWidth(modifyOldNeighbour, oldNeighbourWidth);
@@ -388,38 +403,42 @@ export default class Preview extends PreviewCollection {
388403
);
389404
let newNeighbour = movePosition.affectedColumn;
390405
let totalWidthAdjusted = 0;
391-
let newNeighbourIndex = getColumnIndexInLine(newNeighbour);
392406
updateColumnWidth(column, oldWidth);
393407
while (true) {
394-
//take width from all neighbours in one direction till the entire width is obtained
408+
// take width from all neighbours in one direction till the entire width is obtained
395409
if (newNeighbourWidth <= 0) {
396-
newNeighbourWidth = this.resizeUtils.getSmallestColumnWidth();
397-
let originalWidthOfNeighbour = this.resizeUtils.getColumnWidth(newNeighbour);
410+
newNeighbourWidth = this.resizeUtils.getSmallestColumnWidth();
411+
const originalWidthOfNeighbour = this.resizeUtils.getColumnWidth(newNeighbour);
398412
updateColumnWidth(newNeighbour, newNeighbourWidth);
399413
totalWidthAdjusted += (originalWidthOfNeighbour - newNeighbourWidth);
400414
} else {
401415
updateColumnWidth(newNeighbour, newNeighbourWidth);
402416
break;
403417
}
404418

405-
newNeighbour = getAdjacentColumn(newNeighbour, direction);
419+
if (direction === "+1") {
420+
newNeighbour = getAdjacentColumn(newNeighbour, "+1");
421+
} else {
422+
newNeighbour = getAdjacentColumn(newNeighbour, "-1");
423+
}
424+
406425
if (!newNeighbour) {
407426
updateColumnWidth(column, totalWidthAdjusted);
408427
break;
409428
}
410-
let neighbourExistingWidth = this.resizeUtils.getColumnWidth(newNeighbour);
429+
const neighbourExistingWidth = this.resizeUtils.getColumnWidth(newNeighbour);
411430
newNeighbourWidth = neighbourExistingWidth - (oldWidth - totalWidthAdjusted);
412431
if (newNeighbourWidth < 0.001) {
413432
newNeighbourWidth = 0;
414433
}
415434

416435
}
417436
let totalWidth = 0;
418-
this.contentType.children().forEach((column: ContentTypeCollectionInterface<ColumnPreview>) => {
419-
totalWidth += this.resizeUtils.getColumnWidth(column);
437+
this.contentType.children().forEach((columnChild: ContentTypeCollectionInterface<ColumnPreview>) => {
438+
totalWidth += this.resizeUtils.getColumnWidth(columnChild);
420439
});
421440
if (totalWidth > 100) {
422-
//take extra width from newly moved column
441+
// take extra width from newly moved column
423442
updateColumnWidth(column, this.resizeUtils.getColumnWidth(column) - (totalWidth - 100));
424443
}
425444
}
@@ -784,8 +803,8 @@ export default class Preview extends PreviewCollection {
784803
// show column line drop placeholder only for top column line in a group
785804

786805
return (this.dropOverElement || draggedColumn) &&
787-
event.pageY > linePosition.top &&
788-
event.pageY < linePosition.top + this.lineDropperHeight;
806+
event.pageY > linePosition.top + 15 &&
807+
event.pageY < linePosition.top + 15 + this.lineDropperHeight;
789808
}
790809

791810
/**
@@ -801,8 +820,8 @@ export default class Preview extends PreviewCollection {
801820

802821
const draggedColumn = getDragColumn();
803822
return (this.dropOverElement || draggedColumn) &&
804-
(event.pageY < linePosition.top + this.element.outerHeight() &&
805-
event.pageY > linePosition.top + this.element.outerHeight() - this.lineDropperHeight);
823+
(event.pageY < linePosition.top + 15 + this.element.outerHeight() &&
824+
event.pageY > linePosition.top + 15 +this.element.outerHeight() - this.lineDropperHeight);
806825

807826
}
808827

@@ -816,8 +835,8 @@ export default class Preview extends PreviewCollection {
816835

817836
const draggedColumn = getDragColumn();
818837
return (this.dropOverElement || draggedColumn) &&
819-
event.pageY > linePosition.top + this.lineDropperHeight &&
820-
event.pageY < linePosition.top + linePosition.outerHeight - this.lineDropperHeight;
838+
event.pageY > linePosition.top + 15 + this.lineDropperHeight &&
839+
event.pageY < linePosition.top + 15 + linePosition.outerHeight - this.lineDropperHeight;
821840
}
822841
/**
823842
* Handle mouse move events on when dropping elements

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,23 +226,23 @@ export default class Preview extends PreviewCollection {
226226
return super.clone(contentType, autoAppend);
227227
}
228228

229-
let shrinkableColumn = resizeUtils.findBiggerShrinkableColumn(contentType);
230-
if (shrinkableColumn) {
229+
const biggestShrinkableColumn = resizeUtils.findBiggerShrinkableColumn(contentType);
230+
if (biggestShrinkableColumn) {
231231
const shrinkableClone = super.clone(contentType, autoAppend);
232232
if (shrinkableClone) {
233-
let newShrinkableColumnWidth = resizeUtils.getColumnWidth(shrinkableColumn)
233+
const newShrinkableColumnWidth = resizeUtils.getColumnWidth(biggestShrinkableColumn)
234234
- resizeUtils.getColumnWidth(contentType);
235-
let duplicateColumnWidth = resizeUtils.getColumnWidth(contentType);
235+
const duplicateColumnWidth = resizeUtils.getColumnWidth(contentType);
236236
shrinkableClone.then((duplicateContentType: ContentTypeCollectionInterface<Preview>) => {
237237
updateColumnWidth(
238-
shrinkableColumn,
238+
biggestShrinkableColumn,
239239
resizeUtils.getAcceptedColumnWidth(
240240
(newShrinkableColumnWidth).toString(),
241241
),
242242
);
243243
updateColumnWidth(
244244
duplicateContentType,
245-
duplicateColumnWidth
245+
duplicateColumnWidth,
246246
);
247247

248248
return duplicateContentType;

0 commit comments

Comments
 (0)