Skip to content

Commit

Permalink
#27816 include in 23.10.24 LTS
Browse files Browse the repository at this point in the history
  • Loading branch information
erickgonzalez committed Jul 30, 2024
1 parent 1db887d commit 439d3cd
Show file tree
Hide file tree
Showing 15 changed files with 6,147 additions and 924 deletions.
1 change: 1 addition & 0 deletions dotCMS/hotfix_tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,4 @@ This maintenance release includes the following code fixes:
128. https://github.com/dotCMS/core/issues/26477 : Search filter can't find/filter images #26477
129. https://github.com/dotCMS/core/issues/27297 : Edit Page: Edit Contentlet Dialog Language Support #27297
130. https://github.com/dotCMS/core/issues/26413 : Template Builder: Container Layout Editing Issue #26413
131. https://github.com/dotCMS/core/issues/27816 : Content Displacement Bug when Editing Template #27816
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@
import com.dotmarketing.portlets.containers.model.FileAssetContainer;
import com.dotmarketing.portlets.templates.design.bean.*;

import javax.swing.*;
import java.util.*;

public class TemplateLayoutDataGen {

final Map<String, List<String>> containersIds = new HashMap<>();
private List<TemplateLayoutRow> rows;

private List<TemplateLayoutColumn> currentColumns;

private Map<String, List<String>> containersIds = new HashMap<>();
final Map<String, List<String>> containersIdsInSidebar = new HashMap<>();
private int currentColumnWidthPercent = 100;

public static TemplateLayoutDataGen get(){
return new TemplateLayoutDataGen();
Expand Down Expand Up @@ -45,16 +51,11 @@ public TemplateLayoutDataGen withContainerInSidebar(final String identifier, fin
}

public TemplateLayout next() {
final List<ContainerUUID> containers = createContainerUUIDS(containersIds);
final List<ContainerUUID> containersInSidebar = createContainerUUIDS(containersIdsInSidebar);

final List<TemplateLayoutColumn> columns = new ArrayList<>();
columns.add(new TemplateLayoutColumn(containers, 100, 1, null));

final List<TemplateLayoutRow> rows = new ArrayList<>();
rows.add(new TemplateLayoutRow(columns, null));
final List<ContainerUUID> containersInSidebar = createContainerUUIDS(containersIdsInSidebar);
final List<TemplateLayoutRow> innerRows = rows == null ? getDefaultRow() : getRows();

final Body body = new Body(rows);
final Body body = new Body(innerRows);
final TemplateLayout templateLayout = new TemplateLayout();
templateLayout.setBody(body);

Expand All @@ -63,7 +64,25 @@ public TemplateLayout next() {

return templateLayout;
}


private List<TemplateLayoutRow> getRows() {
createNewRow();
return rows;
}

private List<TemplateLayoutRow> getDefaultRow() {
final List<TemplateLayoutRow> rows = new ArrayList<>();

final List<ContainerUUID> containers = createContainerUUIDS(containersIds);

final List<TemplateLayoutColumn> columns = new ArrayList<>();
columns.add(new TemplateLayoutColumn(containers, 100, 1, null));

rows.add(new TemplateLayoutRow(columns, null));

return rows;
}

private static List<ContainerUUID> createContainerUUIDS(Map<String, List<String>> containersIds) {
final List<ContainerUUID> containers = new ArrayList<>();

Expand All @@ -86,4 +105,39 @@ public TemplateLayoutDataGen withContainer(final Container container, final Stri
public TemplateLayoutDataGen withContainer(final Container container) {
return withContainer(container, null);
}
}

public TemplateLayoutDataGen addRow() {

if (rows == null) {
rows = new ArrayList<>();
currentColumns = new ArrayList<>();
} else {
createNewRow();
}

return this;
}

private void createNewRow() {
addNewColumn();

rows.add(new TemplateLayoutRow(currentColumns, null));
currentColumns = new ArrayList<>();
}

public TemplateLayoutDataGen addColumn(final int widthPercent) {
if (containersIds != null && !containersIds.isEmpty()) {
addNewColumn();
}

currentColumnWidthPercent = widthPercent;
return this;
}

private void addNewColumn() {
final List<ContainerUUID> containers = createContainerUUIDS(containersIds);
currentColumns.add(new TemplateLayoutColumn(containers, currentColumnWidthPercent, 1, null));

containersIds = new HashMap<>();
}
}
Loading

0 comments on commit 439d3cd

Please sign in to comment.