From 1f4a23657ad66d8542cd7efde97d34f41c862980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Tak=C3=A1cs?= <93127072+PeterTakacs300@users.noreply.github.com> Date: Wed, 7 Sep 2022 15:40:29 +0200 Subject: [PATCH] IDEMPIERE-5400 - Dashboard Goal Content should render as single Gauge Indicator (#1458) * IDEMPIERE-5400 - Dashboard Goal Content should render as single Gauge Indicator * IDEMPIERE-5400 - better css responsivity * IDEMPIERE-5400 - add update goal * IDEMPIERE-5400 - fixes * IDEMPIERE-5400 - resolved conflict, migration fix * IDEMPIERE-5400 - fix bad merge --- .../oracle/202208301110_IDEMPIERE-5400.sql | 10 +++ .../202208301110_IDEMPIERE-5400.sql | 7 ++ .../compiere/model/X_PA_DashboardContent.java | 4 +- .../adempiere/webui/apps/graph/WPAWidget.java | 72 +++++++++++++++++++ .../webui/desktop/DashboardController.java | 51 +++++++------ .../theme/default/css/fragment/gadget.css.dsp | 18 +++++ 6 files changed, 140 insertions(+), 22 deletions(-) create mode 100644 migration/iD10/oracle/202208301110_IDEMPIERE-5400.sql create mode 100644 migration/iD10/postgresql/202208301110_IDEMPIERE-5400.sql create mode 100644 org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/graph/WPAWidget.java diff --git a/migration/iD10/oracle/202208301110_IDEMPIERE-5400.sql b/migration/iD10/oracle/202208301110_IDEMPIERE-5400.sql new file mode 100644 index 0000000000..f8477a87a0 --- /dev/null +++ b/migration/iD10/oracle/202208301110_IDEMPIERE-5400.sql @@ -0,0 +1,10 @@ +-- IDEMPIERE-5400 +SELECT register_migration_script('202208301110_IDEMPIERE-5400.sql') FROM dual; + +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Aug 30, 2022, 11:10:28 AM CEST +INSERT INTO AD_Ref_List (AD_Ref_List_ID,Name,AD_Reference_ID,Value,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Ref_List_UU) VALUES (200544,'Gauge Indicator',53316,'G',0,0,'Y',TO_TIMESTAMP('2022-08-30 11:10:28','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-08-30 11:10:28','YYYY-MM-DD HH24:MI:SS'),100,'D','38f8439b-0232-4ea6-9e3f-98574b2b7326') +; + diff --git a/migration/iD10/postgresql/202208301110_IDEMPIERE-5400.sql b/migration/iD10/postgresql/202208301110_IDEMPIERE-5400.sql new file mode 100644 index 0000000000..63594df188 --- /dev/null +++ b/migration/iD10/postgresql/202208301110_IDEMPIERE-5400.sql @@ -0,0 +1,7 @@ +-- IDEMPIERE-5400 +SELECT register_migration_script('202208301110_IDEMPIERE-5400.sql') FROM dual; + +-- Aug 30, 2022, 11:10:28 AM CEST +INSERT INTO AD_Ref_List (AD_Ref_List_ID,Name,AD_Reference_ID,Value,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Ref_List_UU) VALUES (200544,'Gauge Indicator',53316,'G',0,0,'Y',TO_TIMESTAMP('2022-08-30 11:10:28','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-08-30 11:10:28','YYYY-MM-DD HH24:MI:SS'),100,'D','38f8439b-0232-4ea6-9e3f-98574b2b7326') +; + diff --git a/org.adempiere.base/src/org/compiere/model/X_PA_DashboardContent.java b/org.adempiere.base/src/org/compiere/model/X_PA_DashboardContent.java index 52cedb8b3c..577b3f3332 100644 --- a/org.adempiere.base/src/org/compiere/model/X_PA_DashboardContent.java +++ b/org.adempiere.base/src/org/compiere/model/X_PA_DashboardContent.java @@ -33,7 +33,7 @@ public class X_PA_DashboardContent extends PO implements I_PA_DashboardContent, /** * */ - private static final long serialVersionUID = 20220906L; + private static final long serialVersionUID = 20220907L; /** Standard Constructor */ public X_PA_DashboardContent (Properties ctx, int PA_DashboardContent_ID, String trxName) @@ -314,6 +314,8 @@ public class X_PA_DashboardContent extends PO implements I_PA_DashboardContent, public static final int GOALDISPLAY_AD_Reference_ID=53316; /** Chart = C */ public static final String GOALDISPLAY_Chart = "C"; + /** Gauge Indicator = G */ + public static final String GOALDISPLAY_GaugeIndicator = "G"; /** HTML Table = T */ public static final String GOALDISPLAY_HTMLTable = "T"; /** Set Goal Display. diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/graph/WPAWidget.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/graph/WPAWidget.java new file mode 100644 index 0000000000..98d836b34a --- /dev/null +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/graph/WPAWidget.java @@ -0,0 +1,72 @@ +/********************************************************************** +* This file is part of iDempiere ERP Open Source * +* http://www.idempiere.org * +* * +* Copyright (C) Contributors * +* * +* This program is free software; you can redistribute it and/or * +* modify it under the terms of the GNU General Public License * +* as published by the Free Software Foundation; either version 2 * +* of the License, or (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * +* MA 02110-1301, USA. * +* * +* Contributors: * +* - Igor Pojzl, Cloudempiere * +* - Peter Takacs, Cloudempiere * +**********************************************************************/ + +package org.adempiere.webui.apps.graph; + +import org.adempiere.webui.apps.graph.WPerformanceIndicator.Options; +import org.adempiere.webui.component.Panel; +import org.compiere.model.MGoal; +import org.zkoss.zk.ui.event.Events; +import org.zkoss.zul.Div; +import org.zkoss.zul.Label; + +public class WPAWidget extends Panel { + + /** + * + */ + private static final long serialVersionUID = 5684412399657327777L; + + /************************************************************************** + * Constructor + */ + public WPAWidget (MGoal goal, Options options) + { + super(); + goal.updateGoal(false); + init(goal, options); + } + + /** + * Static/Dynamic Init + * @param goal + * @param options + */ + private void init(MGoal goal, Options options) + { + Div div = new Div(); + appendChild(div); + WPerformanceIndicator pi = new WPerformanceIndicator(goal, options); + div.appendChild(pi); + if (goal.getMeasure() != null) + pi.addEventListener(Events.ON_CLICK, e -> new WPerformanceDetail(pi.getGoal())); //Action Listener for Drill Down + Div titleDiv = new Div(); + titleDiv.setSclass("performance-indicator-title"); + Label label = new Label(pi.getTitle()); + div.appendChild(titleDiv); + titleDiv.appendChild(label); + } // init +} diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DashboardController.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DashboardController.java index 9d61a9c4e8..79352eabb4 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DashboardController.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DashboardController.java @@ -37,6 +37,7 @@ import org.adempiere.webui.Extensions; import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.apps.graph.IChartRendererService; import org.adempiere.webui.apps.graph.WGraph; +import org.adempiere.webui.apps.graph.WPAWidget; import org.adempiere.webui.apps.graph.WPerformanceDetail; import org.adempiere.webui.apps.graph.model.ChartModel; import org.adempiere.webui.component.ToolBarButton; @@ -667,30 +668,38 @@ public class DashboardController implements EventListener { int PA_Goal_ID = dc.getPA_Goal_ID(); if(PA_Goal_ID > 0) { - //link to open performance detail - Div div = new Div(); - Toolbarbutton link = new Toolbarbutton(); - if (ThemeManager.isUseFontIconForImage()) - link.setIconSclass("z-icon-Zoom"); - else - link.setImage(ThemeManager.getThemeResource("images/Zoom16.png")); - link.setAttribute("PA_Goal_ID", PA_Goal_ID); - link.addEventListener(Events.ON_CLICK, new EventListener() { - public void onEvent(Event event) throws Exception { - int PA_Goal_ID = (Integer)event.getTarget().getAttribute("PA_Goal_ID"); - MGoal goal = new MGoal(Env.getCtx(), PA_Goal_ID, null); - new WPerformanceDetail(goal); - } - }); - div.appendChild(link); - content.appendChild(div); String goalDisplay = dc.getGoalDisplay(); MGoal goal = new MGoal(Env.getCtx(), PA_Goal_ID, null); - WGraph graph = new WGraph(goal, 55, false, true, - !(MDashboardContent.GOALDISPLAY_Chart.equals(goalDisplay)), - MDashboardContent.GOALDISPLAY_Chart.equals(goalDisplay)); - content.appendChild(graph); + if(MDashboardContent.GOALDISPLAY_GaugeIndicator.equals(goalDisplay)) { + WPAWidget paWidget = new WPAWidget(goal, null); + ((HtmlBasedComponent)content).setSclass("performance-gadget"); + content.appendChild(paWidget); + } + else { + //link to open performance detail + Div div = new Div(); + Toolbarbutton link = new Toolbarbutton(); + if (ThemeManager.isUseFontIconForImage()) + link.setIconSclass("z-icon-Zoom"); + else + link.setImage(ThemeManager.getThemeResource("images/Zoom16.png")); + link.setAttribute("PA_Goal_ID", PA_Goal_ID); + link.addEventListener(Events.ON_CLICK, new EventListener() { + public void onEvent(Event event) throws Exception { + int PA_Goal_ID = (Integer)event.getTarget().getAttribute("PA_Goal_ID"); + MGoal goal = new MGoal(Env.getCtx(), PA_Goal_ID, null); + new WPerformanceDetail(goal); + } + }); + div.appendChild(link); + content.appendChild(div); + + WGraph graph = new WGraph(goal, 55, false, true, + !(MDashboardContent.GOALDISPLAY_Chart.equals(goalDisplay)), + MDashboardContent.GOALDISPLAY_Chart.equals(goalDisplay)); + content.appendChild(graph); + } empty = false; } diff --git a/org.adempiere.ui.zk/WEB-INF/src/web/theme/default/css/fragment/gadget.css.dsp b/org.adempiere.ui.zk/WEB-INF/src/web/theme/default/css/fragment/gadget.css.dsp index 0357ecf834..b15098c538 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/web/theme/default/css/fragment/gadget.css.dsp +++ b/org.adempiere.ui.zk/WEB-INF/src/web/theme/default/css/fragment/gadget.css.dsp @@ -216,6 +216,24 @@ width: 100%; } +.performance-indicator-title { + text-align: center; + padding-top: 1px; + padding-bottom: 1px; + line-height:12px; +} + +.performance-gadget { + display: flex; + justify-content: center; + align-items: center; + cursor: pointer; +} + +.performance-gadget > .z-div { + width: 100%; +} + @media screen and (min-width: 768px) { .dashboard-row .chart-gadget { max-height: 300px;