@tapsellorg/angular-material-library
Version:
Angular library for Tapsell
63 lines (58 loc) • 3.43 kB
JavaScript
import * as i0 from '@angular/core';
import { Injectable, NgModule } from '@angular/core';
import { of, switchMap } from 'rxjs';
import { PghConfirmDialogComponent } from '@tapsellorg/angular-material-library/confirm-dialog';
import * as i1 from '@angular/material/dialog';
import { MatDialogModule } from '@angular/material/dialog';
import * as i2 from '@tapsellorg/angular-material-library/src/lib/translate';
import { CommonModule } from '@angular/common';
class PghAccidentallyClosedGuard {
constructor(matDialog, translateService) {
this.matDialog = matDialog;
this.translateService = translateService;
}
canDeactivate(component) {
if (!component.canClosePage) {
return of(true);
}
const eventResponse$ = component.canClosePage();
const toObservable = typeof eventResponse$ === 'boolean' ? of(eventResponse$) : eventResponse$;
return toObservable.pipe(switchMap(data => data
? of(true)
: this.matDialog
.open(PghConfirmDialogComponent, {
data: {
title: this.translateService.translate('ACCIDENTALLY_CLOSED_TITLE'),
message: this.translateService.translate('ACCIDENTALLY_CLOSED_MESSAGE'),
rejectBtnText: this.translateService.translate('ACCIDENTALLY_CLOSED_REJECT_BUTTON'),
acceptBtnText: this.translateService.translate('ACCIDENTALLY_CLOSED_ACCEPT_BUTTON'),
},
})
.afterClosed()));
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: PghAccidentallyClosedGuard, deps: [{ token: i1.MatDialog }, { token: i2.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: PghAccidentallyClosedGuard, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: PghAccidentallyClosedGuard, decorators: [{
type: Injectable,
args: [{
providedIn: 'root',
}]
}], ctorParameters: () => [{ type: i1.MatDialog }, { type: i2.TranslateService }] });
class AccidentallyClosedModule {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AccidentallyClosedModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.13", ngImport: i0, type: AccidentallyClosedModule, imports: [CommonModule, MatDialogModule] }); }
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AccidentallyClosedModule, imports: [CommonModule, MatDialogModule] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AccidentallyClosedModule, decorators: [{
type: NgModule,
args: [{
declarations: [],
imports: [CommonModule, MatDialogModule],
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { AccidentallyClosedModule, PghAccidentallyClosedGuard };
//# sourceMappingURL=tapsellorg-angular-material-library-guard.mjs.map