mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	remove unused toastService from edit dialogs and add confirmation
This commit is contained in:
		| @@ -5,7 +5,6 @@ import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit- | ||||
| import { DEFAULT_MATCHING_ALGORITHM } from 'src/app/data/matching-model' | ||||
| import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent' | ||||
| import { CorrespondentService } from 'src/app/services/rest/correspondent.service' | ||||
| import { ToastService } from 'src/app/services/toast.service' | ||||
|  | ||||
| @Component({ | ||||
|   selector: 'app-correspondent-edit-dialog', | ||||
| @@ -13,12 +12,8 @@ import { ToastService } from 'src/app/services/toast.service' | ||||
|   styleUrls: ['./correspondent-edit-dialog.component.scss'], | ||||
| }) | ||||
| export class CorrespondentEditDialogComponent extends EditDialogComponent<PaperlessCorrespondent> { | ||||
|   constructor( | ||||
|     service: CorrespondentService, | ||||
|     activeModal: NgbActiveModal, | ||||
|     toastService: ToastService | ||||
|   ) { | ||||
|     super(service, activeModal, toastService) | ||||
|   constructor(service: CorrespondentService, activeModal: NgbActiveModal) { | ||||
|     super(service, activeModal) | ||||
|   } | ||||
|  | ||||
|   getCreateTitle() { | ||||
|   | ||||
| @@ -5,7 +5,6 @@ import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit- | ||||
| import { DEFAULT_MATCHING_ALGORITHM } from 'src/app/data/matching-model' | ||||
| import { PaperlessDocumentType } from 'src/app/data/paperless-document-type' | ||||
| import { DocumentTypeService } from 'src/app/services/rest/document-type.service' | ||||
| import { ToastService } from 'src/app/services/toast.service' | ||||
|  | ||||
| @Component({ | ||||
|   selector: 'app-document-type-edit-dialog', | ||||
| @@ -13,12 +12,8 @@ import { ToastService } from 'src/app/services/toast.service' | ||||
|   styleUrls: ['./document-type-edit-dialog.component.scss'], | ||||
| }) | ||||
| export class DocumentTypeEditDialogComponent extends EditDialogComponent<PaperlessDocumentType> { | ||||
|   constructor( | ||||
|     service: DocumentTypeService, | ||||
|     activeModal: NgbActiveModal, | ||||
|     toastService: ToastService | ||||
|   ) { | ||||
|     super(service, activeModal, toastService) | ||||
|   constructor(service: DocumentTypeService, activeModal: NgbActiveModal) { | ||||
|     super(service, activeModal) | ||||
|   } | ||||
|  | ||||
|   getCreateTitle() { | ||||
|   | ||||
| @@ -2,11 +2,9 @@ import { Directive, EventEmitter, Input, OnInit, Output } from '@angular/core' | ||||
| import { FormGroup } from '@angular/forms' | ||||
| import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' | ||||
| import { Observable } from 'rxjs' | ||||
| import { map } from 'rxjs/operators' | ||||
| import { MATCHING_ALGORITHMS, MATCH_AUTO } from 'src/app/data/matching-model' | ||||
| import { ObjectWithId } from 'src/app/data/object-with-id' | ||||
| import { AbstractPaperlessService } from 'src/app/services/rest/abstract-paperless-service' | ||||
| import { ToastService } from 'src/app/services/toast.service' | ||||
|  | ||||
| @Directive() | ||||
| export abstract class EditDialogComponent<T extends ObjectWithId> | ||||
| @@ -14,8 +12,7 @@ export abstract class EditDialogComponent<T extends ObjectWithId> | ||||
| { | ||||
|   constructor( | ||||
|     private service: AbstractPaperlessService<T>, | ||||
|     private activeModal: NgbActiveModal, | ||||
|     private toastService: ToastService | ||||
|     private activeModal: NgbActiveModal | ||||
|   ) {} | ||||
|  | ||||
|   @Input() | ||||
|   | ||||
| @@ -4,7 +4,6 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' | ||||
| import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component' | ||||
| import { PaperlessTag } from 'src/app/data/paperless-tag' | ||||
| import { TagService } from 'src/app/services/rest/tag.service' | ||||
| import { ToastService } from 'src/app/services/toast.service' | ||||
| import { randomColor } from 'src/app/utils/color' | ||||
| import { DEFAULT_MATCHING_ALGORITHM } from 'src/app/data/matching-model' | ||||
|  | ||||
| @@ -14,12 +13,8 @@ import { DEFAULT_MATCHING_ALGORITHM } from 'src/app/data/matching-model' | ||||
|   styleUrls: ['./tag-edit-dialog.component.scss'], | ||||
| }) | ||||
| export class TagEditDialogComponent extends EditDialogComponent<PaperlessTag> { | ||||
|   constructor( | ||||
|     service: TagService, | ||||
|     activeModal: NgbActiveModal, | ||||
|     toastService: ToastService | ||||
|   ) { | ||||
|     super(service, activeModal, toastService) | ||||
|   constructor(service: TagService, activeModal: NgbActiveModal) { | ||||
|     super(service, activeModal) | ||||
|   } | ||||
|  | ||||
|   getCreateTitle() { | ||||
|   | ||||
| @@ -120,8 +120,20 @@ export abstract class ManagementListComponent<T extends ObjectWithId> | ||||
|       backdrop: 'static', | ||||
|     }) | ||||
|     activeModal.componentInstance.dialogMode = 'create' | ||||
|     activeModal.componentInstance.success.subscribe((o) => { | ||||
|       this.reloadData() | ||||
|     activeModal.componentInstance.success.subscribe({ | ||||
|       next: () => { | ||||
|         this.reloadData() | ||||
|         this.toastService.showInfo( | ||||
|           $localize`Successfully created ${this.typeName}.` | ||||
|         ) | ||||
|       }, | ||||
|       error: (e) => { | ||||
|         this.toastService.showInfo( | ||||
|           $localize`Error occurred while creating ${ | ||||
|             this.typeName | ||||
|           } : ${e.toString()}.` | ||||
|         ) | ||||
|       }, | ||||
|     }) | ||||
|   } | ||||
|  | ||||
| @@ -131,8 +143,20 @@ export abstract class ManagementListComponent<T extends ObjectWithId> | ||||
|     }) | ||||
|     activeModal.componentInstance.object = object | ||||
|     activeModal.componentInstance.dialogMode = 'edit' | ||||
|     activeModal.componentInstance.success.subscribe((o) => { | ||||
|       this.reloadData() | ||||
|     activeModal.componentInstance.success.subscribe({ | ||||
|       next: () => { | ||||
|         this.reloadData() | ||||
|         this.toastService.showInfo( | ||||
|           $localize`Successfully updated ${this.typeName}.` | ||||
|         ) | ||||
|       }, | ||||
|       error: (e) => { | ||||
|         this.toastService.showInfo( | ||||
|           $localize`Error occurred while saving ${ | ||||
|             this.typeName | ||||
|           } : ${e.toString()}.` | ||||
|         ) | ||||
|       }, | ||||
|     }) | ||||
|   } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Michael Shamoon
					Michael Shamoon