From 667cdfb9d0830db4d7dded4414afe19841632434 Mon Sep 17 00:00:00 2001 From: nhthinh-axonivy Date: Fri, 6 Dec 2024 14:01:20 +0700 Subject: [PATCH] Revert "bug/IVYPORTAL-18051-Portal-Dashboard-shows-no-permission-screen-when-dashboards-is-empty" This reverts commit 2d4c74049b142a823e30521ffa1073f21865af10. --- .../addon/portal/generic/menu/MenuView.java | 2 + .../bean/DashboardDetailModificationBean.java | 2 +- .../bean/DashboardModificationBean.java | 2 +- .../addon/portalkit/util/DashboardUtils.java | 10 +- .../portalkit/util/DefaultDashboardUtils.java | 336 ------------------ 5 files changed, 7 insertions(+), 345 deletions(-) diff --git a/AxonIvyPortal/portal/src/ch/addon/portal/generic/menu/MenuView.java b/AxonIvyPortal/portal/src/ch/addon/portal/generic/menu/MenuView.java index bb808d0b6f6..668df5c4364 100644 --- a/AxonIvyPortal/portal/src/ch/addon/portal/generic/menu/MenuView.java +++ b/AxonIvyPortal/portal/src/ch/addon/portal/generic/menu/MenuView.java @@ -91,6 +91,8 @@ public void buildPortalLeftMenu(ITask workingTask, boolean isWorkingOnATask) { mainMenuModel = new DefaultMenuModel(); mainMenuModel.getElements().add(buildDashboardItem()); // menuIndex = 0 + + List subMenuItems = PortalMenuNavigator.callSubMenuItemsProcess(); int menuIndex = 1; for (SubMenuItem subMenu : subMenuItems) { diff --git a/AxonIvyPortal/portal/src/ch/ivy/addon/portal/generic/bean/DashboardDetailModificationBean.java b/AxonIvyPortal/portal/src/ch/ivy/addon/portal/generic/bean/DashboardDetailModificationBean.java index f49485ecb0f..5727ffb6499 100644 --- a/AxonIvyPortal/portal/src/ch/ivy/addon/portal/generic/bean/DashboardDetailModificationBean.java +++ b/AxonIvyPortal/portal/src/ch/ivy/addon/portal/generic/bean/DashboardDetailModificationBean.java @@ -182,7 +182,7 @@ protected List collectDashboards() { } catch (PortalException e) { Ivy.log().error(e); } - DashboardUtils.addDefaultDashboardsIfMissing(collectedDashboards); + DashboardUtils.addDefaultTaskCaseListDashboardsIfMissing(collectedDashboards); return collectedDashboards.stream() .filter(dashboard -> dashboard.getId().equals(selectedDashboardId)).collect(Collectors.toList()); } diff --git a/AxonIvyPortal/portal/src/ch/ivy/addon/portal/generic/bean/DashboardModificationBean.java b/AxonIvyPortal/portal/src/ch/ivy/addon/portal/generic/bean/DashboardModificationBean.java index f4f8402d864..c6c86eafd56 100644 --- a/AxonIvyPortal/portal/src/ch/ivy/addon/portal/generic/bean/DashboardModificationBean.java +++ b/AxonIvyPortal/portal/src/ch/ivy/addon/portal/generic/bean/DashboardModificationBean.java @@ -72,7 +72,7 @@ protected void collectDashboardsForManagement() { String dashboardInUserProperty = readDashboardBySessionUser(); if (isPublicDashboard) { this.dashboards = DashboardUtils.getPublicDashboards(); - DashboardUtils.addDefaultDashboardsIfMissing(this.dashboards); + DashboardUtils.addDefaultTaskCaseListDashboardsIfMissing(this.dashboards); } else if (StringUtils.isNoneEmpty(dashboardInUserProperty)) { List myDashboards = getVisibleDashboards(dashboardInUserProperty); this.dashboards.addAll(myDashboards); 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 97cc6abd708..f42e63ec3d2 100644 --- a/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/util/DashboardUtils.java +++ b/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/util/DashboardUtils.java @@ -134,16 +134,12 @@ public static List getVisiblePublicDashboards() { public static List getPublicDashboards() { String dashboardJson = Ivy.var().get(PortalVariable.DASHBOARD.key); List visibleDashboards = jsonToDashboards(dashboardJson); - addDefaultDashboardsIfMissing(visibleDashboards); + addDefaultTaskCaseListDashboardsIfMissing(visibleDashboards); setDashboardAsPublic(visibleDashboards); return visibleDashboards; } - public static void addDefaultDashboardsIfMissing(List dashboards) { - List dashboardsWithoutItem = dashboards.stream().filter(dashboard -> !dashboard.getIsTopMenu()).toList(); - if (dashboardsWithoutItem.size() == 0) { - dashboards.add(0,DefaultDashboardUtils.getDefaultDashboard()); - } + public static void addDefaultTaskCaseListDashboardsIfMissing(List dashboards) { if (!hasDashboardWithId(dashboards, DEFAULT_CASE_LIST_DASHBOARD)) { dashboards.add(0, DefaultDashboardUtils.getDefaultCaseListDashboard()); } @@ -202,7 +198,7 @@ public static List collectDashboards() { } } collectedDashboards.addAll(idToDashboard.values()); - addDefaultDashboardsIfMissing(collectedDashboards); + addDefaultTaskCaseListDashboardsIfMissing(collectedDashboards); return collectedDashboards; } 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 7e87c1d1856..f092c03fb23 100644 --- a/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/util/DefaultDashboardUtils.java +++ b/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/util/DefaultDashboardUtils.java @@ -4,339 +4,6 @@ public class DefaultDashboardUtils { - private static String DEFAULT_DASHBOARD_JSON = """ - { - "id": "1", - "version": "12.0.0", - "templateId": "default-portal-dashboard-template", - "titles": [ - { - "locale": "en", - "value": "Dashboard" - }, - { - "locale": "fr", - "value": "Tableau de bord" - }, - { - "locale": "de", - "value": "Dashboard" - }, - { - "locale": "es", - "value": "Tablero de mandos" - } - ], - "icon": "si-pie-line-graph", - "widgets": [ - { - "type": "task", - "id": "task_1", - "names": [ - { - "locale": "en", - "value": "Your Tasks" - }, - { - "locale": "de", - "value": "Ihre Aufgaben" - }, - { - "locale": "fr", - "value": "Vos tâches" - }, - { - "locale": "es", - "value": "Sus tareas" - } - ], - "layout": { - "w": 8, - "h": 6, - "x": 0, - "y": 2 - }, - "enableQuickSearch": true, - "columns": [ - { - "field": "start", - "width": "65" - }, - { - "field": "priority", - "width": "65" - }, - { - "field": "id", - "visible": false - }, - { - "field": "name", - "width": "315" - }, - { - "field": "description", - "visible": false - }, - { - "field": "activator", - "width": "120" - }, - { - "field": "state", - "visible": false - }, - { - "field": "startTimestamp", - "visible": false - }, - { - "field": "expiryTimestamp" - }, - { - "field": "category", - "visible": false - }, - { - "field": "actions", - "width": "78" - } - ], - "sortDescending": true, - "sortField": "startTimestamp", - "canWorkOn": true, - "filters": [ - { - "field": "state", - "values": [ - "DONE", - "IN_PROGRESS", - "OPEN" - ], - "operator": "in", - "type": "standard" - } - ] - }, - { - "type": "case", - "id": "case_1", - "names": [ - { - "locale": "en", - "value": "Your Cases" - }, - { - "locale": "de", - "value": "Ihre Vorgänge" - }, - { - "locale": "fr", - "value": "Vos affaires" - }, - { - "locale": "es", - "value": "Sus casos" - } - ], - "layout": { - "w": 9, - "h": 6, - "x": 3, - "y": 8 - }, - "enableQuickSearch": true, - "columns": [ - { - "field": "id", - "width": "60" - }, - { - "field": "name", - "width": "320" - }, - { - "field": "description", - "visible": false - }, - { - "field": "state", - "width": "60" - }, - { - "field": "creator", - "width": "100" - }, - { - "field": "startTimestamp", - "width": "100" - }, - { - "field": "endTimestamp", - "visible": false - }, - { - "field": "category", - "visible": false - }, - { - "field": "actions", - "width": "60" - } - ], - "sortDescending": true, - "sortField": "startTimestamp", - "filters": [ - { - "field": "state", - "values": [ - "OPEN" - ], - "operator": "in", - "type": "standard" - } - ] - }, - { - "type": "compact-process", - "id": "process_1", - "names": [ - { - "locale": "en", - "value": "Your Processes" - }, - { - "locale": "de", - "value": "Ihre Prozesse" - }, - { - "locale": "fr", - "value": "Vos processus" - }, - { - "locale": "es", - "value": "Sus procesos" - } - ], - "layout": { - "w": 4, - "h": 4, - "x": 8, - "y": 4 - } - }, - { - "type": "welcome", - "id": "welcome_1", - "names": [ - { - "locale": "en", - "value": "Your Welcome Widget" - } - ], - "layout": { - "w": 12, - "h": 2, - "x": 0, - "y": 0 - }, - "welcomeTextPosition": "TOP_LEFT", - "welcomeTextSize": "HEADING_3", - "welcomeTextColor": "ffffff", - "welcomeTexts": [ - { - "locale": "en", - "value": ", welcome to the Axon Ivy Portal!" - }, - { - "locale": "fr", - "value": ", bienvenue sur le portail Axon Ivy!" - }, - { - "locale": "de", - "value": ", willkommen im Axon Ivy Portal!" - }, - { - "locale": "es", - "value": ", bienvenido al portal Axon Ivy!" - } - ], - "welcomeImageFit": "COVER", - "greeting": true - }, - { - "type": "client-statistic", - "id": "client_statistic_1", - "layout": { - "w": 2, - "h": 2, - "x": 8, - "y": 2 - }, - "chartId": "10" - }, - { - "type": "client-statistic", - "id": "client_statistic_2", - "layout": { - "w": 2, - "h": 2, - "x": 10, - "y": 2 - }, - "chartId": "11" - }, - { - "type": "client-statistic", - "id": "client_statistic_3", - "layout": { - "w": 3, - "h": 3, - "x": 0, - "y": 11 - }, - "chartId": "7" - }, - { - "type": "client-statistic", - "id": "client_statistic_4", - "layout": { - "w": 3, - "h": 3, - "x": 0, - "y": 8 - }, - "chartId": "3" - }, - { - "type": "client-statistic", - "id": "client_statistic_5", - "layout": { - "w": 3, - "h": 3, - "x": 0, - "y": 14 - }, - "chartId": "5" - }, - { - "type": "client-statistic", - "id": "client_statistic_6", - "layout": { - "w": 9, - "h": 3, - "x": 3, - "y": 14 - }, - "chartId": "4" - } - ], - "permissions": [ - "Everybody" - ] - } - """; - private static String DEFAULT_TASK_LIST_DASHBOARD_JSON = """ { "id": "default-task-list-dashboard", @@ -566,7 +233,4 @@ public static Dashboard getDefaultCaseListDashboard() { return DashboardUtils.jsonToDashboard(DEFAULT_CASE_LIST_DASHBOARD_JSON); } - public static Dashboard getDefaultDashboard() { - return DashboardUtils.jsonToDashboard(DEFAULT_DASHBOARD_JSON); - } }