mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-15 02:57:09 +01:00
use new date inputs for the date filter as well
This commit is contained in:
parent
d2719b5309
commit
1896aa7da1
5 changed files with 64 additions and 7 deletions
27
src-ui/src/app/utils/ngb-iso-date-adapter.ts
Normal file
27
src-ui/src/app/utils/ngb-iso-date-adapter.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { Injectable } from "@angular/core";
|
||||
import { NgbDateAdapter, NgbDateStruct } from "@ng-bootstrap/ng-bootstrap";
|
||||
|
||||
@Injectable()
|
||||
export class ISODateAdapter extends NgbDateAdapter<string> {
|
||||
|
||||
fromModel(value: string | null): NgbDateStruct | null {
|
||||
if (value) {
|
||||
let date = new Date(value)
|
||||
return {
|
||||
day : date.getDate(),
|
||||
month : date.getMonth() + 1,
|
||||
year : date.getFullYear()
|
||||
}
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
toModel(date: NgbDateStruct | null): string | null {
|
||||
if (date) {
|
||||
return date.year.toString().padStart(4, '0') + "-" + date.month.toString().padStart(2, '0') + "-" + date.day.toString().padStart(2, '0')
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ import { Injectable } from "@angular/core";
|
|||
import { NgbDateAdapter, NgbDateStruct } from "@ng-bootstrap/ng-bootstrap";
|
||||
|
||||
@Injectable()
|
||||
export class ISODateAdapter extends NgbDateAdapter<string> {
|
||||
export class ISODateTimeAdapter extends NgbDateAdapter<string> {
|
||||
|
||||
fromModel(value: string | null): NgbDateStruct | null {
|
||||
if (value) {
|
||||
Loading…
Add table
Add a link
Reference in a new issue