From c0b4da403d5ea8971b1f17dcbd4e568d47aeae46 Mon Sep 17 00:00:00 2001 From: Murilo Habermann Torquato Date: Mon, 3 Jun 2019 16:31:38 -0300 Subject: [PATCH] Refs #9674 - window UUID from quickInfo zoom ( IDEMPIERE-3978 ) --- .../src/org/compiere/model/MQuery.java | 13 +++++++++++ .../src/org/compiere/model/MWindow.java | 23 +++++++++++++++++++ .../src/org/adempiere/webui/apps/AEnv.java | 6 ++++- .../webui/component/ZoomCommand.java | 9 ++++++++ org.adempiere.ui.zk/js/report.js | 6 ++++- 5 files changed, 55 insertions(+), 2 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MQuery.java b/org.adempiere.base/src/org/compiere/model/MQuery.java index d696ede3e8..9c45107b4c 100644 --- a/org.adempiere.base/src/org/compiere/model/MQuery.java +++ b/org.adempiere.base/src/org/compiere/model/MQuery.java @@ -383,6 +383,19 @@ public class MQuery implements Serializable private Object m_zoomValue; + private int m_zoomWindow_ID; + + + public int getM_zoomWindow_ID() { + return m_zoomWindow_ID; + } + + + public void setM_zoomWindow_ID(int m_zoomWindow_ID) { + this.m_zoomWindow_ID = m_zoomWindow_ID; + } + + /** * Get Record Count * @return count - default 999999 diff --git a/org.adempiere.base/src/org/compiere/model/MWindow.java b/org.adempiere.base/src/org/compiere/model/MWindow.java index 0d960004d6..0b9426957a 100644 --- a/org.adempiere.base/src/org/compiere/model/MWindow.java +++ b/org.adempiere.base/src/org/compiere/model/MWindow.java @@ -27,6 +27,7 @@ import java.util.logging.Level; import org.compiere.util.CCache; import org.compiere.util.CLogger; import org.compiere.util.DB; +import org.compiere.util.Env; import org.compiere.wf.MWFNode; /** @@ -240,4 +241,26 @@ public class MWindow extends X_AD_Window } //end vpj-cd e-evolution + /** + * get Window ID by UU + * @param uu + * @return + */ + public static int findByUU(String uu) + { + int retValue = 0; + + final String whereClause = MWindow.COLUMNNAME_AD_Window_UU + "=?"; + + MWindow window = new Query(Env.getCtx(), MWindow.Table_Name, whereClause, null) + .setParameters(uu) + .setOnlyActiveRecords(true) + .first(); + + if (window != null) + retValue = window.get_ID(); + + return retValue; + } + } // M_Window diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AEnv.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AEnv.java index ad6e205bac..d987a9490d 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AEnv.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AEnv.java @@ -462,7 +462,11 @@ public final class AEnv if (query == null || query.getTableName() == null || query.getTableName().length() == 0) return; - int AD_Window_ID = Env.getZoomWindowID(query); + int AD_Window_ID = query.getM_zoomWindow_ID(); + + if (AD_Window_ID <= 0) + AD_Window_ID = Env.getZoomWindowID(query); + // Nothing to Zoom to if (AD_Window_ID == 0) return; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/ZoomCommand.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/ZoomCommand.java index 1ba2474890..277743d3c5 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/ZoomCommand.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/ZoomCommand.java @@ -17,6 +17,7 @@ import java.util.Map; import org.adempiere.webui.event.ZoomEvent; import org.compiere.model.MQuery; +import org.compiere.model.MWindow; import org.zkoss.json.JSONArray; import org.zkoss.lang.Objects; import org.zkoss.zk.au.AuRequest; @@ -54,6 +55,7 @@ public class ZoomCommand implements AuService { String columnName = (String) data.get(0); String tableName = MQuery.getZoomTableName(columnName); Object code = null; + int windowID = 0; if (columnName.endsWith("_ID")) { try { @@ -66,6 +68,12 @@ public class ZoomCommand implements AuService { { code = data.get(1); } + + if (data.size() > 3) + { + String windowUU = (String) data.get(3); + windowID = MWindow.findByUU(windowUU); + } // MQuery query = new MQuery(tableName); query.addRestriction(columnName, MQuery.EQUAL, code); @@ -73,6 +81,7 @@ public class ZoomCommand implements AuService { query.setZoomTableName(tableName); query.setZoomColumnName(columnName); query.setZoomValue(code); + query.setM_zoomWindow_ID(windowID); Events.postEvent(new ZoomEvent(comp, query)); diff --git a/org.adempiere.ui.zk/js/report.js b/org.adempiere.ui.zk/js/report.js index 5da788df2c..34ba351fa8 100644 --- a/org.adempiere.ui.zk/js/report.js +++ b/org.adempiere.ui.zk/js/report.js @@ -1,7 +1,11 @@ function zoom(cmpid, column, value){ + zoomWindow(cmpid, column, value, null) +} + +function zoomWindow(cmpid, column, value, windowuu){ zAu.cmd0.showBusy(null); var widget = zk.Widget.$(cmpid); - var event = new zk.Event(widget, 'onZoom', {data: [column, value]}, {toServer: true}); + var event = new zk.Event(widget, 'onZoom', {data: [column, value, 'AD_Window_UU', windowuu]}, {toServer: true}); zAu.send(event); }