From 063788242c9edda8e8ef8e0afec36de7a85450f2 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Fri, 4 Mar 2022 02:51:43 +0100 Subject: [PATCH] IDEMPIERE-5218 Improvements for Record Info dialog (#1219) * IDEMPIERE-5218 Improvements for Record Info dialog #resolve #comment Permalink as a button + new button Copy SELECT * Use navigator.clipboard and PO.get_WhereClause - as suggested by Heng Sin --- .../i9/oracle/202203031428_IDEMPIERE-5218.sql | 18 ++++++++++ .../202203031428_IDEMPIERE-5218.sql | 15 ++++++++ .../adempiere/webui/window/WRecordInfo.java | 35 ++++++++++++++++--- 3 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 migration/i9/oracle/202203031428_IDEMPIERE-5218.sql create mode 100644 migration/i9/postgresql/202203031428_IDEMPIERE-5218.sql diff --git a/migration/i9/oracle/202203031428_IDEMPIERE-5218.sql b/migration/i9/oracle/202203031428_IDEMPIERE-5218.sql new file mode 100644 index 0000000000..3647353104 --- /dev/null +++ b/migration/i9/oracle/202203031428_IDEMPIERE-5218.sql @@ -0,0 +1,18 @@ +-- IDEMPIERE-5218 Improvements for Record Info dialog +SELECT register_migration_script('202203031428_IDEMPIERE-5218.sql') FROM dual; + +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Mar 3, 2022, 2:28:28 PM CET +UPDATE AD_Message SET MsgText='Click to copy a permanent link to this record',Updated=TO_TIMESTAMP('2022-03-03 14:28:28','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200370 +; + +-- Mar 3, 2022, 2:29:07 PM CET +INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Copy SELECT',0,0,'Y',TO_TIMESTAMP('2022-03-03 14:29:06','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-03-03 14:29:06','YYYY-MM-DD HH24:MI:SS'),100,200733,'CopySelect','D','441bb105-9f59-44db-a9bc-a1873f3678e3') +; + +-- Mar 3, 2022, 2:29:34 PM CET +INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Click to copy a SELECT SQL query pointing to this record',0,0,'Y',TO_TIMESTAMP('2022-03-03 14:29:33','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-03-03 14:29:33','YYYY-MM-DD HH24:MI:SS'),100,200734,'CopySelect_tooltip','D','8f403aaf-6fe4-4fdb-9630-5ec81cd03a4e') +; + diff --git a/migration/i9/postgresql/202203031428_IDEMPIERE-5218.sql b/migration/i9/postgresql/202203031428_IDEMPIERE-5218.sql new file mode 100644 index 0000000000..7e0fbe2cc6 --- /dev/null +++ b/migration/i9/postgresql/202203031428_IDEMPIERE-5218.sql @@ -0,0 +1,15 @@ +-- IDEMPIERE-5218 Improvements for Record Info dialog +SELECT register_migration_script('202203031428_IDEMPIERE-5218.sql') FROM dual; + +-- Mar 3, 2022, 2:28:28 PM CET +UPDATE AD_Message SET MsgText='Click to copy a permanent link to this record',Updated=TO_TIMESTAMP('2022-03-03 14:28:28','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200370 +; + +-- Mar 3, 2022, 2:29:07 PM CET +INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Copy SELECT',0,0,'Y',TO_TIMESTAMP('2022-03-03 14:29:06','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-03-03 14:29:06','YYYY-MM-DD HH24:MI:SS'),100,200733,'CopySelect','D','441bb105-9f59-44db-a9bc-a1873f3678e3') +; + +-- Mar 3, 2022, 2:29:34 PM CET +INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Click to copy a SELECT SQL query pointing to this record',0,0,'Y',TO_TIMESTAMP('2022-03-03 14:29:33','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-03-03 14:29:33','YYYY-MM-DD HH24:MI:SS'),100,200734,'CopySelect_tooltip','D','8f403aaf-6fe4-4fdb-9630-5ec81cd03a4e') +; + diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WRecordInfo.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WRecordInfo.java index eb56f61344..101694529a 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WRecordInfo.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WRecordInfo.java @@ -59,7 +59,7 @@ import org.zkoss.zhtml.Text; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; -import org.zkoss.zul.A; +import org.zkoss.zk.ui.util.Clients; import org.zkoss.zul.Borderlayout; import org.zkoss.zul.Center; import org.zkoss.zul.Div; @@ -71,6 +71,7 @@ import org.zkoss.zul.North; import org.zkoss.zul.Radio; import org.zkoss.zul.Radiogroup; import org.zkoss.zul.South; +import org.zkoss.zul.Toolbarbutton; /** * Record Info (Who) With Change History @@ -145,7 +146,9 @@ public class WRecordInfo extends Window implements EventListener /** Info */ private StringBuffer m_info = new StringBuffer(); /** Permalink */ - private A m_permalink = new A(); + private Toolbarbutton m_permalink = new Toolbarbutton(); + /** Copy Select */ + private Toolbarbutton m_copySelect = new Toolbarbutton(); /** Date Time Format */ private SimpleDateFormat m_dateTimeFormat = DisplayType.getDateFormat @@ -241,14 +244,15 @@ public class WRecordInfo extends Window implements EventListener south.setSclass("dialog-footer"); south.setParent(layout); // - m_permalink.setTarget("_blank"); m_permalink.setLabel(Msg.getMsg(Env.getCtx(), "Permalink")); m_permalink.setTooltiptext(Msg.getMsg(Env.getCtx(), "Permalink_tooltip")); + m_copySelect.setLabel(Msg.getMsg(Env.getCtx(), "CopySelect")); + m_copySelect.setTooltiptext(Msg.getMsg(Env.getCtx(), "CopySelect_tooltip")); Hbox hbox = new Hbox(); hbox.setWidth("100%"); south.appendChild(hbox); - ZKUpdateUtil.setHflex(m_permalink, "true"); hbox.appendChild(m_permalink); + hbox.appendChild(m_copySelect); ZKUpdateUtil.setHflex(confirmPanel, "true"); hbox.appendChild(confirmPanel); @@ -341,8 +345,29 @@ public class WRecordInfo extends Window implements EventListener } if (!Util.isEmpty(uuid)) m_info.append("\n ").append(uuidcol).append("=").append(uuid); - m_permalink.setHref(AEnv.getZoomUrlTableID(po)); + if (po.get_KeyColumns().length == 1) { + m_permalink.addEventListener(Events.ON_CLICK, new EventListener() { + public void onEvent(Event event) throws Exception { + String ticketURL = AEnv.getZoomUrlTableID(po); + StringBuffer sb = new StringBuffer("navigator.clipboard.writeText(\"") + .append(ticketURL) + .append("\");"); + Clients.evalJavaScript(sb.toString()); + } + }); + } m_permalink.setVisible(po.get_KeyColumns().length == 1); + m_copySelect.addEventListener(Events.ON_CLICK, new EventListener() { + public void onEvent(Event event) throws Exception { + StringBuffer query = new StringBuffer("navigator.clipboard.writeText(\"SELECT * FROM ") + .append(po.get_TableName()) + .append(" WHERE ") + .append(po.get_WhereClause(true)); + query.append("\");"); + Clients.evalJavaScript(query.toString()); + } + }); + m_copySelect.setVisible(true); } } if (gridTab != null)