Merge pull request #957 from paperless-ngx/feature-created-date

Feature: make frontend timezone un-aware
This commit is contained in:
shamoon
2022-07-02 16:58:30 -07:00
committed by GitHub
16 changed files with 60 additions and 75 deletions

View File

@@ -68,7 +68,7 @@
<app-input-text #inputTitle i18n-title title="Title" formControlName="title" (keyup)="titleKeyUp($event)" [error]="error?.title"></app-input-text>
<app-input-number i18n-title title="Archive serial number" [error]="error?.archive_serial_number" formControlName='archive_serial_number'></app-input-number>
<app-input-date i18n-title title="Date created" formControlName="created" [error]="error?.created"></app-input-date>
<app-input-date i18n-title title="Date created" formControlName="created_date" [error]="error?.created_date"></app-input-date>
<app-input-select [items]="correspondents" i18n-title title="Correspondent" formControlName="correspondent" [allowNull]="true"
(createNew)="createCorrespondent($event)" [suggestions]="suggestions?.correspondents"></app-input-select>
<app-input-select [items]="documentTypes" i18n-title title="Document type" formControlName="document_type" [allowNull]="true"

View File

@@ -31,7 +31,6 @@ import {
} from 'rxjs/operators'
import { PaperlessDocumentSuggestions } from 'src/app/data/paperless-document-suggestions'
import { FILTER_FULLTEXT_MORELIKE } from 'src/app/data/filter-rule-type'
import { normalizeDateStr } from 'src/app/utils/date'
import { StoragePathService } from 'src/app/services/rest/storage-path.service'
import { PaperlessStoragePath } from 'src/app/data/paperless-storage-path'
import { StoragePathEditDialogComponent } from '../common/edit-dialog/storage-path-edit-dialog/storage-path-edit-dialog.component'
@@ -73,7 +72,7 @@ export class DocumentDetailComponent
documentForm: FormGroup = new FormGroup({
title: new FormControl(''),
content: new FormControl(''),
created: new FormControl(),
created_date: new FormControl(),
correspondent: new FormControl(),
document_type: new FormControl(),
storage_path: new FormControl(),
@@ -139,27 +138,8 @@ export class DocumentDetailComponent
ngOnInit(): void {
this.documentForm.valueChanges
.pipe(takeUntil(this.unsubscribeNotifier))
.subscribe((changes) => {
.subscribe(() => {
this.error = null
if (this.ogDate) {
try {
let newDate = new Date(normalizeDateStr(changes['created']))
newDate.setHours(
this.ogDate.getHours(),
this.ogDate.getMinutes(),
this.ogDate.getSeconds(),
this.ogDate.getMilliseconds()
)
this.documentForm.patchValue(
{ created: newDate.toISOString() },
{ emitEvent: false }
)
} catch (e) {
// catch this before we try to save and simulate an api error
this.error = { created: e.message }
}
}
Object.assign(this.document, this.documentForm.value)
})
@@ -231,13 +211,11 @@ export class DocumentDetailComponent
},
})
this.ogDate = new Date(normalizeDateStr(doc.created.toString()))
// Initialize dirtyCheck
this.store = new BehaviorSubject({
title: doc.title,
content: doc.content,
created: this.ogDate.toISOString(),
created_date: doc.created_date,
correspondent: doc.correspondent,
document_type: doc.document_type,
storage_path: doc.storage_path,
@@ -245,12 +223,6 @@ export class DocumentDetailComponent
tags: [...doc.tags],
})
// start with ISO8601 string
this.documentForm.patchValue(
{ created: this.ogDate.toISOString() },
{ emitEvent: false }
)
this.isDirty$ = dirtyCheck(
this.documentForm,
this.store.asObservable()