From 35ac7bfa38f7251f8e34a8bbcd1de513bcff018a Mon Sep 17 00:00:00 2001 From: Boubaker Khanfir Date: Wed, 26 Jun 2024 16:13:51 +0100 Subject: [PATCH] feat: Save Applications and Sections Margins Style - MEED-7131 - Meeds-io/MIPs#144 (#926) --- .../portal/pom/data/MappedAttributes.java | 8 +++++++ .../portal/mop/storage/LayoutStorage.java | 24 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/component/api/src/main/java/org/exoplatform/portal/pom/data/MappedAttributes.java b/component/api/src/main/java/org/exoplatform/portal/pom/data/MappedAttributes.java index c562f17f92..643ab3d99c 100644 --- a/component/api/src/main/java/org/exoplatform/portal/pom/data/MappedAttributes.java +++ b/component/api/src/main/java/org/exoplatform/portal/pom/data/MappedAttributes.java @@ -113,6 +113,14 @@ private MappedAttributes() { public static final Key BOX_SHADOW = Key.create("box-shadow", ValueType.STRING); + public static final Key MARGIN_TOP = Key.create("margin-top", ValueType.STRING); + + public static final Key MARGIN_BOTTOM = Key.create("margin-bottom", ValueType.STRING); + + public static final Key MARGIN_LEFT = Key.create("margin-left", ValueType.STRING); + + public static final Key MARGIN_RIGHT = Key.create("margin-right", ValueType.STRING); + public static final Key RADIUS_TOP_RIGHT_SHADOW = Key.create("radius-top-right", ValueType.STRING); public static final Key RADIUS_TOP_LEFT_SHADOW = Key.create("radius-top-left", ValueType.STRING); diff --git a/component/portal/src/main/java/org/exoplatform/portal/mop/storage/LayoutStorage.java b/component/portal/src/main/java/org/exoplatform/portal/mop/storage/LayoutStorage.java index 0434954672..2e279ca64a 100644 --- a/component/portal/src/main/java/org/exoplatform/portal/mop/storage/LayoutStorage.java +++ b/component/portal/src/main/java/org/exoplatform/portal/mop/storage/LayoutStorage.java @@ -838,6 +838,18 @@ private ModelStyle mapPropertiesToStyle(JSONObject attrs) { // NOSONAR if (attrs.containsKey(MappedAttributes.BOX_SHADOW.getName())) { cssStyle.setBoxShadow((String) attrs.get(MappedAttributes.BOX_SHADOW.getName())); } + if (attrs.containsKey(MappedAttributes.MARGIN_TOP.getName())) { + cssStyle.setMarginTop(Integer.parseInt((String) attrs.get(MappedAttributes.MARGIN_TOP.getName()))); + } + if (attrs.containsKey(MappedAttributes.MARGIN_BOTTOM.getName())) { + cssStyle.setMarginBottom(Integer.parseInt((String) attrs.get(MappedAttributes.MARGIN_BOTTOM.getName()))); + } + if (attrs.containsKey(MappedAttributes.MARGIN_RIGHT.getName())) { + cssStyle.setMarginRight(Integer.parseInt((String) attrs.get(MappedAttributes.MARGIN_RIGHT.getName()))); + } + if (attrs.containsKey(MappedAttributes.MARGIN_LEFT.getName())) { + cssStyle.setMarginLeft(Integer.parseInt((String) attrs.get(MappedAttributes.MARGIN_LEFT.getName()))); + } if (attrs.containsKey(MappedAttributes.RADIUS_TOP_RIGHT_SHADOW.getName())) { cssStyle.setRadiusTopRight(Integer.parseInt((String) attrs.get(MappedAttributes.RADIUS_TOP_RIGHT_SHADOW.getName()))); } @@ -953,6 +965,18 @@ private void mapStyleToProperties(ModelStyle cssStyle, JSONObject properties) { if (StringUtils.isNotBlank(cssStyle.getBoxShadow())) { properties.put(MappedAttributes.BOX_SHADOW.getName(), cssStyle.getBoxShadow()); } + if (cssStyle.getMarginTop() != null) { + properties.put(MappedAttributes.MARGIN_TOP.getName(), cssStyle.getMarginTop().toString()); + } + if (cssStyle.getMarginBottom() != null) { + properties.put(MappedAttributes.MARGIN_BOTTOM.getName(), cssStyle.getMarginBottom().toString()); + } + if (cssStyle.getMarginRight() != null) { + properties.put(MappedAttributes.MARGIN_RIGHT.getName(), cssStyle.getMarginRight().toString()); + } + if (cssStyle.getMarginLeft() != null) { + properties.put(MappedAttributes.MARGIN_LEFT.getName(), cssStyle.getMarginLeft().toString()); + } if (cssStyle.getRadiusTopRight() != null) { properties.put(MappedAttributes.RADIUS_TOP_RIGHT_SHADOW.getName(), cssStyle.getRadiusTopRight().toString()); }