Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- constructor(private location: PlatformLocation,
- private _dialog: DialogService,
- private router: Router) { }
- open() {
- this.showDialog = true;
- const body = document.body;
- body.classList.add('cell-modal-open');
- }
- close() {
- this.dialog = undefined;
- }
- private handleDialog(d: Dialog) {
- if (!d) {
- this.close();
- } else if (d.template) {
- if (this.showDialog) {
- this.close();
- }
- this.dialog = d;
- this.open();
- }
- }
- ngOnInit() {
- this.subscription = this
- ._dialog
- .getDialog()
- .subscribe({
- next: (d) => { this.handleDialog(d); console.log('subscribed dialog') },
- error: (err) => this.handleDialogError(err)
- });
- this.initialiseRoutingEventListeners();
- }
- private d: Dialog = { template: null, size: DialogSizeEnum.XLarge };
- private dialogSubject = new BehaviorSubject<Dialog>({ template: null, size: DialogSizeEnum.XLarge });
- constructor() { }
- showDialog(template: TemplateRef<any>, size = DialogSizeEnum.XLarge, requiresAction = false) {
- Object.assign(this.d, { template: template, size: size, requiresAction: requiresAction });
- if (this.d !== null) {
- this.dialogSubject.next(this.d);
- }
- }
- getDialog(): BehaviorSubject<Dialog> {
- return this.dialogSubject;
- }
- clear() {
- this.dialogSubject.next(null);
- }
Add Comment
Please, Sign In to add comment