IDEMPIERE-5135 : Add a link in a Broadcast message to open a record (#1105)
* IDEMPIERE-5135 : Add a link in a Broadcast message to open a record Credits go to devcoffee - sorry i didn't find Matheus Marcelino's github account Co-Authored-By: muriloht <5605206+muriloht@users.noreply.github.com> * IDEMPIERE-5135 : Add a link in a Broadcast message to open a record fix suggested by hengsin Co-authored-by: muriloht <5605206+muriloht@users.noreply.github.com>
This commit is contained in:
parent
a74f76dcc2
commit
79763f8626
|
@ -16,6 +16,7 @@ package org.adempiere.model;
|
|||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.model.X_AD_BroadcastMessage;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
@ -33,9 +34,9 @@ public class MBroadcastMessage extends X_AD_BroadcastMessage implements Immutabl
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -5402131480890468471L;
|
||||
|
||||
static private ImmutableIntPOCache<Integer,MBroadcastMessage> s_cache = new ImmutableIntPOCache<Integer,MBroadcastMessage>("AD_BroadcastMessage", 30, 60);
|
||||
private static final long serialVersionUID = 3124401616294213703L;
|
||||
public final static String CLIENTINFO_BROADCAST_COMPONENT_ID = "#clientInfo_BroadcastComponentId";
|
||||
static private ImmutableIntPOCache<Integer,MBroadcastMessage> s_cache = new ImmutableIntPOCache<Integer,MBroadcastMessage>("AD_BroadcastMessage", 30, 60);
|
||||
|
||||
public MBroadcastMessage(Properties ctx, int AD_BroadcastMessage_ID,
|
||||
String trxName)
|
||||
|
@ -176,4 +177,29 @@ public class MBroadcastMessage extends X_AD_BroadcastMessage implements Immutabl
|
|||
makeImmutable();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get_Translation (String columnName) {
|
||||
String translation = super.get_Translation(columnName);
|
||||
if (translation.indexOf('@') > 0)
|
||||
return Env.parseContext(getCtx(), 0, translation, false, false);
|
||||
|
||||
return translation;
|
||||
}
|
||||
|
||||
/** Returns a link to be used in broadcast messages to open a record
|
||||
* @param PO po
|
||||
* @param uuid of the window
|
||||
* @param text of the link
|
||||
* @return the text to set in the broadcast message
|
||||
* */
|
||||
public String getUrlZoom(PO po, String windowUUID, String text) {
|
||||
StringBuilder url = new StringBuilder("");
|
||||
url.append("<a href=\"javascript:void(0)\" class=\"rp-href\" onclick=\"window.idempiere.zoomWindow(@" + CLIENTINFO_BROADCAST_COMPONENT_ID + "@, '");
|
||||
url.append(po.get_KeyColumns()[0]);
|
||||
url.append("', '").append(po.get_ID()).append("','").append(windowUUID).append("')\">");
|
||||
url.append(text);
|
||||
|
||||
return url.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,12 +21,15 @@ import java.util.logging.Level;
|
|||
|
||||
import org.adempiere.exceptions.DBException;
|
||||
import org.adempiere.model.MBroadcastMessage;
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.component.Button;
|
||||
import org.adempiere.webui.component.Checkbox;
|
||||
import org.adempiere.webui.component.Label;
|
||||
import org.adempiere.webui.component.Window;
|
||||
import org.adempiere.webui.event.ZoomEvent;
|
||||
import org.adempiere.webui.util.ZKUpdateUtil;
|
||||
import org.compiere.model.MNote;
|
||||
import org.compiere.model.MQuery;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
@ -36,6 +39,7 @@ import org.zkoss.zk.ui.Component;
|
|||
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.util.Clients;
|
||||
import org.zkoss.zul.Borderlayout;
|
||||
import org.zkoss.zul.Cell;
|
||||
import org.zkoss.zul.Center;
|
||||
|
@ -114,11 +118,14 @@ public class BroadcastMessageWindow extends Window implements IBroadcastMsgPopup
|
|||
//textMsgContent = new Label();
|
||||
htmlDiv.appendChild(textMsgContent);
|
||||
center.setAutoscroll(true);
|
||||
Env.setContext(Env.getCtx(), MBroadcastMessage.CLIENTINFO_BROADCAST_COMPONENT_ID, pnlHead.getUuid());
|
||||
textMsgContent.setContent(mbMessages.get(0).get_Translation(MBroadcastMessage.COLUMNNAME_BroadcastMessage));
|
||||
pnlHead.addEventListener(ZoomEvent.EVENT_NAME, this);
|
||||
htmlDiv.setFocus(true);
|
||||
htmlDiv.setStyle("display: table-cell; vertical-align: middle; text-align: center;");
|
||||
Div divAlign = new Div();
|
||||
divAlign.setStyle("color:white; position: absolute; width: 370px; height: 120px; display: table;");
|
||||
|
||||
htmlDiv.setParent(divAlign);
|
||||
center.appendChild(divAlign);
|
||||
center.setBorder("rounded");
|
||||
|
@ -248,6 +255,13 @@ public class BroadcastMessageWindow extends Window implements IBroadcastMsgPopup
|
|||
hashMessages.put(mbMessages.get(currMsg).get_ID(), acknowledged.isChecked());
|
||||
}
|
||||
}
|
||||
else if(event.getName().equals(ZoomEvent.EVENT_NAME)) {
|
||||
Clients.clearBusy();
|
||||
ZoomEvent ze = (ZoomEvent) event;
|
||||
if (ze.getData() != null && ze.getData() instanceof MQuery) {
|
||||
AEnv.zoom((MQuery) ze.getData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue