mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[ACS-4985] Updated query generation logic. Now both 'In the last' and 'Between' options use the start date to end date query format
This commit is contained in:
committed by
Jatin_Chugh
parent
c4aaa8ff59
commit
d4de517a03
+19
-2
@@ -180,9 +180,26 @@ export class SearchDateRangeAdvancedTabbedComponent implements SearchWidget, OnI
|
||||
private generateQuery(value: Partial<SearchDateRangeAdvanced>, field: string): string {
|
||||
let query = '';
|
||||
if (value.dateRangeType === DateRangeType.IN_LAST) {
|
||||
query = `${field}:[NOW/DAY-${value.inLastValue}${value.inLastValueType} TO NOW/DAY+1DAY]`;
|
||||
switch(value.inLastValueType) {
|
||||
case InLastDateType.DAYS:
|
||||
startDate = startOfDay(subDays(new Date(), parseInt(value.inLastValue)));
|
||||
break;
|
||||
case InLastDateType.WEEKS:
|
||||
startDate = startOfWeek(subWeeks(new Date(), parseInt(value.inLastValue)));
|
||||
break;
|
||||
case InLastDateType.MONTHS:
|
||||
startDate = startOfMonth(subMonths(new Date(), parseInt(value.inLastValue)));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
endDate = endOfToday();
|
||||
} else if (value.dateRangeType === DateRangeType.BETWEEN) {
|
||||
query = `${field}:['${formatISO(startOfDay(value.betweenStartDate))}' TO '${formatISO(endOfDay(value.betweenEndDate))}']`;
|
||||
startDate = startOfDay(value.betweenStartDate);
|
||||
endDate = endOfDay(value.betweenEndDate);
|
||||
}
|
||||
if (startDate && endDate) {
|
||||
query = `${field}:['${formatISO(startDate)}' TO '${formatISO(endDate)}']`;
|
||||
}
|
||||
return query;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user