mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-17 21:00:45 +00:00
Update to format dates (e.g., from query string), so that they show up
This commit is contained in:
@ -105,7 +105,7 @@ function getDefaultFilter(tableMetaData: QTableMetaData, searchParams: URLSearch
|
||||
defaultFilter.items.push({
|
||||
columnField: criteria.fieldName,
|
||||
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!!
|
||||
});
|
||||
});
|
||||
|
@ -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)
|
||||
{
|
||||
@ -242,6 +242,31 @@ class QFilterUtils
|
||||
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]);
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user