IDEMPIERE-4651 Max records for Search autocomplete list should be configurable (#531)

This commit is contained in:
hengsin 2021-01-18 18:52:12 +08:00 committed by GitHub
parent fa8b7f1807
commit ebcf4b3e1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 5 deletions

View File

@ -0,0 +1,10 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Jan 18, 2021, 11:13:52 AM MYT
INSERT INTO AD_SysConfig (AD_SysConfig_ID,AD_Client_ID,AD_Org_ID,Created,Updated,CreatedBy,UpdatedBy,IsActive,Name,Value,Description,EntityType,ConfigurationLevel,AD_SysConfig_UU) VALUES (200168,0,0,TO_DATE('2021-01-18 11:13:51','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2021-01-18 11:13:51','YYYY-MM-DD HH24:MI:SS'),100,100,'Y','ZK_SEARCH_AUTO_COMPLETE_MAX_ROWS','500','Maximum number of rows to retrieve and display for search field''s autocomplete list','D','C','a54d5000-57db-42f7-a910-06ea1e1fd245')
;
SELECT register_migration_script('202001180340_IDEMPIERE-4651.sql') FROM dual
;

View File

@ -0,0 +1,7 @@
-- Jan 18, 2021, 11:13:52 AM MYT
INSERT INTO AD_SysConfig (AD_SysConfig_ID,AD_Client_ID,AD_Org_ID,Created,Updated,CreatedBy,UpdatedBy,IsActive,Name,Value,Description,EntityType,ConfigurationLevel,AD_SysConfig_UU) VALUES (200168,0,0,TO_TIMESTAMP('2021-01-18 11:13:51','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2021-01-18 11:13:51','YYYY-MM-DD HH24:MI:SS'),100,100,'Y','ZK_SEARCH_AUTO_COMPLETE_MAX_ROWS','500','Maximum number of rows to retrieve and display for search field''s autocomplete list','D','C','a54d5000-57db-42f7-a910-06ea1e1fd245')
;
SELECT register_migration_script('202001180340_IDEMPIERE-4651.sql') FROM dual
;

View File

@ -200,6 +200,7 @@ public class MSysConfig extends X_AD_SysConfig
public static final String ZK_REPORT_ONLY_PRINTFORMAT_LINKEDTO_REPORTVIEW = "ZK_REPORT_ONLY_PRINTFORMAT_LINKEDTO_REPORTVIEW"; public static final String ZK_REPORT_ONLY_PRINTFORMAT_LINKEDTO_REPORTVIEW = "ZK_REPORT_ONLY_PRINTFORMAT_LINKEDTO_REPORTVIEW";
public static final String ZK_REPORT_TABLE_OUTPUT_TYPE = "ZK_REPORT_TABLE_OUTPUT_TYPE"; public static final String ZK_REPORT_TABLE_OUTPUT_TYPE = "ZK_REPORT_TABLE_OUTPUT_TYPE";
public static final String ZK_ROOT_FOLDER_BROWSER = "ZK_ROOT_FOLDER_BROWSER"; public static final String ZK_ROOT_FOLDER_BROWSER = "ZK_ROOT_FOLDER_BROWSER";
public static final String ZK_SEARCH_AUTO_COMPLETE_MAX_ROWS = "ZK_SEARCH_AUTO_COMPLETE_MAX_ROWS";
public static final String ZK_SEQ_DEFAULT_VALUE_PANEL = "ZK_SEQ_DEFAULT_VALUE_PANEL"; public static final String ZK_SEQ_DEFAULT_VALUE_PANEL = "ZK_SEQ_DEFAULT_VALUE_PANEL";
public static final String ZK_SESSION_TIMEOUT_IN_SECONDS = "ZK_SESSION_TIMEOUT_IN_SECONDS"; public static final String ZK_SESSION_TIMEOUT_IN_SECONDS = "ZK_SESSION_TIMEOUT_IN_SECONDS";
public static final String ZK_THEME_USE_FONT_ICON_FOR_IMAGE = "ZK_THEME_USE_FONT_ICON_FOR_IMAGE"; public static final String ZK_THEME_USE_FONT_ICON_FOR_IMAGE = "ZK_THEME_USE_FONT_ICON_FOR_IMAGE";

View File

@ -37,6 +37,7 @@ import org.compiere.model.GridField;
import org.compiere.model.Lookup; import org.compiere.model.Lookup;
import org.compiere.model.MColumn; import org.compiere.model.MColumn;
import org.compiere.model.MLookup; import org.compiere.model.MLookup;
import org.compiere.model.MSysConfig;
import org.compiere.model.MTable; import org.compiere.model.MTable;
import org.compiere.model.X_AD_CtxHelp; import org.compiere.model.X_AD_CtxHelp;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
@ -70,7 +71,7 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen
private InfoListSubModel subModel = null; private InfoListSubModel subModel = null;
private static final CLogger log = CLogger.getCLogger(WChosenboxSearchEditor.class); private static final CLogger log = CLogger.getCLogger(WChosenboxSearchEditor.class);
private static final int MAX_AUTO_COMPLETE_ROWS = 50; private static final int DEFAULT_MAX_AUTO_COMPLETE_ROWS = 500;
private boolean onselecting; private boolean onselecting;
/** /**
@ -593,7 +594,8 @@ public class WChosenboxSearchEditor extends WEditor implements ContextMenuListen
@Override @Override
public ListModel<ValueNamePair> getSubModel(Object value, int nRows) { public ListModel<ValueNamePair> getSubModel(Object value, int nRows) {
subModel.setWhereClause(getWhereClause()); subModel.setWhereClause(getWhereClause());
ListModel<ValueNamePair> model = subModel.getSubModel(value, MAX_AUTO_COMPLETE_ROWS); int maxRows = MSysConfig.getIntValue(MSysConfig.ZK_SEARCH_AUTO_COMPLETE_MAX_ROWS, DEFAULT_MAX_AUTO_COMPLETE_ROWS, Env.getAD_Client_ID(Env.getCtx()));
ListModel<ValueNamePair> model = subModel.getSubModel(value, maxRows);
getComponent().getChosenbox().setSubListModel(model); getComponent().getChosenbox().setSubListModel(model);
return model; return model;
} }

View File

@ -78,7 +78,7 @@ import org.zkoss.zk.ui.util.Clients;
*/ */
public class WSearchEditor extends WEditor implements ContextMenuListener, ValueChangeListener, IZoomableEditor public class WSearchEditor extends WEditor implements ContextMenuListener, ValueChangeListener, IZoomableEditor
{ {
private static final int MAX_AUTO_COMPLETE_ROWS = 50; private static final int DEFAULT_MAX_AUTO_COMPLETE_ROWS = 500;
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_CHANGE, Events.ON_OK}; private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_CHANGE, Events.ON_OK};
public static final String ATTRIBUTE_IS_INFO_PANEL_OPEN = "ATTRIBUTE_IS_INFO_PANEL_OPEN"; public static final String ATTRIBUTE_IS_INFO_PANEL_OPEN = "ATTRIBUTE_IS_INFO_PANEL_OPEN";
private Lookup lookup; private Lookup lookup;
@ -228,13 +228,14 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
if (gridField != null && gridField.isAutocomplete()) { if (gridField != null && gridField.isAutocomplete()) {
setTableAndKeyColumn(); setTableAndKeyColumn();
listModel = new InfoListSubModel(lookup, gridField, m_tableName, m_keyColumnName); listModel = new InfoListSubModel(lookup, gridField, m_tableName, m_keyColumnName);
getComponent().getCombobox().setModel(listModel.getSubModel(null, MAX_AUTO_COMPLETE_ROWS)); int maxRows = MSysConfig.getIntValue(MSysConfig.ZK_SEARCH_AUTO_COMPLETE_MAX_ROWS, DEFAULT_MAX_AUTO_COMPLETE_ROWS, Env.getAD_Client_ID(Env.getCtx()));
getComponent().getCombobox().setModel(listModel.getSubModel(null, maxRows));
getComponent().getCombobox().addEventListener(Events.ON_CHANGING, (EventListener<InputEvent>)(e) -> { getComponent().getCombobox().addEventListener(Events.ON_CHANGING, (EventListener<InputEvent>)(e) -> {
if (!e.isChangingBySelectBack()) { if (!e.isChangingBySelectBack()) {
listModel.setWhereClause(getWhereClause()); listModel.setWhereClause(getWhereClause());
String s = e.getValue(); String s = e.getValue();
getComponent().getCombobox().setModel(listModel.getSubModel(s, MAX_AUTO_COMPLETE_ROWS)); getComponent().getCombobox().setModel(listModel.getSubModel(s, maxRows));
} }
}); });
} else { } else {