{ "version": 3, "sources": ["src/app/core/guards/deactivate.gaurd.ts"], "sourcesContent": ["import { Injectable } from '@angular/core';\r\nimport { MatDialog } from '@angular/material/dialog';\r\nimport { ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree } from '@angular/router';\r\nimport { Observable } from 'rxjs/internal/Observable';\r\nimport { map } from 'rxjs/operators';\r\nimport { ConfirmationDialogComponent } from '@app/shared/dialogs/confirmation-dialog/confirmation-dialog.component';\r\n// import { Observable } from 'rxjs/Observable';\r\n\r\nexport declare interface DirtyComponent {\r\n canDeactivate: () => boolean | Observable;\r\n dirtyDialogMetaData: { title: string, message: string, okText: string, cancelText: string };\r\n}\r\n\r\n@Injectable()\r\nexport class DeactivateGuard {\r\n constructor(public dialog: MatDialog) {\r\n\r\n }\r\n canDeactivate(\r\n component: DirtyComponent,\r\n next: ActivatedRouteSnapshot,\r\n state: RouterStateSnapshot,\r\n nextState: RouterStateSnapshot): Observable | Promise | boolean | UrlTree {\r\n if (component.canDeactivate()) {\r\n if (nextState.url.indexOf('/login') > -1) {\r\n return true;\r\n } else {\r\n return this.openDialog(component);\r\n }\r\n } else {\r\n return true;\r\n }\r\n }\r\n\r\n openDialog(component: DirtyComponent): Observable {\r\n const dialogRef = this.dialog.open(ConfirmationDialogComponent, {\r\n data: {\r\n title: component.dirtyDialogMetaData.title,\r\n message: component.dirtyDialogMetaData.message,\r\n buttonText: {\r\n ok: component.dirtyDialogMetaData.okText,\r\n cancel: component.dirtyDialogMetaData.cancelText,\r\n }\r\n }\r\n });\r\n\r\n return dialogRef.afterClosed().pipe(map(result => {\r\n return result;\r\n }));\r\n }\r\n}\r\n\r\n"], "mappings": ";;;;;;;;;AAcO,IAAM,kBAAN,MAAMA,iBAAe;EAC1B,YAAmB,QAAiB;AAAjB,SAAA,SAAA;EAEnB;EACA,cACE,WACA,MACA,OACA,WAA8B;AAC9B,QAAI,UAAU,cAAa,GAAI;AAC7B,UAAI,UAAU,IAAI,QAAQ,QAAQ,IAAI,IAAI;AACxC,eAAO;MACT,OAAO;AACL,eAAO,KAAK,WAAW,SAAS;MAClC;IACF,OAAO;AACL,aAAO;IACT;EACF;EAEA,WAAW,WAAyB;AAClC,UAAM,YAAY,KAAK,OAAO,KAAK,6BAA6B;MAC9D,MAAM;QACJ,OAAO,UAAU,oBAAoB;QACrC,SAAS,UAAU,oBAAoB;QACvC,YAAY;UACV,IAAI,UAAU,oBAAoB;UAClC,QAAQ,UAAU,oBAAoB;;;KAG3C;AAED,WAAO,UAAU,YAAW,EAAG,KAAK,IAAI,YAAS;AAC/C,aAAO;IACT,CAAC,CAAC;EACJ;;;;;;;AAnCW,kBAAe,WAAA;EAD3B,WAAU;GACE,eAAe;", "names": ["DeactivateGuard"] }