Fix relative date display hint

This commit is contained in:
shamoon 2025-11-18 10:29:49 -08:00
parent e6b0b94ac4
commit 1bd3504593
2 changed files with 42 additions and 6 deletions

View file

@ -26,7 +26,15 @@
i18n-placeholder i18n-placeholder
(change)="onSetCreatedRelativeDate($event)"> (change)="onSetCreatedRelativeDate($event)">
<ng-template ng-option-tmp let-item="item"> <ng-template ng-option-tmp let-item="item">
<div class="d-flex">{{ item.name }}<span class="ms-auto text-muted small">{{ item.date | customDate:'mediumDate' }} &ndash; <ng-container i18n>now</ng-container></span></div> <div class="d-flex">{{ item.name }}
<span class="ms-auto text-muted small">
@if (item.dateEnd) {
{{ item.date | customDate:'MMM d' }} &ndash; {{ item.dateEnd | customDate:'mediumDate' }}
} @else {
{{ item.date | customDate:'mediumDate' }} &ndash; <ng-container i18n>now</ng-container>
}
</span>
</div>
</ng-template> </ng-template>
</ng-select> </ng-select>
</div> </div>
@ -102,7 +110,15 @@
i18n-placeholder i18n-placeholder
(change)="onSetAddedRelativeDate($event)"> (change)="onSetAddedRelativeDate($event)">
<ng-template ng-option-tmp let-item="item"> <ng-template ng-option-tmp let-item="item">
<div class="d-flex">{{ item.name }}<span class="ms-auto text-muted small">{{ item.date | customDate:'mediumDate' }} &ndash; <ng-container i18n>now</ng-container></span></div> <div class="d-flex">{{ item.name }}
<span class="ms-auto text-muted small">
@if (item.dateEnd) {
{{ item.date | customDate:'MMM d' }} &ndash; {{ item.dateEnd | customDate:'mediumDate' }}
} @else {
{{ item.date | customDate:'mediumDate' }} &ndash; <ng-container i18n>now</ng-container>
}
</span>
</div>
</ng-template> </ng-template>
</ng-select> </ng-select>
</div> </div>

View file

@ -118,22 +118,42 @@ export class DatesDropdownComponent implements OnInit, OnDestroy {
{ {
id: RelativeDate.PREVIOUS_WEEK, id: RelativeDate.PREVIOUS_WEEK,
name: $localize`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, id: RelativeDate.PREVIOUS_MONTH,
name: $localize`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, id: RelativeDate.PREVIOUS_QUARTER,
name: $localize`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, id: RelativeDate.PREVIOUS_YEAR,
name: $localize`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)),
}, },
] ]