@ecodev/natural 47.0.1 → 47.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/modules/common/services/seo.service.mjs +42 -13
- package/esm2020/lib/modules/icon/icon.component.mjs +6 -3
- package/esm2020/lib/modules/select/select-hierarchic/select-hierarchic.component.mjs +13 -8
- package/fesm2015/ecodev-natural.mjs +119 -86
- package/fesm2015/ecodev-natural.mjs.map +1 -1
- package/fesm2020/ecodev-natural.mjs +122 -86
- package/fesm2020/ecodev-natural.mjs.map +1 -1
- package/lib/modules/common/services/seo.service.d.ts +9 -1
- package/lib/modules/select/select-hierarchic/select-hierarchic.component.d.ts +3 -1
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import { Subject, BehaviorSubject, of, timer, switchMap as switchMap$1, endWith,
|
|
|
5
5
|
import * as i3 from '@angular/forms';
|
|
6
6
|
import { FormGroup, FormArray, Validators, UntypedFormGroup, UntypedFormArray, FormControl, UntypedFormControl, FormsModule, FormControlDirective, FormControlName, ReactiveFormsModule } from '@angular/forms';
|
|
7
7
|
import * as i2$1 from '@angular/router';
|
|
8
|
-
import { Router, ActivatedRoute, NavigationStart, NavigationEnd, RouterModule, NavigationError, DefaultUrlSerializer } from '@angular/router';
|
|
8
|
+
import { Router, ActivatedRoute, NavigationStart, NavigationEnd, PRIMARY_OUTLET, RouterModule, NavigationError, DefaultUrlSerializer } from '@angular/router';
|
|
9
9
|
import { merge, isArray, pickBy, isEmpty, cloneDeep, uniq, groupBy, mergeWith, defaultsDeep, omit, kebabCase, clone, pick, isEqual, defaults, isObject, intersection, flatten, differenceWith } from 'lodash-es';
|
|
10
10
|
import * as i1 from '@angular/material/legacy-dialog';
|
|
11
11
|
import { MAT_LEGACY_DIALOG_DATA, MatLegacyDialogModule } from '@angular/material/legacy-dialog';
|
|
@@ -49,6 +49,7 @@ import * as i2$2 from '@angular/platform-browser';
|
|
|
49
49
|
import * as i7$1 from '@angular/material/legacy-tooltip';
|
|
50
50
|
import { MatLegacyTooltipModule } from '@angular/material/legacy-tooltip';
|
|
51
51
|
import * as i1$7 from '@angular/material/legacy-tabs';
|
|
52
|
+
import { __rest } from 'tslib';
|
|
52
53
|
import * as i4$4 from '@angular/material/legacy-list';
|
|
53
54
|
import { MatLegacySelectionList, MatLegacyListModule } from '@angular/material/legacy-list';
|
|
54
55
|
import * as i2$3 from '@angular/material/legacy-autocomplete';
|
|
@@ -67,7 +68,6 @@ import * as i9 from '@angular/material/legacy-paginator';
|
|
|
67
68
|
import { MatLegacyPaginatorModule } from '@angular/material/legacy-paginator';
|
|
68
69
|
import * as i3$4 from '@angular/material/sidenav';
|
|
69
70
|
import { MatSidenavContainer, MatSidenav, MatSidenavModule } from '@angular/material/sidenav';
|
|
70
|
-
import { __rest } from 'tslib';
|
|
71
71
|
import * as i1$8 from '@angular/common/http';
|
|
72
72
|
import { HttpHeaders, HttpClientModule } from '@angular/common/http';
|
|
73
73
|
|
|
@@ -5122,6 +5122,9 @@ class NaturalIconComponent {
|
|
|
5122
5122
|
this.fontSize = 24;
|
|
5123
5123
|
this.labelColor = 'accent';
|
|
5124
5124
|
this.labelPosition = 'top-right';
|
|
5125
|
+
this.icon = {
|
|
5126
|
+
name: '',
|
|
5127
|
+
};
|
|
5125
5128
|
this.registerIcons(config);
|
|
5126
5129
|
}
|
|
5127
5130
|
set name(value) {
|
|
@@ -5157,10 +5160,10 @@ class NaturalIconComponent {
|
|
|
5157
5160
|
}
|
|
5158
5161
|
}
|
|
5159
5162
|
NaturalIconComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.2", ngImport: i0, type: NaturalIconComponent, deps: [{ token: i1$6.MatIconRegistry }, { token: i2$2.DomSanitizer }, { token: IconsConfigService }], target: i0.ɵɵFactoryTarget.Component });
|
|
5160
|
-
NaturalIconComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.2", type: NaturalIconComponent, selector: "natural-icon", inputs: { label: "label", labelColor: "labelColor", labelPosition: "labelPosition", name: "name", size: "size" }, host: { properties: { "style.color": "this.fgColor", "class.material-icons": "this.isMaterialIcon", "class.mat-icon": "this.isIcon", "style.min-width.px": "this.width", "style.min-height.px": "this.height", "style.font-size.px": "this.fontSize" } }, ngImport: i0, template: "<mat-icon *ngIf=\"icon
|
|
5163
|
+
NaturalIconComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.2", type: NaturalIconComponent, selector: "natural-icon", inputs: { label: "label", labelColor: "labelColor", labelPosition: "labelPosition", name: "name", size: "size" }, host: { properties: { "style.color": "this.fgColor", "class.material-icons": "this.isMaterialIcon", "class.mat-icon": "this.isIcon", "style.min-width.px": "this.width", "style.min-height.px": "this.height", "style.font-size.px": "this.fontSize" } }, ngImport: i0, template: "<mat-icon *ngIf=\"icon.font\" [class]=\"icon.class\" [fontIcon]=\"icon.font\"></mat-icon>\n<mat-icon *ngIf=\"icon.svg\" [class]=\"icon.class\" [svgIcon]=\"icon.name\" class=\"svg-icon\"></mat-icon>\n\n<div *ngIf=\"label\" [ngClass]=\"labelColor + ' ' + labelPosition\" class=\"label\">{{ label }}</div>\n", styles: [":host{position:relative}:host mat-icon{background-repeat:inherit;display:inherit;fill:inherit;height:inherit;width:inherit;font-family:inherit;font-weight:inherit;font-style:inherit;font-size:inherit;line-height:inherit;text-transform:inherit;letter-spacing:inherit;word-wrap:inherit;white-space:inherit;direction:inherit;-webkit-font-smoothing:inherit;text-rendering:inherit;-moz-osx-font-smoothing:inherit;font-feature-settings:inherit;min-height:inherit;min-width:inherit;vertical-align:unset}:host .label{position:absolute;padding:2px;border-radius:100%;font-family:Quicksand sans-serif;font-size:14px;line-height:1em;height:14px;min-width:14px;text-align:center}:host .label.top-left{top:0;left:0;transform:translate(-50%)}:host .label.top-right{top:0;right:0;transform:translate(50%)}:host .label.bottom-left{bottom:0;left:0;transform:translate(-50%)}:host .label.bottom-right{bottom:0;right:0;transform:translate(50%)}\n"], dependencies: [{ kind: "directive", type: i1$2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1$2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i1$6.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }] });
|
|
5161
5164
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.2", ngImport: i0, type: NaturalIconComponent, decorators: [{
|
|
5162
5165
|
type: Component,
|
|
5163
|
-
args: [{ selector: 'natural-icon', template: "<mat-icon *ngIf=\"icon
|
|
5166
|
+
args: [{ selector: 'natural-icon', template: "<mat-icon *ngIf=\"icon.font\" [class]=\"icon.class\" [fontIcon]=\"icon.font\"></mat-icon>\n<mat-icon *ngIf=\"icon.svg\" [class]=\"icon.class\" [svgIcon]=\"icon.name\" class=\"svg-icon\"></mat-icon>\n\n<div *ngIf=\"label\" [ngClass]=\"labelColor + ' ' + labelPosition\" class=\"label\">{{ label }}</div>\n", styles: [":host{position:relative}:host mat-icon{background-repeat:inherit;display:inherit;fill:inherit;height:inherit;width:inherit;font-family:inherit;font-weight:inherit;font-style:inherit;font-size:inherit;line-height:inherit;text-transform:inherit;letter-spacing:inherit;word-wrap:inherit;white-space:inherit;direction:inherit;-webkit-font-smoothing:inherit;text-rendering:inherit;-moz-osx-font-smoothing:inherit;font-feature-settings:inherit;min-height:inherit;min-width:inherit;vertical-align:unset}:host .label{position:absolute;padding:2px;border-radius:100%;font-family:Quicksand sans-serif;font-size:14px;line-height:1em;height:14px;min-width:14px;text-align:center}:host .label.top-left{top:0;left:0;transform:translate(-50%)}:host .label.top-right{top:0;right:0;transform:translate(50%)}:host .label.bottom-left{bottom:0;left:0;transform:translate(-50%)}:host .label.bottom-right{bottom:0;right:0;transform:translate(50%)}\n"] }]
|
|
5164
5167
|
}], ctorParameters: function () {
|
|
5165
5168
|
return [{ type: i1$6.MatIconRegistry }, { type: i2$2.DomSanitizer }, { type: undefined, decorators: [{
|
|
5166
5169
|
type: Inject,
|
|
@@ -5760,6 +5763,68 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.2", ngImpor
|
|
|
5760
5763
|
}]
|
|
5761
5764
|
}] });
|
|
5762
5765
|
|
|
5766
|
+
class NaturalDialogTriggerComponent {
|
|
5767
|
+
constructor(dialog, route, router) {
|
|
5768
|
+
this.dialog = dialog;
|
|
5769
|
+
this.route = route;
|
|
5770
|
+
this.router = router;
|
|
5771
|
+
// Data from activated route
|
|
5772
|
+
this.triggerConfig = this.route.snapshot.data.trigger;
|
|
5773
|
+
// Get data relative to dialog service configuration
|
|
5774
|
+
const _a = this.triggerConfig.dialogConfig, { data } = _a, config = __rest(_a, ["data"]);
|
|
5775
|
+
const dialogConfig = Object.assign(Object.assign({}, config), { data: {
|
|
5776
|
+
data: data,
|
|
5777
|
+
// Set data accessible into component instantiated by the dialog service
|
|
5778
|
+
activatedRoute: this.route,
|
|
5779
|
+
} });
|
|
5780
|
+
this.dialogRef = this.dialog.open(this.triggerConfig.component, dialogConfig);
|
|
5781
|
+
// Redirect on closing (if applicable)
|
|
5782
|
+
this.dialogRef.beforeClosed().subscribe(exitValue => this.redirect(exitValue));
|
|
5783
|
+
}
|
|
5784
|
+
/**
|
|
5785
|
+
* Called when router leaves route, and so on, closes the modal with undefined value to prevent a new redirection
|
|
5786
|
+
*/
|
|
5787
|
+
ngOnDestroy() {
|
|
5788
|
+
if (this.dialogRef) {
|
|
5789
|
+
this.dialogRef.close(-1); // -1 = no redirection
|
|
5790
|
+
}
|
|
5791
|
+
}
|
|
5792
|
+
/**
|
|
5793
|
+
* Redirects on modal closing under following rules/conditions
|
|
5794
|
+
*
|
|
5795
|
+
* If -1 : no redirection
|
|
5796
|
+
* If undefined, null or empty string : uses the router provided redirection route or fallbacks on parent route if router don't provide
|
|
5797
|
+
* If a value is provided, should be of type any[] and it's used for redirection.
|
|
5798
|
+
*/
|
|
5799
|
+
redirect(exitValue) {
|
|
5800
|
+
const isEmptyExitValue = exitValue == null || exitValue === ''; // undefined, null or ''
|
|
5801
|
+
if (exitValue === -1) {
|
|
5802
|
+
// if -1, don't redirect
|
|
5803
|
+
return;
|
|
5804
|
+
}
|
|
5805
|
+
else if (!isEmptyExitValue) {
|
|
5806
|
+
// If value provided, redirect to that route
|
|
5807
|
+
this.router.navigate(exitValue);
|
|
5808
|
+
}
|
|
5809
|
+
else if (isEmptyExitValue && this.triggerConfig.afterClosedRoute) {
|
|
5810
|
+
// If value is not provided (null) and router context specified default redirection route, use it
|
|
5811
|
+
this.router.navigate(this.triggerConfig.afterClosedRoute);
|
|
5812
|
+
}
|
|
5813
|
+
else if (isEmptyExitValue) {
|
|
5814
|
+
// If neither of component or router provides redirection, go to parent (care : parent can't have empty path : ''),
|
|
5815
|
+
this.router.navigate(['.'], { relativeTo: this.route.parent });
|
|
5816
|
+
}
|
|
5817
|
+
}
|
|
5818
|
+
}
|
|
5819
|
+
NaturalDialogTriggerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.2", ngImport: i0, type: NaturalDialogTriggerComponent, deps: [{ token: i1.MatLegacyDialog }, { token: i2$1.ActivatedRoute }, { token: i2$1.Router }], target: i0.ɵɵFactoryTarget.Component });
|
|
5820
|
+
NaturalDialogTriggerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.2", type: NaturalDialogTriggerComponent, selector: "ng-component", ngImport: i0, template: '', isInline: true });
|
|
5821
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.2", ngImport: i0, type: NaturalDialogTriggerComponent, decorators: [{
|
|
5822
|
+
type: Component,
|
|
5823
|
+
args: [{
|
|
5824
|
+
template: '',
|
|
5825
|
+
}]
|
|
5826
|
+
}], ctorParameters: function () { return [{ type: i1.MatLegacyDialog }, { type: i2$1.ActivatedRoute }, { type: i2$1.Router }]; } });
|
|
5827
|
+
|
|
5763
5828
|
const NATURAL_SEO_CONFIG = new InjectionToken('Configuration for SEO service');
|
|
5764
5829
|
function stripTags(str) {
|
|
5765
5830
|
return str.replace(/<\/?[^>]+>/g, '');
|
|
@@ -5773,7 +5838,10 @@ function stripTags(str) {
|
|
|
5773
5838
|
*
|
|
5774
5839
|
* The full title has the following structure:
|
|
5775
5840
|
*
|
|
5776
|
-
* page title - extra part - app name
|
|
5841
|
+
* dialog title - page title - extra part - app name
|
|
5842
|
+
*
|
|
5843
|
+
* `dialog title` only exists if a `NaturalDialogTriggerComponent` is currently open, and that some SEO is
|
|
5844
|
+
* configured for it in the routing.
|
|
5777
5845
|
*/
|
|
5778
5846
|
class NaturalSeoService {
|
|
5779
5847
|
constructor(config, router, titleService, metaTagService) {
|
|
@@ -5783,9 +5851,16 @@ class NaturalSeoService {
|
|
|
5783
5851
|
this.metaTagService = metaTagService;
|
|
5784
5852
|
this.router.events.pipe(filter(event => event instanceof NavigationEnd)).subscribe(() => {
|
|
5785
5853
|
var _a;
|
|
5786
|
-
|
|
5854
|
+
const root = this.router.routerState.root.snapshot;
|
|
5855
|
+
this.routeData = this.getRouteData(root);
|
|
5787
5856
|
const seo = (_a = this.routeData.seo) !== null && _a !== void 0 ? _a : { title: '' };
|
|
5788
|
-
const
|
|
5857
|
+
const dialogRouteData = this.getDialogRouteData(root);
|
|
5858
|
+
const dialogSeo = dialogRouteData === null || dialogRouteData === void 0 ? void 0 : dialogRouteData.seo;
|
|
5859
|
+
let basic = this.toBasic(seo, this.routeData);
|
|
5860
|
+
if (dialogRouteData && dialogSeo) {
|
|
5861
|
+
const dialogBasic = this.toBasic(dialogSeo, dialogRouteData);
|
|
5862
|
+
basic = Object.assign(Object.assign({}, dialogBasic), { title: this.join([dialogBasic.title, basic.title]) });
|
|
5863
|
+
}
|
|
5789
5864
|
this.update(basic);
|
|
5790
5865
|
});
|
|
5791
5866
|
}
|
|
@@ -5803,10 +5878,10 @@ class NaturalSeoService {
|
|
|
5803
5878
|
// Title
|
|
5804
5879
|
const parts = [
|
|
5805
5880
|
seo.title,
|
|
5806
|
-
this.config.extraPart && this.routeData ? this.config.extraPart(this.routeData) :
|
|
5881
|
+
this.config.extraPart && this.routeData ? this.config.extraPart(this.routeData) : '',
|
|
5807
5882
|
this.config.applicationName,
|
|
5808
5883
|
];
|
|
5809
|
-
const title =
|
|
5884
|
+
const title = this.join(parts);
|
|
5810
5885
|
this.titleService.setTitle(title);
|
|
5811
5886
|
// Description
|
|
5812
5887
|
const description = (_a = seo === null || seo === void 0 ? void 0 : seo.description) !== null && _a !== void 0 ? _a : this.config.defaultDescription;
|
|
@@ -5815,6 +5890,9 @@ class NaturalSeoService {
|
|
|
5815
5890
|
const robots = (_b = seo === null || seo === void 0 ? void 0 : seo.robots) !== null && _b !== void 0 ? _b : this.config.defaultRobots;
|
|
5816
5891
|
this.updateTag('robots', robots);
|
|
5817
5892
|
}
|
|
5893
|
+
join(parts) {
|
|
5894
|
+
return parts.filter(s => !!s).join(' - ');
|
|
5895
|
+
}
|
|
5818
5896
|
updateTag(name, value) {
|
|
5819
5897
|
if (value) {
|
|
5820
5898
|
this.metaTagService.updateTag({
|
|
@@ -5830,24 +5908,35 @@ class NaturalSeoService {
|
|
|
5830
5908
|
* Returns the data from the most deep/specific activated route
|
|
5831
5909
|
*/
|
|
5832
5910
|
getRouteData(route) {
|
|
5833
|
-
var _a;
|
|
5834
5911
|
if (route.firstChild) {
|
|
5835
5912
|
return this.getRouteData(route.firstChild);
|
|
5836
5913
|
}
|
|
5837
5914
|
else {
|
|
5838
|
-
return
|
|
5915
|
+
return route.data;
|
|
5839
5916
|
}
|
|
5840
5917
|
}
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5918
|
+
/**
|
|
5919
|
+
* Returns the data from the `NaturalDialogTriggerComponent` if one is open
|
|
5920
|
+
*/
|
|
5921
|
+
getDialogRouteData(route) {
|
|
5922
|
+
if (route.component === NaturalDialogTriggerComponent && route.outlet !== PRIMARY_OUTLET) {
|
|
5923
|
+
return route.data;
|
|
5924
|
+
}
|
|
5925
|
+
for (const child of route.children) {
|
|
5926
|
+
const data = this.getDialogRouteData(child);
|
|
5927
|
+
if (data) {
|
|
5928
|
+
return data;
|
|
5929
|
+
}
|
|
5845
5930
|
}
|
|
5931
|
+
return null;
|
|
5932
|
+
}
|
|
5933
|
+
toBasic(seo, routeData) {
|
|
5934
|
+
var _a, _b, _c, _d, _e;
|
|
5846
5935
|
if (typeof seo === 'function') {
|
|
5847
|
-
return seo(
|
|
5936
|
+
return seo(routeData);
|
|
5848
5937
|
}
|
|
5849
5938
|
else if ('resolveKey' in seo) {
|
|
5850
|
-
const data =
|
|
5939
|
+
const data = routeData[seo.resolveKey];
|
|
5851
5940
|
if (!data) {
|
|
5852
5941
|
throw new Error('Could not find resolved data for SEO service with key: ' + seo.resolveKey);
|
|
5853
5942
|
}
|
|
@@ -8229,6 +8318,12 @@ class NaturalSelectHierarchicComponent extends AbstractSelect {
|
|
|
8229
8318
|
constructor(hierarchicSelectorDialogService, ngControl) {
|
|
8230
8319
|
super(ngControl);
|
|
8231
8320
|
this.hierarchicSelectorDialogService = hierarchicSelectorDialogService;
|
|
8321
|
+
/**
|
|
8322
|
+
* Configuration for hierarchic relations
|
|
8323
|
+
*
|
|
8324
|
+
* It should be an array with at least one element with `selectableAtKey` configured, otherwise the selector will never open.
|
|
8325
|
+
*/
|
|
8326
|
+
this.config = null;
|
|
8232
8327
|
/**
|
|
8233
8328
|
* The selected value as an object. The internal value is `internalCtrl.value`, and that is a string.
|
|
8234
8329
|
*/
|
|
@@ -8262,11 +8357,14 @@ class NaturalSelectHierarchicComponent extends AbstractSelect {
|
|
|
8262
8357
|
if (this.lockOpenDialog) {
|
|
8263
8358
|
return;
|
|
8264
8359
|
}
|
|
8360
|
+
const selectAtKey = this.getSelectKey();
|
|
8361
|
+
if (!selectAtKey || !this.config) {
|
|
8362
|
+
return;
|
|
8363
|
+
}
|
|
8265
8364
|
this.lockOpenDialog = true;
|
|
8266
8365
|
if (this.onTouched) {
|
|
8267
8366
|
this.onTouched();
|
|
8268
8367
|
}
|
|
8269
|
-
const selectAtKey = this.getSelectKey();
|
|
8270
8368
|
const selected = {};
|
|
8271
8369
|
if (this.internalCtrl.value) {
|
|
8272
8370
|
selected[selectAtKey] = [this.value];
|
|
@@ -8295,14 +8393,11 @@ class NaturalSelectHierarchicComponent extends AbstractSelect {
|
|
|
8295
8393
|
}
|
|
8296
8394
|
showSelectButton() {
|
|
8297
8395
|
var _a;
|
|
8298
|
-
return !!(((_a = this.internalCtrl) === null || _a === void 0 ? void 0 : _a.enabled) && this.selectLabel && this.
|
|
8396
|
+
return !!(((_a = this.internalCtrl) === null || _a === void 0 ? void 0 : _a.enabled) && this.selectLabel && this.getSelectKey());
|
|
8299
8397
|
}
|
|
8300
8398
|
getSelectKey() {
|
|
8301
|
-
|
|
8302
|
-
|
|
8303
|
-
throw new Error('Hierarchic selector must be configured with at least one selectableAtKey');
|
|
8304
|
-
}
|
|
8305
|
-
return selectKey;
|
|
8399
|
+
var _a, _b;
|
|
8400
|
+
return (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.filter(c => !!c.selectableAtKey)[0]) === null || _b === void 0 ? void 0 : _b.selectableAtKey;
|
|
8306
8401
|
}
|
|
8307
8402
|
}
|
|
8308
8403
|
NaturalSelectHierarchicComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.2", ngImport: i0, type: NaturalSelectHierarchicComponent, deps: [{ token: NaturalHierarchicSelectorDialogService }, { token: i3.NgControl, optional: true, self: true }], target: i0.ɵɵFactoryTarget.Component });
|
|
@@ -10449,68 +10544,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.2", ngImpor
|
|
|
10449
10544
|
* Public API Surface of natural
|
|
10450
10545
|
*/
|
|
10451
10546
|
|
|
10452
|
-
class NaturalDialogTriggerComponent {
|
|
10453
|
-
constructor(dialog, route, router) {
|
|
10454
|
-
this.dialog = dialog;
|
|
10455
|
-
this.route = route;
|
|
10456
|
-
this.router = router;
|
|
10457
|
-
// Data from activated route
|
|
10458
|
-
this.triggerConfig = this.route.snapshot.data.trigger;
|
|
10459
|
-
// Get data relative to dialog service configuration
|
|
10460
|
-
const _a = this.triggerConfig.dialogConfig, { data } = _a, config = __rest(_a, ["data"]);
|
|
10461
|
-
const dialogConfig = Object.assign(Object.assign({}, config), { data: {
|
|
10462
|
-
data: data,
|
|
10463
|
-
// Set data accessible into component instantiated by the dialog service
|
|
10464
|
-
activatedRoute: this.route,
|
|
10465
|
-
} });
|
|
10466
|
-
this.dialogRef = this.dialog.open(this.triggerConfig.component, dialogConfig);
|
|
10467
|
-
// Redirect on closing (if applicable)
|
|
10468
|
-
this.dialogRef.beforeClosed().subscribe(exitValue => this.redirect(exitValue));
|
|
10469
|
-
}
|
|
10470
|
-
/**
|
|
10471
|
-
* Called when router leaves route, and so on, closes the modal with undefined value to prevent a new redirection
|
|
10472
|
-
*/
|
|
10473
|
-
ngOnDestroy() {
|
|
10474
|
-
if (this.dialogRef) {
|
|
10475
|
-
this.dialogRef.close(-1); // -1 = no redirection
|
|
10476
|
-
}
|
|
10477
|
-
}
|
|
10478
|
-
/**
|
|
10479
|
-
* Redirects on modal closing under following rules/conditions
|
|
10480
|
-
*
|
|
10481
|
-
* If -1 : no redirection
|
|
10482
|
-
* If undefined, null or empty string : uses the router provided redirection route or fallbacks on parent route if router don't provide
|
|
10483
|
-
* If a value is provided, should be of type any[] and it's used for redirection.
|
|
10484
|
-
*/
|
|
10485
|
-
redirect(exitValue) {
|
|
10486
|
-
const isEmptyExitValue = exitValue == null || exitValue === ''; // undefined, null or ''
|
|
10487
|
-
if (exitValue === -1) {
|
|
10488
|
-
// if -1, don't redirect
|
|
10489
|
-
return;
|
|
10490
|
-
}
|
|
10491
|
-
else if (!isEmptyExitValue) {
|
|
10492
|
-
// If value provided, redirect to that route
|
|
10493
|
-
this.router.navigate(exitValue);
|
|
10494
|
-
}
|
|
10495
|
-
else if (isEmptyExitValue && this.triggerConfig.afterClosedRoute) {
|
|
10496
|
-
// If value is not provided (null) and router context specified default redirection route, use it
|
|
10497
|
-
this.router.navigate(this.triggerConfig.afterClosedRoute);
|
|
10498
|
-
}
|
|
10499
|
-
else if (isEmptyExitValue) {
|
|
10500
|
-
// If neither of component or router provides redirection, go to parent (care : parent can't have empty path : ''),
|
|
10501
|
-
this.router.navigate(['.'], { relativeTo: this.route.parent });
|
|
10502
|
-
}
|
|
10503
|
-
}
|
|
10504
|
-
}
|
|
10505
|
-
NaturalDialogTriggerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.2", ngImport: i0, type: NaturalDialogTriggerComponent, deps: [{ token: i1.MatLegacyDialog }, { token: i2$1.ActivatedRoute }, { token: i2$1.Router }], target: i0.ɵɵFactoryTarget.Component });
|
|
10506
|
-
NaturalDialogTriggerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.2", type: NaturalDialogTriggerComponent, selector: "ng-component", ngImport: i0, template: '', isInline: true });
|
|
10507
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.2", ngImport: i0, type: NaturalDialogTriggerComponent, decorators: [{
|
|
10508
|
-
type: Component,
|
|
10509
|
-
args: [{
|
|
10510
|
-
template: '',
|
|
10511
|
-
}]
|
|
10512
|
-
}], ctorParameters: function () { return [{ type: i1.MatLegacyDialog }, { type: i2$1.ActivatedRoute }, { type: i2$1.Router }]; } });
|
|
10513
|
-
|
|
10514
10547
|
class NaturalDialogTriggerModule {
|
|
10515
10548
|
}
|
|
10516
10549
|
NaturalDialogTriggerModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.2", ngImport: i0, type: NaturalDialogTriggerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|