mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-11-21 04:36:53 -06:00
Enhancement: add more relative dates, support modified (#11411)
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
i18n-placeholder
|
||||
(change)="onSetCreatedRelativeDate($event)">
|
||||
<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' }} – <ng-container i18n>now</ng-container></span></div>
|
||||
<ng-container [ngTemplateOutlet]="relativeDateOptionTemplate" [ngTemplateOutletContext]="{ $implicit: item }"></ng-container>
|
||||
</ng-template>
|
||||
</ng-select>
|
||||
</div>
|
||||
@@ -102,7 +102,7 @@
|
||||
i18n-placeholder
|
||||
(change)="onSetAddedRelativeDate($event)">
|
||||
<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' }} – <ng-container i18n>now</ng-container></span></div>
|
||||
<ng-container [ngTemplateOutlet]="relativeDateOptionTemplate" [ngTemplateOutletContext]="{ $implicit: item }"></ng-container>
|
||||
</ng-template>
|
||||
</ng-select>
|
||||
</div>
|
||||
@@ -158,3 +158,16 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ng-template #relativeDateOptionTemplate let-item>
|
||||
<div class="d-flex">
|
||||
{{ item.name }}
|
||||
<span class="ms-auto text-muted small">
|
||||
@if (item.dateEnd) {
|
||||
{{ item.date | customDate:'MMM d' }} – {{ item.dateEnd | customDate:'mediumDate' }}
|
||||
} @else {
|
||||
{{ item.date | customDate:'mediumDate' }} – <ng-container i18n>now</ng-container>
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { NgClass } from '@angular/common'
|
||||
import { NgClass, NgTemplateOutlet } from '@angular/common'
|
||||
import {
|
||||
Component,
|
||||
EventEmitter,
|
||||
@@ -42,6 +42,10 @@ export enum RelativeDate {
|
||||
THIS_MONTH = 6,
|
||||
TODAY = 7,
|
||||
YESTERDAY = 8,
|
||||
PREVIOUS_WEEK = 9,
|
||||
PREVIOUS_MONTH = 10,
|
||||
PREVIOUS_QUARTER = 11,
|
||||
PREVIOUS_YEAR = 12,
|
||||
}
|
||||
|
||||
@Component({
|
||||
@@ -59,6 +63,7 @@ export enum RelativeDate {
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
NgClass,
|
||||
NgTemplateOutlet,
|
||||
],
|
||||
})
|
||||
export class DatesDropdownComponent implements OnInit, OnDestroy {
|
||||
@@ -111,6 +116,46 @@ export class DatesDropdownComponent implements OnInit, OnDestroy {
|
||||
name: $localize`Yesterday`,
|
||||
date: new Date().setDate(new Date().getDate() - 1),
|
||||
},
|
||||
{
|
||||
id: RelativeDate.PREVIOUS_WEEK,
|
||||
name: $localize`Previous week`,
|
||||
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: 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: 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: new Date('1/1/' + (new Date().getFullYear() - 1)),
|
||||
dateEnd: new Date('12/31/' + (new Date().getFullYear() - 1)),
|
||||
},
|
||||
]
|
||||
|
||||
datePlaceHolder: string
|
||||
|
||||
@@ -173,6 +173,22 @@ const RELATIVE_DATE_QUERYSTRINGS = [
|
||||
relativeDate: RelativeDate.YESTERDAY,
|
||||
dateQuery: 'yesterday',
|
||||
},
|
||||
{
|
||||
relativeDate: RelativeDate.PREVIOUS_WEEK,
|
||||
dateQuery: 'previous week',
|
||||
},
|
||||
{
|
||||
relativeDate: RelativeDate.PREVIOUS_MONTH,
|
||||
dateQuery: 'previous month',
|
||||
},
|
||||
{
|
||||
relativeDate: RelativeDate.PREVIOUS_QUARTER,
|
||||
dateQuery: 'previous quarter',
|
||||
},
|
||||
{
|
||||
relativeDate: RelativeDate.PREVIOUS_YEAR,
|
||||
dateQuery: 'previous year',
|
||||
},
|
||||
]
|
||||
|
||||
const DEFAULT_TEXT_FILTER_TARGET_OPTIONS = [
|
||||
|
||||
Reference in New Issue
Block a user