Update to format dates (e.g., from query string), so that they show up

This commit is contained in:
2022-10-05 12:34:27 -05:00
parent 5cdc15a498
commit c87871860e
2 changed files with 27 additions and 2 deletions

View File

@ -105,7 +105,7 @@ function getDefaultFilter(tableMetaData: QTableMetaData, searchParams: URLSearch
defaultFilter.items.push({ defaultFilter.items.push({
columnField: criteria.fieldName, columnField: criteria.fieldName,
operatorValue: QFilterUtils.qqqCriteriaOperatorToGrid(criteria.operator, fieldType, criteria.values), operatorValue: QFilterUtils.qqqCriteriaOperatorToGrid(criteria.operator, fieldType, criteria.values),
value: QFilterUtils.qqqCriteriaValuesToGrid(criteria.operator, criteria.values), value: QFilterUtils.qqqCriteriaValuesToGrid(criteria.operator, criteria.values, fieldType),
id: id++, // not sure what this id is!! id: id++, // not sure what this id is!!
}); });
}); });

View File

@ -231,7 +231,7 @@ class QFilterUtils
/******************************************************************************* /*******************************************************************************
** **
*******************************************************************************/ *******************************************************************************/
public static qqqCriteriaValuesToGrid = (operator: QCriteriaOperator, values: any[]): any | any[] => public static qqqCriteriaValuesToGrid = (operator: QCriteriaOperator, values: any[], fieldType: QFieldType): any | any[] =>
{ {
if (operator === QCriteriaOperator.IS_BLANK || operator === QCriteriaOperator.IS_NOT_BLANK) if (operator === QCriteriaOperator.IS_BLANK || operator === QCriteriaOperator.IS_NOT_BLANK)
{ {
@ -242,6 +242,31 @@ class QFilterUtils
return (values); return (values);
} }
if(values.length > 0)
{
////////////////////////////////////////////////////////////////////////////////////////////////
// make sure dates are formatted for the grid the way it expects - not the way we pass it in. //
////////////////////////////////////////////////////////////////////////////////////////////////
if (fieldType === QFieldType.DATE_TIME)
{
const inputValue = values[0];
if(inputValue.match(/^\d{4}-\d{2}-\d{2}$/))
{
//////////////////////////////////////////////////////////////////
// if we just passed in a date (w/o time), attach T00:00 to it. //
//////////////////////////////////////////////////////////////////
values[0] = inputValue + "T00:00";
}
else if(inputValue.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}.*/))
{
///////////////////////////////////////////////////////////////////////////////////
// if we passed in something too long (e.g., w/ seconds and fractions), trim it. //
///////////////////////////////////////////////////////////////////////////////////
values[0] = inputValue.substring(0, 16);
}
}
}
return (values[0]); return (values[0]);
}; };
} }