IDEMPIERE-1540 Autocomplete for field type "Search" (#88)

Fix search column for auto complete
This commit is contained in:
hengsin 2020-05-30 00:08:39 +08:00 committed by GitHub
parent ed7952945a
commit fc56a2a205
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 50 additions and 8 deletions

View File

@ -20,6 +20,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
@ -618,7 +619,12 @@ public class MLookupFactory
retValue.DisplayColumn = lookupDisplayColumn;
retValue.InfoWindowId = infoWindowId;
retValue.QueryDirect = MRole.getDefault().addAccessSQL(directQuery, TableName, true, false);
List<String> lookupDisplayColumns = new ArrayList<String>();
if (isValueDisplayed)
lookupDisplayColumns.add("Value");
lookupDisplayColumns.add(lookupDisplayColumn != null ? lookupDisplayColumn : DisplayColumn);
s_cacheRefTable.put(key.toString(), retValue.cloneIt());
retValue.lookupDisplayColumns = lookupDisplayColumns;
return retValue;
} // getLookup_Table
@ -850,6 +856,11 @@ public class MLookupFactory
msginf.toString(), ZoomWindow, ZoomWindowPO, zoomQuery);
lInfo.DisplayColumn = displayColumn.toString();
lInfo.QueryDirect = MRole.getDefault().addAccessSQL(directQuery, TableName, true, false);
List<String> lookupDisplayColumns = new ArrayList<String>();
for (LookupDisplayColumn ldc : list) {
lookupDisplayColumns.add(ldc.ColumnName);
}
lInfo.lookupDisplayColumns = lookupDisplayColumns;
s_cacheRefTable.put(cacheKey.toString(), lInfo.cloneIt());
return lInfo;
} // getLookup_TableDir

View File

@ -20,6 +20,7 @@ import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
@ -207,6 +208,8 @@ public class MLookupInfo implements Serializable, Cloneable
public String DisplayColumn;
public int InfoWindowId;
public List<String> lookupDisplayColumns = null;
/**
* String representation

View File

@ -21,6 +21,7 @@ import static org.compiere.model.SystemIDs.COLUMN_C_INVOICELINE_M_PRODUCT_ID;
import static org.compiere.model.SystemIDs.COLUMN_C_INVOICE_C_BPARTNER_ID;
import java.beans.PropertyChangeEvent;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
@ -226,6 +227,15 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
.append(",")
.append("pagesize:")
.append(MAX_AUTO_COMPLETE_ROWS);
if (lookup instanceof MLookup) {
MLookup mlookup = (MLookup) lookup;
List<String> displayColumns = mlookup.getLookupInfo().lookupDisplayColumns;
if (displayColumns != null && displayColumns.size() > 0) {
query.append(",")
.append("searchcolumn:")
.append(displayColumns.get(0));
}
}
query.append("}");
s = query.toString();
}

View File

@ -506,8 +506,11 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
isQueryByUser = true;
for (int i = 0; i < identifiers.size(); i++) {
WEditor editor = identifiers.get(i);
if (isAutoComplete && i > 0) {
break;
if (isAutoComplete) {
if (!Util.isEmpty(autoCompleteSearchColumn)) {
if (!editor.getColumnName().equals(autoCompleteSearchColumn))
continue;
}
}
try{
editor.setValue(queryValue);
@ -516,6 +519,8 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
}
testCount(false);
if (isAutoComplete)
break;
if (m_count > 0) {
break;
} else {
@ -1452,8 +1457,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
row.appendChild(checkAND);
}
}
if (!isAutoComplete)
evalDisplayLogic();
evalDisplayLogic();
if (!update)
initParameters();
if (!isAutoComplete)

View File

@ -160,22 +160,32 @@ public class InfoGeneralPanel extends InfoPanel implements EventListener<Event>
if (queryValue != null && queryValue.length() > 0)
{
Textbox[] txts = new Textbox[] {txt1, txt2, txt3, txt4};
int i = 0;
for(Textbox t : txts)
{
if (t != null && t.isVisible())
{
if (isAutoComplete)
{
if (!Util.isEmpty(autoCompleteSearchColumn))
{
if (!autoCompleteSearchColumn.equals(m_queryColumns.get(i)))
continue;
}
}
t.setValue(queryValue);
testCount();
if (m_count <= 0)
t.setValue(null);
else
break;
if (isAutoComplete)
break;
}
if (isAutoComplete)
break;
i++;
}
if (m_count <= 0)
if (m_count <= 0 && !isAutoComplete)
{
txt1.setValue(queryValue);
}

View File

@ -318,6 +318,8 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
if (t > 0)
this.pageSize = t;
} catch (Exception e) {}
} else if (pair[0].equalsIgnoreCase("searchcolumn")) {
this.autoCompleteSearchColumn = pair[1];
}
}
}
@ -462,6 +464,8 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
protected int queryTimeout = 0;
protected String autoCompleteSearchColumn = null;
protected String queryValue;
/**