IDEMPIERE-5630 - Drill rule from dashboard html report never opening (#1734)

* IDEMPIERE-5630 - Drill rule from dashboard html report never opening

* IDEMPIERE-5630 - remove windowNo, simplify code

* IDEMPIERE-5630 - small fixes

- add Drill Across Event Listener only when report content is embedded
- small code refactor
This commit is contained in:
Peter Takács 2023-03-15 16:43:34 +01:00 committed by GitHub
parent d4dd4585b6
commit c170c59f47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 57 additions and 11 deletions

View File

@ -48,7 +48,7 @@ Copyright (C) 2007 Ashley G Ramdass (ADempiere WebUI).
<javascript-module name="jawwa.atmosphere" version="202205100600"/>
<javascript-module name="adempiere.local.storage" version="202205100600"/>
<javascript-module name="html2canvas" version="1.3.1"/>
<javascript-module name="org.idempiere.commons" version="202303021810"/>
<javascript-module name="org.idempiere.commons" version="202303151220"/>
<javascript-module name="jquery.maskedinput" version="1.4.1" />
<javascript-module name="photobooth" version="0.7-rsd3" />
<javascript-module name="chosenbox" version="202205100600"/>

View File

@ -401,13 +401,14 @@ public final class LayoutUtils {
public static ISupportMask findMaskParent (Component child, Class<?> parentClass){
Component parent = child;
ISupportMask trueParent = null;
while ((parent = parent.getParent()) != null){
while (parent != null) {
if (ISupportMask.class.isInstance(parent)){
if (parentClass == null || parentClass.isInstance(parent)){
trueParent = (ISupportMask)parent;
break;
}
}
parent = parent.getParent();
}
return trueParent;
}

View File

@ -64,7 +64,7 @@ public class DrillCommand implements AuService {
MQuery query = new MQuery(tableName);
query.addRestriction(columnName, MQuery.EQUAL, code);
Events.postEvent(new DrillEvent(request.getCommand(), comp, new DrillEvent.DrillData(query, columnName, code, displayValue, null )));
Events.postEvent(new DrillEvent(request.getCommand(), comp, new DrillEvent.DrillData(query, columnName, code, displayValue, data )));
return true;
}

View File

@ -47,6 +47,8 @@ import org.adempiere.webui.apps.graph.model.ChartModel;
import org.adempiere.webui.component.ToolBarButton;
import org.adempiere.webui.dashboard.DashboardPanel;
import org.adempiere.webui.dashboard.DashboardRunnable;
import org.adempiere.webui.event.DrillEvent;
import org.adempiere.webui.event.DrillEvent.DrillData;
import org.adempiere.webui.report.HTMLExtension;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager;
@ -82,6 +84,7 @@ import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Util;
import org.zkoss.json.JSONArray;
import org.zkoss.util.media.AMedia;
import org.zkoss.zhtml.Text;
import org.zkoss.zk.ui.Component;
@ -95,6 +98,7 @@ import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.event.MaximizeEvent;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.A;
import org.zkoss.zul.Anchorchildren;
import org.zkoss.zul.Anchorlayout;
@ -170,6 +174,7 @@ public class DashboardController implements EventListener<Event> {
* @param isShowInDashboard
*/
public void render(Component parent, IDesktop desktopImpl, boolean isShowInDashboard) {
String layoutOrientation = MSysConfig.getValue(MSysConfig.DASHBOARD_LAYOUT_ORIENTATION, Env.getAD_Client_ID(Env.getCtx()));
if(layoutOrientation.equals(DASHBOARD_LAYOUT_ROWS) && isShowInDashboard)
renderRows(parent, desktopImpl, isShowInDashboard, false);
@ -772,6 +777,7 @@ public class DashboardController implements EventListener<Event> {
if (dashboardContent.isEmbedReportContent())
{
addDrillAcrossEventListener(AD_Process_ID, appDesktop);
String processParameters = dashboardContent.getProcessParameters();
Div layout = new Div();
@ -961,6 +967,30 @@ public class DashboardController implements EventListener<Event> {
return !empty;
}
/**
* Add Drill Across Event Listener to Border Layout
* @param processID
*/
private void addDrillAcrossEventListener(int processID, IDesktop appDesktop) {
appDesktop.getComponent().addEventListener(DrillEvent.ON_DRILL_ACROSS, new EventListener<Event>() {
public void onEvent(Event event) throws Exception {
if (event instanceof DrillEvent) {
Clients.clearBusy();
DrillEvent de = (DrillEvent) event;
if (de.getData() != null && de.getData() instanceof DrillData) {
DrillData data = (DrillData) de.getData();
if(data.getData() instanceof JSONArray) {
JSONArray jsonData = (JSONArray) data.getData();
if(jsonData.indexOf(String.valueOf(processID)) < 0)
return;
}
AEnv.actionDrill(data, 0, processID); // WindowNo of Home tab is always 0
}
}
}
});
}
@Override
public void onEvent(Event event) throws Exception {
Component comp = event.getTarget();
@ -1461,7 +1491,7 @@ public class DashboardController implements EventListener<Event> {
File file = FileUtil.createTempFile(re.getName(), ".html");
re.createHTML(file, false, AEnv.getLanguage(Env.getCtx()), new HTMLExtension(contextPath, "rp",
appDesktop.getComponent().getUuid()));
appDesktop.getComponent().getUuid(), String.valueOf(AD_Process_ID)));
return new AMedia(re.getName(), "html", "text/html", file, false);
}

View File

@ -45,6 +45,9 @@ public class DrillEvent extends Event {
private Object value;
/**
* [columnName, displayValue, value, processID - source]
*/
private Object data;
public DrillData(MQuery query, String columnName, Object value, String displayValue, Object data) {

View File

@ -44,6 +44,7 @@ public class HTMLExtension implements IHTMLExtension {
private String scriptURL;
private String styleURL;
private String contextPath;
private String processID;
/**
* @param contextPath
@ -51,6 +52,15 @@ public class HTMLExtension implements IHTMLExtension {
* @param componentId
*/
public HTMLExtension(String contextPath, String classPrefix, String componentId) {
this(contextPath, classPrefix, componentId, "");
}
/**
* @param contextPath
* @param classPrefix
* @param componentId
*/
public HTMLExtension(String contextPath, String classPrefix, String componentId, String processID) {
String theme = MSysConfig.getValue(MSysConfig.HTML_REPORT_THEME, "/", Env.getAD_Client_ID(Env.getCtx()));
@ -69,6 +79,7 @@ public class HTMLExtension implements IHTMLExtension {
this.styleURL = contextPath + theme + "css/report.css";
}
this.contextPath = contextPath;
this.processID = processID;
}
@Override
@ -84,7 +95,7 @@ public class HTMLExtension implements IHTMLExtension {
@Override
public void extendIDColumn(int row, ConcreteElement columnElement, a href,
PrintDataElement dataElement) {
href.addAttribute("onclick", "parent.idempiere.showColumnMenu(document, event, '" + dataElement.getColumnName() + "', " + row + ", " + ThemeManager.isUseFontIconForImage() + ")");
href.addAttribute("onclick", "parent.idempiere.showColumnMenu(document, event, '" + dataElement.getColumnName() + "', " + row + ", " + ThemeManager.isUseFontIconForImage() + ", " + processID + ")");
href.addAttribute ("componentId", componentId);
href.addAttribute ("foreignColumnName", dataElement.getForeignColumnName());
href.addAttribute ("value", dataElement.getValueAsString());

View File

@ -15,10 +15,10 @@ window.idempiere.zoomWindow = function(cmpid, column, value, windowuu){
zAu.send(event);
};
window.idempiere.drillAcross = function(cmpid, column, value, displayValue){
window.idempiere.drillAcross = function(cmpid, column, value, displayValue, processID){
zAu.cmd0.showBusy(null);
let widget = zk.Widget.$(cmpid);
let event = new zk.Event(widget, 'onDrillAcross', {data: [column, value, displayValue]}, {toServer: true});
let event = new zk.Event(widget, 'onDrillAcross', {data: [column, value, displayValue, processID]}, {toServer: true});
zAu.send(event);
};
@ -29,8 +29,8 @@ window.idempiere.drillDown = function(cmpid, column, value){
zAu.send(event);
};
window.idempiere.showColumnMenu = function(doc, e, columnName, row, isUseFontIcons) {
let d = idempiere.getMenu (doc, e.target.getAttribute ("componentId"), e.target.getAttribute ("foreignColumnName"), e.target.getAttribute ("value"), e.target.getAttribute ("displayValue"), isUseFontIcons);
window.idempiere.showColumnMenu = function(doc, e, columnName, row, isUseFontIcons, processID) {
let d = idempiere.getMenu (doc, e.target.getAttribute ("componentId"), e.target.getAttribute ("foreignColumnName"), e.target.getAttribute ("value"), e.target.getAttribute ("displayValue"), isUseFontIcons, processID);
let posx = 0;
let posy = 0;
@ -56,7 +56,7 @@ window.idempiere.showColumnMenu = function(doc, e, columnName, row, isUseFontIco
setTimeout(f, 3000);
};
window.idempiere.getMenu = function(doc, componentId, foreignColumnName, value, displayValue, isUseFontIcons){
window.idempiere.getMenu = function(doc, componentId, foreignColumnName, value, displayValue, isUseFontIcons, processID){
doc.contextMenu = null;
if (componentId != null){
//menu div
@ -157,7 +157,8 @@ window.idempiere.getMenu = function(doc, componentId, foreignColumnName, value,
reportDrillHref.style.textDecorationColor = "inherit";
reportDrillHref.style.fontSize = "11px";
reportDrillHref.style.verticalAlign = "middle";
reportDrillHref.setAttribute("onclick", "parent.idempiere.drillAcross('" + componentId + "','" + foreignColumnName + "','" + value + "','" + displayValue + "')");
console.log(processID);
reportDrillHref.setAttribute("onclick", "parent.idempiere.drillAcross('" + componentId + "','" + foreignColumnName + "','" + value + "','" + displayValue + "','" + processID + "')");
let drillIco = doc.body.getAttribute ("drillAssistantIco");
if (typeof drillIco === 'string' && drillIco.length > 0) {