@valtimo/components 10.2.0 → 10.2.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.
@@ -1166,13 +1166,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
1166
1166
  * limitations under the License.
1167
1167
  */
1168
1168
  class MenuService {
1169
- constructor(configService, documentService, userProviderService, logger, menuIncludeService, router) {
1169
+ constructor(configService, documentService, userProviderService, logger, menuIncludeService, router, keycloakService) {
1170
1170
  this.configService = configService;
1171
1171
  this.documentService = documentService;
1172
1172
  this.userProviderService = userProviderService;
1173
1173
  this.logger = logger;
1174
1174
  this.menuIncludeService = menuIncludeService;
1175
1175
  this.router = router;
1176
+ this.keycloakService = keycloakService;
1176
1177
  this.includeFunctionObservables = {};
1177
1178
  this._menuItems$ = new BehaviorSubject(undefined);
1178
1179
  this.currentRoute$ = this.router.events.pipe(filter(event => event instanceof NavigationEnd), map$1(event => event?.url));
@@ -1226,9 +1227,10 @@ class MenuService {
1226
1227
  return this._menuItems$.asObservable();
1227
1228
  }
1228
1229
  reload() {
1229
- return this._menuItems$.next(this.loadMenuItems());
1230
+ const roles = this.keycloakService.getUserRoles(true);
1231
+ return this._menuItems$.next(this.loadMenuItems(roles));
1230
1232
  }
1231
- loadMenuItems() {
1233
+ loadMenuItems(userRoles) {
1232
1234
  let menuItems = [];
1233
1235
  this.menuConfig.menuItems.forEach((menuItem) => {
1234
1236
  if (menuItem.includeFunction !== undefined) {
@@ -1236,7 +1238,9 @@ class MenuService {
1236
1238
  this.menuIncludeService.getIncludeFunction(menuItem.includeFunction);
1237
1239
  }
1238
1240
  menuItem.show = true;
1239
- menuItems.push(menuItem);
1241
+ if (userRoles.find(userRole => menuItem.roles.includes(userRole))) {
1242
+ menuItems.push(menuItem);
1243
+ }
1240
1244
  });
1241
1245
  menuItems = this.sortMenuItems(menuItems);
1242
1246
  this.appendDossierSubMenuItems(menuItems).subscribe(value => (menuItems = this.applyMenuRoleSecurity(value)));
@@ -1317,14 +1321,14 @@ class MenuService {
1317
1321
  return !menuItem.roles || menuItem.roles.some(role => roles.includes(role));
1318
1322
  }
1319
1323
  }
1320
- MenuService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: MenuService, deps: [{ token: i2$1.ConfigService }, { token: i2$2.DocumentService }, { token: i3.UserProviderService }, { token: i4.NGXLogger }, { token: i2$1.MenuIncludeService }, { token: i1$4.Router }], target: i0.ɵɵFactoryTarget.Injectable });
1324
+ MenuService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: MenuService, deps: [{ token: i2$1.ConfigService }, { token: i2$2.DocumentService }, { token: i3.UserProviderService }, { token: i4.NGXLogger }, { token: i2$1.MenuIncludeService }, { token: i1$4.Router }, { token: i1$3.KeycloakService }], target: i0.ɵɵFactoryTarget.Injectable });
1321
1325
  MenuService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: MenuService, providedIn: 'root' });
1322
1326
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: MenuService, decorators: [{
1323
1327
  type: Injectable,
1324
1328
  args: [{
1325
1329
  providedIn: 'root',
1326
1330
  }]
1327
- }], ctorParameters: function () { return [{ type: i2$1.ConfigService }, { type: i2$2.DocumentService }, { type: i3.UserProviderService }, { type: i4.NGXLogger }, { type: i2$1.MenuIncludeService }, { type: i1$4.Router }]; } });
1331
+ }], ctorParameters: function () { return [{ type: i2$1.ConfigService }, { type: i2$2.DocumentService }, { type: i3.UserProviderService }, { type: i4.NGXLogger }, { type: i2$1.MenuIncludeService }, { type: i1$4.Router }, { type: i1$3.KeycloakService }]; } });
1328
1332
 
1329
1333
  /*
1330
1334
  * Copyright 2015-2020 Ritense BV, the Netherlands.