mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-18 21:30:45 +00:00
Small updates to widgets; ok-ish version of filter query with relative time expressions; initial version of multi-select query for possible-values
This commit is contained in:
@ -344,7 +344,8 @@ class FilterUtils
|
||||
{
|
||||
try
|
||||
{
|
||||
const qQueryFilter = (filterString !== null) ? JSON.parse(filterString) : JSON.parse(searchParams.get("filter")) as QQueryFilter;
|
||||
const filterJSON = (filterString !== null) ? JSON.parse(filterString) : JSON.parse(searchParams.get("filter"));
|
||||
const qQueryFilter = filterJSON as QQueryFilter;
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// translate from a qqq-style filter to one that the grid wants //
|
||||
@ -377,6 +378,53 @@ class FilterUtils
|
||||
}
|
||||
}
|
||||
|
||||
if (field && field.type == "DATE_TIME" && !values)
|
||||
{
|
||||
try
|
||||
{
|
||||
const criteria = filterJSON.criteria[i];
|
||||
if (criteria && criteria.expression)
|
||||
{
|
||||
let value = new Date();
|
||||
let amount = Number(criteria.expression.amount);
|
||||
switch (criteria.expression.timeUnit)
|
||||
{
|
||||
case "MINUTES":
|
||||
{
|
||||
amount = amount * 60;
|
||||
break;
|
||||
}
|
||||
case "HOURS":
|
||||
{
|
||||
amount = amount * 60 * 60;
|
||||
break;
|
||||
}
|
||||
case "DAYS":
|
||||
{
|
||||
amount = amount * 60 * 60 * 24;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
console.log("Unrecognized time unit: " + criteria.expression.timeUnit);
|
||||
}
|
||||
}
|
||||
|
||||
if (criteria.expression.operator == "MINUS")
|
||||
{
|
||||
amount = -amount;
|
||||
}
|
||||
|
||||
value.setTime(value.getTime() + 1000 * amount);
|
||||
values = [ValueUtils.formatDateTimeISO8601(value)];
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
defaultFilter.items.push({
|
||||
columnField: criteria.fieldName,
|
||||
operatorValue: FilterUtils.qqqCriteriaOperatorToGrid(criteria.operator, field, values),
|
||||
|
@ -131,7 +131,7 @@ class ValueUtils
|
||||
|
||||
if (field.hasAdornment(AdornmentType.RENDER_HTML))
|
||||
{
|
||||
return (parse(rawValue));
|
||||
return (rawValue ? parse(rawValue) : "");
|
||||
}
|
||||
|
||||
if (field.hasAdornment(AdornmentType.CHIP))
|
||||
@ -253,6 +253,16 @@ class ValueUtils
|
||||
return (`${date.toString("yyyy-MM-dd hh:mm:ss")} ${date.getHours() < 12 ? "AM" : "PM"} ${date.getTimezone()}`);
|
||||
}
|
||||
|
||||
public static formatDateTimeISO8601(date: Date)
|
||||
{
|
||||
if(!(date instanceof Date))
|
||||
{
|
||||
date = new Date(date)
|
||||
}
|
||||
// @ts-ignore
|
||||
return (`${date.toString("yyyy-MM-ddThh:mm:ssZ")}`);
|
||||
}
|
||||
|
||||
public static getFullWeekday(date: Date)
|
||||
{
|
||||
if(!(date instanceof Date))
|
||||
|
Reference in New Issue
Block a user