From 1bd350459306715aa771766d0e178c574a61b6d3 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Tue, 18 Nov 2025 10:29:49 -0800 Subject: [PATCH] Fix relative date display hint --- .../dates-dropdown.component.html | 20 +++++++++++-- .../dates-dropdown.component.ts | 28 ++++++++++++++++--- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/src-ui/src/app/components/common/dates-dropdown/dates-dropdown.component.html b/src-ui/src/app/components/common/dates-dropdown/dates-dropdown.component.html index 9b243d907..538f79fe8 100644 --- a/src-ui/src/app/components/common/dates-dropdown/dates-dropdown.component.html +++ b/src-ui/src/app/components/common/dates-dropdown/dates-dropdown.component.html @@ -26,7 +26,15 @@ i18n-placeholder (change)="onSetCreatedRelativeDate($event)"> -
{{ item.name }}{{ item.date | customDate:'mediumDate' }} – now
+
{{ item.name }} + + @if (item.dateEnd) { + {{ item.date | customDate:'MMM d' }} – {{ item.dateEnd | customDate:'mediumDate' }} + } @else { + {{ item.date | customDate:'mediumDate' }} – now + } + +
@@ -102,7 +110,15 @@ i18n-placeholder (change)="onSetAddedRelativeDate($event)"> -
{{ item.name }}{{ item.date | customDate:'mediumDate' }} – now
+
{{ item.name }} + + @if (item.dateEnd) { + {{ item.date | customDate:'MMM d' }} – {{ item.dateEnd | customDate:'mediumDate' }} + } @else { + {{ item.date | customDate:'mediumDate' }} – now + } + +
diff --git a/src-ui/src/app/components/common/dates-dropdown/dates-dropdown.component.ts b/src-ui/src/app/components/common/dates-dropdown/dates-dropdown.component.ts index fa9bd622b..e5d64ddc6 100644 --- a/src-ui/src/app/components/common/dates-dropdown/dates-dropdown.component.ts +++ b/src-ui/src/app/components/common/dates-dropdown/dates-dropdown.component.ts @@ -118,22 +118,42 @@ export class DatesDropdownComponent implements OnInit, OnDestroy { { id: RelativeDate.PREVIOUS_WEEK, name: $localize`Previous week`, - date: null, + date: new Date( + new Date().getFullYear(), + new Date().getMonth(), + new Date().getDate() - new Date().getDay() - 6 + ), + dateEnd: new Date( + new Date().getFullYear(), + new Date().getMonth(), + new Date().getDate() - new Date().getDay() + ), }, { id: RelativeDate.PREVIOUS_MONTH, name: $localize`Previous month`, - date: null, + date: new Date(new Date().getFullYear(), new Date().getMonth() - 1, 1), + dateEnd: new Date(new Date().getFullYear(), new Date().getMonth(), 0), }, { id: RelativeDate.PREVIOUS_QUARTER, name: $localize`Previous quarter`, - date: null, + date: new Date( + new Date().getFullYear(), + Math.floor(new Date().getMonth() / 3) * 3 - 3, + 1 + ), + dateEnd: new Date( + new Date().getFullYear(), + Math.floor(new Date().getMonth() / 3) * 3, + 0 + ), }, { id: RelativeDate.PREVIOUS_YEAR, name: $localize`Previous year`, - date: null, + date: new Date('1/1/' + (new Date().getFullYear() - 1)), + dateEnd: new Date('12/31/' + (new Date().getFullYear() - 1)), }, ]