Browse Source

Extend Datarange options

pull/5027/head
Dan 4 months ago
parent
commit
b72316817e
  1. 10
      libs/common/src/lib/calculation-helper.ts
  2. 13
      libs/ui/src/lib/assistant/assistant.component.ts

10
libs/common/src/lib/calculation-helper.ts

@ -7,6 +7,7 @@ import {
startOfWeek,
startOfYear,
subDays,
subMonths,
subYears
} from 'date-fns';
import { isNumber } from 'lodash';
@ -55,12 +56,21 @@ export function getIntervalFromDateRange(
subDays(startOfWeek(resetHours(new Date()), { weekStartsOn: 1 }), 1)
]);
break;
case '1w':
startDate = max([startDate, subDays(resetHours(new Date()), 7)]);
break;
case 'ytd':
startDate = max([
startDate,
subDays(startOfYear(resetHours(new Date())), 1)
]);
break;
case '1m':
startDate = max([startDate, subMonths(resetHours(new Date()), 1)]);
break;
case '3m':
startDate = max([startDate, subMonths(resetHours(new Date()), 3)]);
break;
case '1y':
startDate = max([startDate, subYears(resetHours(new Date()), 1)]);
break;

13
libs/ui/src/lib/assistant/assistant.component.ts

@ -222,10 +222,23 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
label: $localize`Week to date` + ' (' + $localize`WTD` + ')',
value: 'wtd'
},
{
label: '1 ' + $localize`Week` + ' (' + $localize`1W` + ')',
value: '1w'
},
{
label: $localize`Month to date` + ' (' + $localize`MTD` + ')',
value: 'mtd'
},
{
label: '1 ' + $localize`Month` + ' (' + $localize`1M` + ')',
value: '1m'
},
{
label: '3 ' + $localize`Month` + ' (' + $localize`3M` + ')',
value: '3m'
},
{
label: $localize`Year to date` + ' (' + $localize`YTD` + ')',
value: 'ytd'

Loading…
Cancel
Save