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:
2023-02-13 10:46:59 -06:00
parent 6215e58e23
commit a10cee86a8
7 changed files with 145 additions and 8 deletions

View File

@ -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),

View File

@ -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))