From 73c63e2cf2526d3f18ed1371d25a28d8c6a5ba1e Mon Sep 17 00:00:00 2001 From: hengsin Date: Sun, 6 Mar 2022 04:50:04 +0800 Subject: [PATCH] IDEMPIERE-5202 Implement auto save of current tab (#1226) * IDEMPIERE-5202 Implement auto save of current tab - Table/List Editor: auto drop upon focus works better for auto save. Without auto drop upon focus, auto save is trigger for every arrow up/down key stroke. * IDEMPIERE-5202 Implement auto save of current tab - Auto open the dropdown list upon pressing of up/down arrow key - Do not auto move focus to next field --- .../webui/editor/WTableDirEditor.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java index 6f20c5dfe4..3bcbe93998 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java @@ -86,7 +86,17 @@ import org.zkoss.zul.Menuitem; public class WTableDirEditor extends WEditor implements ListDataListener, ContextMenuListener, IZoomableEditor { - public final static String[] LISTENER_EVENTS = {Events.ON_SELECT}; + private static final String UP_PRESSED_OVERRIDE_SCRIPT = "function(evt) {" + + " if (!this.isOpen()) this.open();" + + " this.$upPressed_(evt);" + + "}"; + + private static final String DOWN_PRESSED_OVERRIDE_SCRIPT = "function(evt) {" + + " if (!this.isOpen()) this.open();" + + " this.$dnPressed_(evt);" + + "}"; + + public final static String[] LISTENER_EVENTS = {Events.ON_SELECT}; @SuppressWarnings("unused") private static final CLogger logger; @@ -207,6 +217,13 @@ ContextMenuListener, IZoomableEditor getComponent().addScrollSelectedIntoViewListener(); } + //auto open for up/down key + if (MSysConfig.getBooleanValue(MSysConfig.ZK_AUTO_SAVE_CHANGES, false, Env.getAD_Client_ID(Env.getCtx()))) + { + getComponent().setWidgetOverride("dnPressed_", DOWN_PRESSED_OVERRIDE_SCRIPT); + getComponent().setWidgetOverride("upPressed_", UP_PRESSED_OVERRIDE_SCRIPT); + } + boolean zoom= false; if (lookup != null) { @@ -537,7 +554,7 @@ ContextMenuListener, IZoomableEditor gridField.setLookupEditorSettingValue(false); } } - if (newValue != null) + if (newValue != null && !MSysConfig.getBooleanValue(MSysConfig.ZK_AUTO_SAVE_CHANGES, false, Env.getAD_Client_ID(Env.getCtx()))) focusNext(); } finally { onselecting = false;