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
This commit is contained in:
hengsin 2022-03-06 04:50:04 +08:00 committed by GitHub
parent 89a1d0cd23
commit 73c63e2cf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 2 deletions

View File

@ -86,7 +86,17 @@ import org.zkoss.zul.Menuitem;
public class WTableDirEditor extends WEditor implements ListDataListener, public class WTableDirEditor extends WEditor implements ListDataListener,
ContextMenuListener, IZoomableEditor 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") @SuppressWarnings("unused")
private static final CLogger logger; private static final CLogger logger;
@ -207,6 +217,13 @@ ContextMenuListener, IZoomableEditor
getComponent().addScrollSelectedIntoViewListener(); 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; boolean zoom= false;
if (lookup != null) if (lookup != null)
{ {
@ -537,7 +554,7 @@ ContextMenuListener, IZoomableEditor
gridField.setLookupEditorSettingValue(false); gridField.setLookupEditorSettingValue(false);
} }
} }
if (newValue != null) if (newValue != null && !MSysConfig.getBooleanValue(MSysConfig.ZK_AUTO_SAVE_CHANGES, false, Env.getAD_Client_ID(Env.getCtx())))
focusNext(); focusNext();
} finally { } finally {
onselecting = false; onselecting = false;