IDEMPIERE-5443 Date Range Filter Component (#1551)

- Fix issue with non-date field
This commit is contained in:
hengsin 2022-11-08 20:34:16 +08:00 committed by GitHub
parent 193141324e
commit c926c05d4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 36 additions and 30 deletions

View File

@ -1224,44 +1224,44 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
{ {
cellQueryFrom.setAttribute("value", value); // Elaine 2009/03/16 - set attribute value cellQueryFrom.setAttribute("value", value); // Elaine 2009/03/16 - set attribute value
//Attribute Values Parsing //Attribute Values Parsing
if(tableName.equals(MAttribute.COLUMNNAME_M_Attribute_ID)) if(tableName.equals(MAttribute.COLUMNNAME_M_Attribute_ID))
{ {
cellQueryFrom.appendChild(parseAttributeString( Integer.valueOf(columnName), value, listItem, false)); cellQueryFrom.appendChild(parseAttributeString( Integer.valueOf(columnName), value, listItem, false));
} }
else else
{ {
editorFrom = parseString(getTargetMField(columnName), value, listItem, false); editorFrom = parseString(getTargetMField(columnName), value, listItem, false);
if (editorFrom != null) if (editorFrom != null)
cellQueryFrom.appendChild(editorFrom.getComponent()); cellQueryFrom.appendChild(editorFrom.getComponent());
} }
} }
// QueryTo // QueryTo
WEditor editorTo = null; WEditor editorTo = null;
String value2 = fields.length > INDEX_VALUE2 ? fields[INDEX_VALUE2] : ""; String value2 = fields.length > INDEX_VALUE2 ? fields[INDEX_VALUE2] : "";
if(value2.length() > 0) if(value2.length() > 0)
{ {
cellQueryTo.setAttribute("value", value2); // Elaine 2009/03/16 - set attribute value cellQueryTo.setAttribute("value", value2); // Elaine 2009/03/16 - set attribute value
// Attribute Parsing // Attribute Parsing
if(tableName.equals(MAttribute.COLUMNNAME_M_Attribute_ID)) if(tableName.equals(MAttribute.COLUMNNAME_M_Attribute_ID))
{ {
cellQueryTo.appendChild(parseAttributeString( Integer.valueOf(columnName), value2, listItem, true)); cellQueryTo.appendChild(parseAttributeString( Integer.valueOf(columnName), value2, listItem, true));
} }
else else
{
editorTo = parseString(getTargetMField(columnName), value2, listItem, true);
if (editorTo != null)
{ {
if (editorFrom != null && editorFrom.getGridField() != null && DisplayType.isDate(editorFrom.getGridField().getDisplayType())) editorTo = parseString(getTargetMField(columnName), value2, listItem, true);
if (editorTo != null)
{ {
Div div = createDateRangeWrapper(editorFrom, editorTo); if (editorFrom != null && editorFrom.getGridField() != null && DisplayType.isDate(editorFrom.getGridField().getDisplayType()))
cellQueryTo.appendChild(div); {
} Div div = createDateRangeWrapper(editorFrom, editorTo);
else cellQueryTo.appendChild(div);
{ }
cellQueryTo.appendChild(editorTo.getComponent()); else
{
cellQueryTo.appendChild(editorTo.getComponent());
}
} }
} }
}
} }
// AndOr // AndOr
@ -1593,18 +1593,24 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
m_sEditorsFlag.add(editorFlag); m_sEditorsFlag.add(editorFlag);
editorFlag.setMode("toggle"); editorFlag.setMode("toggle");
div.appendChild(editorFlag); div.appendChild(editorFlag);
div.appendChild(fieldEditorTo); div.appendChild(fieldEditorTo);
DateRangeButton drb = new DateRangeButton(editor, editorTo); DateRangeButton drb = null;
div.appendChild(drb); if (editor.getGridField() != null && DisplayType.isDate(editor.getGridField().getDisplayType()))
{
drb = new DateRangeButton(editor, editorTo);
div.appendChild(drb);
drb.setVisible(false);
}
fieldEditorTo.setVisible(false); fieldEditorTo.setVisible(false);
drb.setVisible(false);
final Component editorRef = fieldEditorTo; final Component editorRef = fieldEditorTo;
final DateRangeButton drbRef = drb;
editorFlag.addEventListener(Events.ON_CHECK, new EventListener<Event>() { editorFlag.addEventListener(Events.ON_CHECK, new EventListener<Event>() {
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
ToolBarButton btn = (ToolBarButton) event.getTarget(); ToolBarButton btn = (ToolBarButton) event.getTarget();
editorRef.setVisible(btn.isChecked()); editorRef.setVisible(btn.isChecked());
drb.setVisible(editorRef.isVisible()); if (drbRef != null)
drbRef.setVisible(editorRef.isVisible());
} }
}); });
m_sEditorsTo.add(editorTo); m_sEditorsTo.add(editorTo);