@onecx/angular-accelerator 4.36.0 → 4.37.1
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/services/breadcrumb.service.mjs +57 -23
- package/fesm2015/onecx-angular-accelerator.mjs +57 -25
- package/fesm2015/onecx-angular-accelerator.mjs.map +1 -1
- package/fesm2020/onecx-angular-accelerator.mjs +57 -24
- package/fesm2020/onecx-angular-accelerator.mjs.map +1 -1
- package/lib/services/breadcrumb.service.d.ts +2 -0
- package/package.json +2 -1
|
@@ -12,12 +12,14 @@ import { FormGroup, FormControl, FormsModule, ReactiveFormsModule } from '@angul
|
|
|
12
12
|
import * as i2 from 'primeng/dropdown';
|
|
13
13
|
import { DropdownModule } from 'primeng/dropdown';
|
|
14
14
|
import * as i1$1 from '@ngx-translate/core';
|
|
15
|
-
import { TranslatePipe, TranslateModule } from '@ngx-translate/core';
|
|
15
|
+
import { TranslateService, TranslatePipe, TranslateModule } from '@ngx-translate/core';
|
|
16
16
|
import * as i2$1 from 'primeng/api';
|
|
17
17
|
import { PrimeIcons } from 'primeng/api';
|
|
18
18
|
import { BehaviorSubject, filter, concat, of, map, combineLatest, mergeMap, withLatestFrom, tap, race, first, firstValueFrom, defaultIfEmpty, forkJoin } from 'rxjs';
|
|
19
|
+
import { __decorate, __metadata } from 'tslib';
|
|
19
20
|
import * as i1$2 from '@angular/router';
|
|
20
|
-
import { NavigationEnd, RouterModule } from '@angular/router';
|
|
21
|
+
import { NavigationEnd, Router, ActivatedRoute, RouterModule } from '@angular/router';
|
|
22
|
+
import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy';
|
|
21
23
|
import * as i5 from 'primeng/breadcrumb';
|
|
22
24
|
import { BreadcrumbModule } from 'primeng/breadcrumb';
|
|
23
25
|
import * as i8 from 'primeng/menu';
|
|
@@ -229,7 +231,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
229
231
|
type: Output
|
|
230
232
|
}] } });
|
|
231
233
|
|
|
232
|
-
class BreadcrumbService {
|
|
234
|
+
let BreadcrumbService = class BreadcrumbService {
|
|
233
235
|
constructor(router, activeRoute, translateService) {
|
|
234
236
|
this.router = router;
|
|
235
237
|
this.activeRoute = activeRoute;
|
|
@@ -237,38 +239,65 @@ class BreadcrumbService {
|
|
|
237
239
|
this.itemsSource = new BehaviorSubject([]);
|
|
238
240
|
this.generatedItemsSource = new BehaviorSubject([]);
|
|
239
241
|
this.itemsHandler = this.itemsSource.asObservable();
|
|
240
|
-
|
|
241
|
-
this.
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
this.generateBreadcrumbs(this.activeRoute.snapshot);
|
|
243
|
+
this.router.events
|
|
244
|
+
.pipe(untilDestroyed(this), filter((e) => e instanceof NavigationEnd))
|
|
245
|
+
.subscribe(() => {
|
|
244
246
|
const root = this.router.routerState.snapshot.root;
|
|
247
|
+
this.generateBreadcrumbs(root);
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
generateBreadcrumbs(route) {
|
|
251
|
+
if (route?.data['mfeInfo']) {
|
|
252
|
+
const breadcrumbs = [
|
|
253
|
+
{
|
|
254
|
+
label: route.data['mfeInfo'].productName,
|
|
255
|
+
routerLink: route.data['mfeInfo'].baseHref,
|
|
256
|
+
},
|
|
257
|
+
];
|
|
258
|
+
const baseUrl = route.data['mfeInfo'].baseHref.split('/').filter((value) => value);
|
|
259
|
+
const parentUrl = route.url.map((url) => url.path);
|
|
260
|
+
const isUsingMatcher = !parentUrl.every((item) => baseUrl.includes(item));
|
|
261
|
+
if (isUsingMatcher) {
|
|
262
|
+
this.createBreadcrumb(route, parentUrl, breadcrumbs);
|
|
263
|
+
}
|
|
264
|
+
this.addBreadcrumb(route.firstChild, parentUrl, breadcrumbs);
|
|
265
|
+
this.generatedItemsSource.next(breadcrumbs);
|
|
266
|
+
}
|
|
267
|
+
else if (route?.data['breadcrumb']) {
|
|
245
268
|
const breadcrumbs = [];
|
|
246
|
-
this.addBreadcrumb(
|
|
269
|
+
this.addBreadcrumb(route, [], breadcrumbs);
|
|
247
270
|
this.generatedItemsSource.next(breadcrumbs);
|
|
248
|
-
}
|
|
271
|
+
}
|
|
272
|
+
else if (route) {
|
|
273
|
+
this.generateBreadcrumbs(route.firstChild);
|
|
274
|
+
}
|
|
249
275
|
}
|
|
250
276
|
addBreadcrumb(route, parentUrl, breadcrumbs) {
|
|
251
277
|
if (route && route.url) {
|
|
252
278
|
const routeUrl = parentUrl.concat(route.url.map((url) => url.path));
|
|
253
279
|
if (route.routeConfig?.path) {
|
|
254
|
-
|
|
255
|
-
const breadcrumb = {
|
|
256
|
-
label: this.getLabel(route.data, route.paramMap),
|
|
257
|
-
routerLink: '/' + routeUrl.join('/'),
|
|
258
|
-
};
|
|
259
|
-
breadcrumbs.push(breadcrumb);
|
|
260
|
-
}
|
|
261
|
-
else {
|
|
262
|
-
const breadcrumb = {
|
|
263
|
-
label: 'NA',
|
|
264
|
-
routerLink: '/' + routeUrl.join('/'),
|
|
265
|
-
};
|
|
266
|
-
breadcrumbs.push(breadcrumb);
|
|
267
|
-
}
|
|
280
|
+
this.createBreadcrumb(route, routeUrl, breadcrumbs);
|
|
268
281
|
}
|
|
269
282
|
this.addBreadcrumb(route.firstChild, routeUrl, breadcrumbs);
|
|
270
283
|
}
|
|
271
284
|
}
|
|
285
|
+
createBreadcrumb(route, routeUrl, breadcrumbs) {
|
|
286
|
+
if (route.data['breadcrumb']) {
|
|
287
|
+
const breadcrumb = {
|
|
288
|
+
label: this.getLabel(route.data, route.paramMap),
|
|
289
|
+
routerLink: '/' + routeUrl.join('/'),
|
|
290
|
+
};
|
|
291
|
+
breadcrumbs.push(breadcrumb);
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
const breadcrumb = {
|
|
295
|
+
label: 'NA',
|
|
296
|
+
routerLink: '/' + routeUrl.join('/'),
|
|
297
|
+
};
|
|
298
|
+
breadcrumbs.push(breadcrumb);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
272
301
|
getLabel(data, params) {
|
|
273
302
|
if (typeof data['breadcrumbFn'] === 'function') {
|
|
274
303
|
return data['breadcrumbFn'](data, params);
|
|
@@ -293,9 +322,13 @@ class BreadcrumbService {
|
|
|
293
322
|
this.itemsSource.next(items);
|
|
294
323
|
}
|
|
295
324
|
}
|
|
296
|
-
}
|
|
325
|
+
};
|
|
297
326
|
BreadcrumbService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: BreadcrumbService, deps: [{ token: i1$2.Router }, { token: i1$2.ActivatedRoute }, { token: i1$1.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
298
327
|
BreadcrumbService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: BreadcrumbService, providedIn: 'any' });
|
|
328
|
+
BreadcrumbService = __decorate([
|
|
329
|
+
UntilDestroy(),
|
|
330
|
+
__metadata("design:paramtypes", [Router, ActivatedRoute, TranslateService])
|
|
331
|
+
], BreadcrumbService);
|
|
299
332
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: BreadcrumbService, decorators: [{
|
|
300
333
|
type: Injectable,
|
|
301
334
|
args: [{ providedIn: 'any' }]
|