mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	show errors on invalid date input
This commit is contained in:
		| @@ -162,8 +162,8 @@ | |||||||
|             <div [ngbNavOutlet]="nav" class="mt-2"></div> |             <div [ngbNavOutlet]="nav" class="mt-2"></div> | ||||||
|  |  | ||||||
|             <button type="button" class="btn btn-outline-secondary" (click)="discard()" i18n [disabled]="networkActive || !(isDirty$ | async)">Discard</button>  |             <button type="button" class="btn btn-outline-secondary" (click)="discard()" i18n [disabled]="networkActive || !(isDirty$ | async)">Discard</button>  | ||||||
|             <button type="button" class="btn btn-outline-primary" (click)="saveEditNext()" *ngIf="hasNext()" i18n [disabled]="networkActive || !(isDirty$ | async)">Save & next</button>  |             <button type="button" class="btn btn-outline-primary" (click)="saveEditNext()" *ngIf="hasNext()" i18n [disabled]="networkActive || !(isDirty$ | async) || error">Save & next</button>  | ||||||
|             <button type="submit" class="btn btn-primary" i18n [disabled]="networkActive || !(isDirty$ | async)">Save</button>  |             <button type="submit" class="btn btn-primary" i18n [disabled]="networkActive || !(isDirty$ | async) || error">Save</button>  | ||||||
|         </form> |         </form> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -146,7 +146,9 @@ export class DocumentDetailComponent | |||||||
|     this.documentForm.valueChanges |     this.documentForm.valueChanges | ||||||
|       .pipe(takeUntil(this.unsubscribeNotifier)) |       .pipe(takeUntil(this.unsubscribeNotifier)) | ||||||
|       .subscribe((changes) => { |       .subscribe((changes) => { | ||||||
|  |         this.error = null | ||||||
|         if (this.ogDate) { |         if (this.ogDate) { | ||||||
|  |           try { | ||||||
|             let newDate = new Date(normalizeDateStr(changes['created'])) |             let newDate = new Date(normalizeDateStr(changes['created'])) | ||||||
|             newDate.setHours( |             newDate.setHours( | ||||||
|               this.ogDate.getHours(), |               this.ogDate.getHours(), | ||||||
| @@ -158,6 +160,10 @@ export class DocumentDetailComponent | |||||||
|               { created: newDate.toISOString() }, |               { created: newDate.toISOString() }, | ||||||
|               { emitEvent: false } |               { 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) |         Object.assign(this.document, this.documentForm.value) | ||||||
| @@ -320,16 +326,17 @@ export class DocumentDetailComponent | |||||||
|     this.documentsService |     this.documentsService | ||||||
|       .get(this.documentId) |       .get(this.documentId) | ||||||
|       .pipe(first()) |       .pipe(first()) | ||||||
|       .subscribe( |       .subscribe({ | ||||||
|         (doc) => { |         next: (doc) => { | ||||||
|           Object.assign(this.document, doc) |           Object.assign(this.document, doc) | ||||||
|           this.title = doc.title |           this.title = doc.title | ||||||
|           this.documentForm.patchValue(doc) |           this.documentForm.patchValue(doc) | ||||||
|  |           this.openDocumentService.setDirty(doc.id, false) | ||||||
|         }, |         }, | ||||||
|         (error) => { |         error: () => { | ||||||
|           this.router.navigate(['404']) |           this.router.navigate(['404']) | ||||||
|         } |         }, | ||||||
|       ) |       }) | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   save() { |   save() { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Michael Shamoon
					Michael Shamoon