From e5ce953f6d3a31b9d944f2b104d0c6631e50feb6 Mon Sep 17 00:00:00 2001 From: Boubaker Khanfir Date: Thu, 20 Jun 2024 12:40:13 +0100 Subject: [PATCH] feat: Allow to define Parent CSS Classes on Application Parent Container - MEED-7094 - Meeds-io/MIPs#144 (#916) This change will allow to define a custom CSS class to a portlet using a portlet.xml definition inside an init param with key 'layout-css-class'. This CSS is part of portlet definition and not attached to a particular of Portlet instance only. --- .../groovy/portal/webui/application/UIPortlet.gtmpl | 3 ++- .../portal/webui/application/UIPortlet.java | 10 ++++++++-- .../portal/webui/util/PortalDataMapper.java | 7 ++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl b/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl index f05b3a9666..d533485898 100644 --- a/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl +++ b/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl @@ -39,9 +39,10 @@ } cssStyle = " style=\"" + cssStyle + "\""; } + String cssClass = uicomponent.getCssClass() == null ? "" : " " + uicomponent.getCssClass(); %>
-
+
<% println portletContent; %>
diff --git a/webui/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java b/webui/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java index 27263b3463..debfabffa5 100644 --- a/webui/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java +++ b/webui/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java @@ -106,6 +106,8 @@ import jakarta.servlet.http.Cookie; import jakarta.servlet.http.HttpServletRequest; +import lombok.Getter; +import lombok.Setter; /** * This UI component represent a portlet window on a page.
@@ -195,6 +197,10 @@ public class UIPortlet extends UIApplication { /** A field storing localized value of javax.portlet.title * */ private String configuredTitle; + @Getter + @Setter + private String cssClass; + public String getStorageId() { return storageId; } @@ -1068,8 +1074,8 @@ public Text generateRenderMarkup(PortletInvocationResponse pir, WebuiRequestCont if (pir instanceof FragmentResponse) { if (lazyResourcesLoading == null) { PortletInfo portletInfo = producedOfferedPortlet.getInfo(); - if (portletInfo instanceof ContainerPortletInfo) { - String prefetchResources = ((ContainerPortletInfo) portletInfo).getInitParameter("prefetch.resources"); + if (portletInfo instanceof ContainerPortletInfo containerPortletInfo) { + String prefetchResources = containerPortletInfo.getInitParameter("prefetch.resources"); lazyResourcesLoading = StringUtils.equals(prefetchResources, "true"); } else { lazyResourcesLoading = false; diff --git a/webui/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java b/webui/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java index a19d9f4ee3..a6a36f8f5f 100644 --- a/webui/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java +++ b/webui/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java @@ -24,10 +24,12 @@ import java.util.Set; import org.exoplatform.portal.mop.service.LayoutService; + import org.gatein.common.net.media.MediaType; import org.gatein.pc.api.Portlet; import org.gatein.pc.api.info.ModeInfo; import org.gatein.pc.api.info.PortletInfo; +import org.gatein.pc.portlet.impl.info.ContainerPortletInfo; import org.exoplatform.portal.config.UserPortalConfigService; import org.exoplatform.portal.config.model.Application; @@ -249,7 +251,10 @@ private static void toUIPortlet(UIPortlet uiPortlet, Application mo if (supportModes.size() > 1) supportModes.remove("view"); uiPortlet.setSupportModes(supportModes); - } + if (portletInfo instanceof ContainerPortletInfo containerPortletInfo) { + uiPortlet.setCssClass(containerPortletInfo.getInitParameter("layout-css-class")); + } + } public static void toUIContainer(UIContainer uiContainer, Container model) throws Exception { uiContainer.setStorageId(model.getStorageId());