From fe9dca1dff5aba017b7cbc069d12822ed834ea3e Mon Sep 17 00:00:00 2001 From: mnhnam-axonivy Date: Thu, 12 Dec 2024 15:05:43 +0700 Subject: [PATCH 1/2] IVYPORTAL-18072 SPIKE: Evaluate the full screen issue with new case and task list - Implemented --- .../config/variables/Portal/Dashboard.json | 4 +- .../portal/generic/bean/DashboardBean.java | 6 ++ .../portalkit/dto/dashboard/Dashboard.java | 15 +++++ .../addon/portalkit/util/DashboardUtils.java | 9 +++ .../restricted/DashboardTemplate.xhtml | 14 +++-- .../webContent/resources/js/dashboard.js | 62 +++++++++++++++++-- .../resources/js/responsive-toolkit.js | 5 +- 7 files changed, 101 insertions(+), 14 deletions(-) diff --git a/AxonIvyPortal/portal/config/variables/Portal/Dashboard.json b/AxonIvyPortal/portal/config/variables/Portal/Dashboard.json index c222e3a9993..c3116189da4 100644 --- a/AxonIvyPortal/portal/config/variables/Portal/Dashboard.json +++ b/AxonIvyPortal/portal/config/variables/Portal/Dashboard.json @@ -377,7 +377,7 @@ ], "layout": { "w": 12, - "h": 8, + "h": 12, "x": 0, "y": 0 }, @@ -489,7 +489,7 @@ ], "layout": { "w": 12, - "h": 8, + "h": 12, "x": 0, "y": 0 }, diff --git a/AxonIvyPortal/portal/src/ch/ivy/addon/portal/generic/bean/DashboardBean.java b/AxonIvyPortal/portal/src/ch/ivy/addon/portal/generic/bean/DashboardBean.java index b573ec9dde1..16d6c18d2a8 100644 --- a/AxonIvyPortal/portal/src/ch/ivy/addon/portal/generic/bean/DashboardBean.java +++ b/AxonIvyPortal/portal/src/ch/ivy/addon/portal/generic/bean/DashboardBean.java @@ -123,6 +123,12 @@ public void init() { .findGlobalSettingValue(GlobalVariable.DEFAULT_BEHAVIOUR_WHEN_CLICKING_ON_LINE_IN_TASK_LIST) .equals(BehaviourWhenClickingOnLineInTaskList.RUN_TASK.name()); + // Set responsive option for default task list and case list + if (DashboardUtils.isDefaultCaseListDashboard(selectedDashboard) + || DashboardUtils.isDefaultTaskListDashboard(selectedDashboard)) { + selectedDashboard.setIsResponsive(true); + } + buildClientStatisticApiUri(); } diff --git a/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/dto/dashboard/Dashboard.java b/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/dto/dashboard/Dashboard.java index 0896ec2dc67..234df2d8057 100644 --- a/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/dto/dashboard/Dashboard.java +++ b/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/dto/dashboard/Dashboard.java @@ -35,9 +35,13 @@ public class Dashboard extends AbstractConfiguration implements Serializable { private String displayedPermission; private Boolean isTopMenu; + @JsonIgnore + private Boolean isResponsive; + public Dashboard() { // Set default values isTopMenu = false; + isResponsive = false; } public Dashboard(Dashboard dashboard) { @@ -54,6 +58,7 @@ public Dashboard(Dashboard dashboard) { permissionDTOs = dashboard.permissionDTOs; displayedPermission = dashboard.displayedPermission; isTopMenu = dashboard.isTopMenu; + isResponsive = dashboard.isResponsive; } public String getTitle() { @@ -146,6 +151,16 @@ public void setIsTopMenu(Boolean isTopMenu) { this.isTopMenu = isTopMenu; } + @JsonIgnore + public Boolean getIsResponsive() { + return isResponsive; + } + + @JsonIgnore + public void setIsResponsive(Boolean isResponsive) { + this.isResponsive = isResponsive; + } + @Override public int hashCode() { final int prime = 31; diff --git a/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/util/DashboardUtils.java b/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/util/DashboardUtils.java index f42e63ec3d2..5a66ea4269e 100644 --- a/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/util/DashboardUtils.java +++ b/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/util/DashboardUtils.java @@ -327,4 +327,13 @@ public static void updatePropertiesToNullIfCurrentValueIsDefaultValue(List "").contentEquals(DEFAULT_TASK_LIST_DASHBOARD); + } + + public static boolean isDefaultCaseListDashboard(Dashboard dashboard) { + return Optional.ofNullable(dashboard).map(Dashboard::getId) + .orElseGet(() -> "").contentEquals(DEFAULT_CASE_LIST_DASHBOARD); + } } diff --git a/AxonIvyPortal/portal/webContent/layouts/restricted/DashboardTemplate.xhtml b/AxonIvyPortal/portal/webContent/layouts/restricted/DashboardTemplate.xhtml index 2c2a30aa326..b6e4256d46c 100644 --- a/AxonIvyPortal/portal/webContent/layouts/restricted/DashboardTemplate.xhtml +++ b/AxonIvyPortal/portal/webContent/layouts/restricted/DashboardTemplate.xhtml @@ -20,6 +20,8 @@ } $(document).ready(function () { + loadGrid(#{managedBean.selectedDashboard.isResponsive}); + updateDashboardWhenResizeWindow(#{managedBean.selectedDashboard.isResponsive}); setTimeout(() => { initStatistics(); }, 50); @@ -48,7 +50,7 @@ - + @@ -203,13 +205,13 @@ + oncomplete="PF('escalation-task-dialog').hide();loadGrid(#{managedBean.selectedDashboard.isResponsive});initStatistics();" update="grid-stack dashboard-title-container" /> + taskId="#{taskWidgetBean.selectedTaskItemId}" componentToUpdate="grid-stack dashboard-title-container" onCompletedCallback="loadGrid(#{managedBean.selectedDashboard.isResponsive}); initStatistics();"/> @@ -308,7 +310,7 @@ + onclick="PF('share-dashboard-dialog').show(); return false;" styleClass="js-share-dashboard-link" /> 0) { + dashboardModificationPageHeaderHeight = ($('.js-dashboard__header').outerHeight(true) || 0) + additionalHeightForResizeHandler; + } + + // calculate available height then divide by default number of cells to get height value for each cell + gridCellHeight = (PortalLayout.getAvailableHeight() - announcementHeight + - shareDashboardLinkHeight - dashboardModificationPageHeaderHeight) / defaultNumberOfCells; + + // If the calculated cell height is less than or equals to 0, use the default cell height instead + gridCellHeight = gridCellHeight > 0 ? gridCellHeight : defaultCellHeight; + } + grids = GridStack.initAll({ - column: 12, - cellHeight: 100, + column: defaultNumberOfCells, + cellHeight: gridCellHeight, resizable: { handles: 'e, se, s, sw, w' } @@ -534,4 +561,29 @@ function udateResizableTablesWhenResizeWidget() { } }); +} + +function updateDashboardWhenResizeWindow(isResponsiveDashboard) { + if (!isResponsiveDashboard) { + return; + } + + // resize timeout ID + let resizeTimeout; + + window.addEventListener('resize', function () { + clearTimeout(resizeTimeout); + + resizeTimeout = setTimeout(function () { + + // Check if the window height has changed + if (window.innerHeight !== windowHeight) { + + // Call the remote command 'updateDashboardWidget' + updateDashboardWidget(); + + windowHeight = window.innerHeight; + } + }, 1000); // Delay execution by 1 sec to avoid send multiple requests + }); } \ No newline at end of file diff --git a/AxonIvyPortal/portal/webContent/resources/js/responsive-toolkit.js b/AxonIvyPortal/portal/webContent/resources/js/responsive-toolkit.js index 893f3cdd016..9a26eac17fa 100644 --- a/AxonIvyPortal/portal/webContent/resources/js/responsive-toolkit.js +++ b/AxonIvyPortal/portal/webContent/resources/js/responsive-toolkit.js @@ -87,7 +87,10 @@ var PortalLayout = { getAvailableHeight: function () { var $layoutMain = $('.js-layout-main'); - var layoutMainPadding = parseInt($layoutMain.css('padding-top') || 0) + parseInt($layoutMain.css('padding-bottom') || 0); + const roundedLayoutMainPaddingTop = parseInt(Math.round(parseFloat($layoutMain.css('padding-top') || 0)) || 0); + const roundedLayoutMainPaddingBottom = parseInt(Math.round(parseFloat($layoutMain.css('padding-bottom') || 0)) || 0); + var layoutMainPadding = roundedLayoutMainPaddingTop + roundedLayoutMainPaddingBottom; + return window.innerHeight - layoutMainPadding; }, From e2ce1b2c34855242bc5aff37a8f76c8b99342141 Mon Sep 17 00:00:00 2001 From: mnhnam-axonivy Date: Tue, 17 Dec 2024 14:45:37 +0700 Subject: [PATCH 2/2] IVYPORTAL-18072 SPIKE: Evaluate the full screen issue with new case and task list - Handled feedback: make the dashboard load from memory responsiveness --- .../ch/ivy/addon/portalkit/util/DefaultDashboardUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/util/DefaultDashboardUtils.java b/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/util/DefaultDashboardUtils.java index f092c03fb23..7c996cbaee0 100644 --- a/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/util/DefaultDashboardUtils.java +++ b/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/util/DefaultDashboardUtils.java @@ -53,7 +53,7 @@ public class DefaultDashboardUtils { ], "layout": { "w": 12, - "h": 8, + "h": 12, "x": 0, "y": 0 }, @@ -168,7 +168,7 @@ public class DefaultDashboardUtils { ], "layout": { "w": 12, - "h": 8, + "h": 12, "x": 0, "y": 0 },