]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
remove unused toastService from edit dialogs and add confirmation
authorMichael Shamoon <4887959+shamoon@users.noreply.github.com>
Tue, 8 Nov 2022 18:53:41 +0000 (10:53 -0800)
committerMichael Shamoon <4887959+shamoon@users.noreply.github.com>
Sat, 3 Dec 2022 17:31:22 +0000 (09:31 -0800)
src-ui/src/app/components/common/edit-dialog/correspondent-edit-dialog/correspondent-edit-dialog.component.ts
src-ui/src/app/components/common/edit-dialog/document-type-edit-dialog/document-type-edit-dialog.component.ts
src-ui/src/app/components/common/edit-dialog/edit-dialog.component.ts
src-ui/src/app/components/common/edit-dialog/tag-edit-dialog/tag-edit-dialog.component.ts
src-ui/src/app/components/manage/management-list/management-list.component.ts

index 86be7414dba3fa82e3d5027c856a9a1cc4260756..7361e5e4bbc406485adf439ddfde872ab01fe6a2 100644 (file)
@@ -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() {
index bcd2363fd3e6927fc74bb141306408ab598465aa..d565e66e1b6085e5189ba1ec4535286e70e6b99e 100644 (file)
@@ -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() {
index 92b16a93dc62a8fd762ec8fc34d903f264baef05..e87eed4388b66d2abcc3c5e77a1b32f8cfce4aa2 100644 (file)
@@ -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()
index 18d476dfe1cab483663120d5ae9b20e2b8b4dce8..db106d990874bbee6ee779a5bbf1b61e99c2ed3d 100644 (file)
@@ -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() {
index 317cf6fee5aaa0129cd986be0603ba2aafa6ab82..d0864d6f5a26fbb12b09b05a7fe30be319bd4b98 100644 (file)
@@ -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()}.`
+        )
+      },
     })
   }