privacy-delete-dialog.component.ts 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import { Component, OnInit, OnDestroy } from '@angular/core';
  2. import { ActivatedRoute, Router } from '@angular/router';
  3. import { NgbActiveModal, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
  4. import { JhiEventManager } from 'ng-jhipster';
  5. import { IPrivacy } from 'app/shared/model/privacy.model';
  6. import { PrivacyService } from './privacy.service';
  7. @Component({
  8. selector: 'jhi-privacy-delete-dialog',
  9. templateUrl: './privacy-delete-dialog.component.html'
  10. })
  11. export class PrivacyDeleteDialogComponent {
  12. privacy: IPrivacy;
  13. constructor(private privacyService: PrivacyService, public activeModal: NgbActiveModal, private eventManager: JhiEventManager) {}
  14. clear() {
  15. this.activeModal.dismiss('cancel');
  16. }
  17. confirmDelete(id: number) {
  18. this.privacyService.delete(id).subscribe(response => {
  19. this.eventManager.broadcast({
  20. name: 'privacyListModification',
  21. content: 'Deleted an privacy'
  22. });
  23. this.activeModal.dismiss(true);
  24. });
  25. }
  26. }
  27. @Component({
  28. selector: 'jhi-privacy-delete-popup',
  29. template: ''
  30. })
  31. export class PrivacyDeletePopupComponent implements OnInit, OnDestroy {
  32. private ngbModalRef: NgbModalRef;
  33. constructor(private activatedRoute: ActivatedRoute, private router: Router, private modalService: NgbModal) {}
  34. ngOnInit() {
  35. this.activatedRoute.data.subscribe(({ privacy }) => {
  36. setTimeout(() => {
  37. this.ngbModalRef = this.modalService.open(PrivacyDeleteDialogComponent as Component, { size: 'lg', backdrop: 'static' });
  38. this.ngbModalRef.componentInstance.privacy = privacy;
  39. this.ngbModalRef.result.then(
  40. result => {
  41. this.router.navigate([{ outlets: { popup: null } }], { replaceUrl: true, queryParamsHandling: 'merge' });
  42. this.ngbModalRef = null;
  43. },
  44. reason => {
  45. this.router.navigate([{ outlets: { popup: null } }], { replaceUrl: true, queryParamsHandling: 'merge' });
  46. this.ngbModalRef = null;
  47. }
  48. );
  49. }, 0);
  50. });
  51. }
  52. ngOnDestroy() {
  53. this.ngbModalRef = null;
  54. }
  55. }