mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 03:16:10 -06: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 { DEFAULT_MATCHING_ALGORITHM } from 'src/app/data/matching-model'
 | 
				
			||||||
import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent'
 | 
					import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent'
 | 
				
			||||||
import { CorrespondentService } from 'src/app/services/rest/correspondent.service'
 | 
					import { CorrespondentService } from 'src/app/services/rest/correspondent.service'
 | 
				
			||||||
import { ToastService } from 'src/app/services/toast.service'
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Component({
 | 
					@Component({
 | 
				
			||||||
  selector: 'app-correspondent-edit-dialog',
 | 
					  selector: 'app-correspondent-edit-dialog',
 | 
				
			||||||
@@ -13,12 +12,8 @@ import { ToastService } from 'src/app/services/toast.service'
 | 
				
			|||||||
  styleUrls: ['./correspondent-edit-dialog.component.scss'],
 | 
					  styleUrls: ['./correspondent-edit-dialog.component.scss'],
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
export class CorrespondentEditDialogComponent extends EditDialogComponent<PaperlessCorrespondent> {
 | 
					export class CorrespondentEditDialogComponent extends EditDialogComponent<PaperlessCorrespondent> {
 | 
				
			||||||
  constructor(
 | 
					  constructor(service: CorrespondentService, activeModal: NgbActiveModal) {
 | 
				
			||||||
    service: CorrespondentService,
 | 
					    super(service, activeModal)
 | 
				
			||||||
    activeModal: NgbActiveModal,
 | 
					 | 
				
			||||||
    toastService: ToastService
 | 
					 | 
				
			||||||
  ) {
 | 
					 | 
				
			||||||
    super(service, activeModal, toastService)
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  getCreateTitle() {
 | 
					  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 { DEFAULT_MATCHING_ALGORITHM } from 'src/app/data/matching-model'
 | 
				
			||||||
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type'
 | 
					import { PaperlessDocumentType } from 'src/app/data/paperless-document-type'
 | 
				
			||||||
import { DocumentTypeService } from 'src/app/services/rest/document-type.service'
 | 
					import { DocumentTypeService } from 'src/app/services/rest/document-type.service'
 | 
				
			||||||
import { ToastService } from 'src/app/services/toast.service'
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Component({
 | 
					@Component({
 | 
				
			||||||
  selector: 'app-document-type-edit-dialog',
 | 
					  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'],
 | 
					  styleUrls: ['./document-type-edit-dialog.component.scss'],
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
export class DocumentTypeEditDialogComponent extends EditDialogComponent<PaperlessDocumentType> {
 | 
					export class DocumentTypeEditDialogComponent extends EditDialogComponent<PaperlessDocumentType> {
 | 
				
			||||||
  constructor(
 | 
					  constructor(service: DocumentTypeService, activeModal: NgbActiveModal) {
 | 
				
			||||||
    service: DocumentTypeService,
 | 
					    super(service, activeModal)
 | 
				
			||||||
    activeModal: NgbActiveModal,
 | 
					 | 
				
			||||||
    toastService: ToastService
 | 
					 | 
				
			||||||
  ) {
 | 
					 | 
				
			||||||
    super(service, activeModal, toastService)
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  getCreateTitle() {
 | 
					  getCreateTitle() {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,11 +2,9 @@ import { Directive, EventEmitter, Input, OnInit, Output } from '@angular/core'
 | 
				
			|||||||
import { FormGroup } from '@angular/forms'
 | 
					import { FormGroup } from '@angular/forms'
 | 
				
			||||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
 | 
					import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
 | 
				
			||||||
import { Observable } from 'rxjs'
 | 
					import { Observable } from 'rxjs'
 | 
				
			||||||
import { map } from 'rxjs/operators'
 | 
					 | 
				
			||||||
import { MATCHING_ALGORITHMS, MATCH_AUTO } from 'src/app/data/matching-model'
 | 
					import { MATCHING_ALGORITHMS, MATCH_AUTO } from 'src/app/data/matching-model'
 | 
				
			||||||
import { ObjectWithId } from 'src/app/data/object-with-id'
 | 
					import { ObjectWithId } from 'src/app/data/object-with-id'
 | 
				
			||||||
import { AbstractPaperlessService } from 'src/app/services/rest/abstract-paperless-service'
 | 
					import { AbstractPaperlessService } from 'src/app/services/rest/abstract-paperless-service'
 | 
				
			||||||
import { ToastService } from 'src/app/services/toast.service'
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Directive()
 | 
					@Directive()
 | 
				
			||||||
export abstract class EditDialogComponent<T extends ObjectWithId>
 | 
					export abstract class EditDialogComponent<T extends ObjectWithId>
 | 
				
			||||||
@@ -14,8 +12,7 @@ export abstract class EditDialogComponent<T extends ObjectWithId>
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  constructor(
 | 
					  constructor(
 | 
				
			||||||
    private service: AbstractPaperlessService<T>,
 | 
					    private service: AbstractPaperlessService<T>,
 | 
				
			||||||
    private activeModal: NgbActiveModal,
 | 
					    private activeModal: NgbActiveModal
 | 
				
			||||||
    private toastService: ToastService
 | 
					 | 
				
			||||||
  ) {}
 | 
					  ) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @Input()
 | 
					  @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 { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component'
 | 
				
			||||||
import { PaperlessTag } from 'src/app/data/paperless-tag'
 | 
					import { PaperlessTag } from 'src/app/data/paperless-tag'
 | 
				
			||||||
import { TagService } from 'src/app/services/rest/tag.service'
 | 
					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 { randomColor } from 'src/app/utils/color'
 | 
				
			||||||
import { DEFAULT_MATCHING_ALGORITHM } from 'src/app/data/matching-model'
 | 
					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'],
 | 
					  styleUrls: ['./tag-edit-dialog.component.scss'],
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
export class TagEditDialogComponent extends EditDialogComponent<PaperlessTag> {
 | 
					export class TagEditDialogComponent extends EditDialogComponent<PaperlessTag> {
 | 
				
			||||||
  constructor(
 | 
					  constructor(service: TagService, activeModal: NgbActiveModal) {
 | 
				
			||||||
    service: TagService,
 | 
					    super(service, activeModal)
 | 
				
			||||||
    activeModal: NgbActiveModal,
 | 
					 | 
				
			||||||
    toastService: ToastService
 | 
					 | 
				
			||||||
  ) {
 | 
					 | 
				
			||||||
    super(service, activeModal, toastService)
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  getCreateTitle() {
 | 
					  getCreateTitle() {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -120,8 +120,20 @@ export abstract class ManagementListComponent<T extends ObjectWithId>
 | 
				
			|||||||
      backdrop: 'static',
 | 
					      backdrop: 'static',
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
    activeModal.componentInstance.dialogMode = 'create'
 | 
					    activeModal.componentInstance.dialogMode = 'create'
 | 
				
			||||||
    activeModal.componentInstance.success.subscribe((o) => {
 | 
					    activeModal.componentInstance.success.subscribe({
 | 
				
			||||||
      this.reloadData()
 | 
					      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.object = object
 | 
				
			||||||
    activeModal.componentInstance.dialogMode = 'edit'
 | 
					    activeModal.componentInstance.dialogMode = 'edit'
 | 
				
			||||||
    activeModal.componentInstance.success.subscribe((o) => {
 | 
					    activeModal.componentInstance.success.subscribe({
 | 
				
			||||||
      this.reloadData()
 | 
					      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