mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-28 03:46:06 -05:00 
			
		
		
		
	retain document time / tz in detail form
This commit is contained in:
		| @@ -87,6 +87,8 @@ export class DocumentDetailComponent | |||||||
|   requiresPassword: boolean = false |   requiresPassword: boolean = false | ||||||
|   password: string |   password: string | ||||||
|  |  | ||||||
|  |   ogDate: Date | ||||||
|  |  | ||||||
|   @ViewChild('nav') nav: NgbNav |   @ViewChild('nav') nav: NgbNav | ||||||
|   @ViewChild('pdfPreview') set pdfPreview(element) { |   @ViewChild('pdfPreview') set pdfPreview(element) { | ||||||
|     // this gets called when compontent added or removed from DOM |     // this gets called when compontent added or removed from DOM | ||||||
| @@ -142,7 +144,21 @@ export class DocumentDetailComponent | |||||||
|   ngOnInit(): void { |   ngOnInit(): void { | ||||||
|     this.documentForm.valueChanges |     this.documentForm.valueChanges | ||||||
|       .pipe(takeUntil(this.unsubscribeNotifier)) |       .pipe(takeUntil(this.unsubscribeNotifier)) | ||||||
|       .subscribe((wow) => { |       .subscribe((changes) => { | ||||||
|  |         if (this.ogDate) { | ||||||
|  |           let newDate = new Date(changes['created']) | ||||||
|  |           newDate.setHours( | ||||||
|  |             this.ogDate.getHours(), | ||||||
|  |             this.ogDate.getMinutes(), | ||||||
|  |             this.ogDate.getSeconds(), | ||||||
|  |             this.ogDate.getMilliseconds() | ||||||
|  |           ) | ||||||
|  |           this.documentForm.patchValue( | ||||||
|  |             { created: this.formatDate(newDate) }, | ||||||
|  |             { emitEvent: false } | ||||||
|  |           ) | ||||||
|  |         } | ||||||
|  |  | ||||||
|         Object.assign(this.document, this.documentForm.value) |         Object.assign(this.document, this.documentForm.value) | ||||||
|       }) |       }) | ||||||
|  |  | ||||||
| @@ -183,17 +199,25 @@ export class DocumentDetailComponent | |||||||
|             this.updateComponent(doc) |             this.updateComponent(doc) | ||||||
|           } |           } | ||||||
|  |  | ||||||
|  |           this.ogDate = new Date(doc.created) | ||||||
|  |  | ||||||
|           // Initialize dirtyCheck |           // Initialize dirtyCheck | ||||||
|           this.store = new BehaviorSubject({ |           this.store = new BehaviorSubject({ | ||||||
|             title: doc.title, |             title: doc.title, | ||||||
|             content: doc.content, |             content: doc.content, | ||||||
|             created: doc.created, |             created: this.formatDate(this.ogDate), | ||||||
|             correspondent: doc.correspondent, |             correspondent: doc.correspondent, | ||||||
|             document_type: doc.document_type, |             document_type: doc.document_type, | ||||||
|             archive_serial_number: doc.archive_serial_number, |             archive_serial_number: doc.archive_serial_number, | ||||||
|             tags: [...doc.tags], |             tags: [...doc.tags], | ||||||
|           }) |           }) | ||||||
|  |  | ||||||
|  |           // ensure we're always starting with 24-char ISO8601 string | ||||||
|  |           this.documentForm.patchValue( | ||||||
|  |             { created: this.formatDate(this.ogDate) }, | ||||||
|  |             { emitEvent: false } | ||||||
|  |           ) | ||||||
|  |  | ||||||
|           this.isDirty$ = dirtyCheck( |           this.isDirty$ = dirtyCheck( | ||||||
|             this.documentForm, |             this.documentForm, | ||||||
|             this.store.asObservable() |             this.store.asObservable() | ||||||
| @@ -461,4 +485,8 @@ export class DocumentDetailComponent | |||||||
|       this.password = (event.target as HTMLInputElement).value |       this.password = (event.target as HTMLInputElement).value | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   formatDate(date: Date): string { | ||||||
|  |     return date.toISOString().split('.')[0] + 'Z' | ||||||
|  |   } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Michael Shamoon
					Michael Shamoon