@mediusinc/mng-commons 5.3.0-rc.0 → 5.3.0-rc.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.
Files changed (30) hide show
  1. package/core/components/pages/error/error.page.component.d.ts +3 -0
  2. package/core/components/pages/not-found/not-found.page.component.d.ts +3 -0
  3. package/core/enum/enum-helpers.d.ts +5 -0
  4. package/core/index.d.ts +1 -1
  5. package/core/services/{local-storage-config.service.d.ts → commons-storage.service.d.ts} +4 -3
  6. package/core/services/commons.service.d.ts +24 -0
  7. package/core/services/tokens/module-config.token.d.ts +23 -2
  8. package/esm2022/core/components/pages/error/error.page.component.mjs +4 -1
  9. package/esm2022/core/components/pages/not-found/not-found.page.component.mjs +4 -1
  10. package/esm2022/core/enum/enum-helpers.mjs +10 -1
  11. package/esm2022/core/index.mjs +2 -2
  12. package/esm2022/core/pipes/enum.pipe.mjs +16 -5
  13. package/esm2022/core/provide.mjs +3 -3
  14. package/esm2022/core/router/route-builder.mjs +8 -1
  15. package/esm2022/core/security/permission.guard.mjs +2 -2
  16. package/esm2022/core/security/permission.service.mjs +2 -2
  17. package/esm2022/core/services/commons-storage.service.mjs +31 -0
  18. package/esm2022/core/services/commons.service.mjs +25 -1
  19. package/esm2022/core/services/tokens/module-config.token.mjs +1 -1
  20. package/esm2022/table/components/table/table.component.mjs +6 -6
  21. package/fesm2022/mediusinc-mng-commons-core.mjs +72 -14
  22. package/fesm2022/mediusinc-mng-commons-core.mjs.map +1 -1
  23. package/fesm2022/mediusinc-mng-commons-table.mjs +5 -5
  24. package/fesm2022/mediusinc-mng-commons-table.mjs.map +1 -1
  25. package/i18n/en.json +8 -0
  26. package/i18n/sl.json +8 -0
  27. package/package.json +1 -1
  28. package/table/components/table/table.component.d.ts +1 -1
  29. package/version-info.json +5 -5
  30. package/esm2022/core/services/local-storage-config.service.mjs +0 -29
@@ -420,7 +420,13 @@ class CommonsService {
420
420
  });
421
421
  this.breadcrumbs = signal([]);
422
422
  // visual
423
+ /**
424
+ * @deprecated Use layout colorScheme instead.
425
+ */
423
426
  this.colorScheme = signal(this.moduleConfig?.app?.colorScheme ?? 'light');
427
+ /**
428
+ * @deprecated Use layout colorScheme instead.
429
+ */
424
430
  this.colorSchemeIsLight = computed(() => this.colorScheme() === 'light');
425
431
  // user
426
432
  this.user = signal(undefined);
@@ -428,11 +434,29 @@ class CommonsService {
428
434
  // APP section
429
435
  this.appName = signal(this.moduleConfig?.app?.name ?? 'app.name');
430
436
  this.appOwner = signal(this.moduleConfig?.app?.owner ?? 'app.owner');
437
+ /**
438
+ * @deprecated Use layout app logo instead.
439
+ */
431
440
  this.appLogoLight = signal(this.moduleConfig?.app?.logoPathLight ? this.moduleConfig.app.logoPathLight : this.moduleConfig?.app?.logoPath ?? 'assets/layout/images/logo.png');
441
+ /**
442
+ * @deprecated Use layout app logo instead.
443
+ */
432
444
  this.appLogoDark = signal(this.moduleConfig?.app?.logoPathDark ? this.moduleConfig.app.logoPathDark : this.moduleConfig?.app?.logoPath ?? 'assets/layout/images/logo.png');
445
+ /**
446
+ * @deprecated Use layout app logo instead.
447
+ */
433
448
  this.appLogo = computed(() => (this.colorSchemeIsLight() ? this.appLogoLight() : this.appLogoDark()));
449
+ /**
450
+ * @deprecated Use layout app logo instead.
451
+ */
434
452
  this.appLogoNameLight = signal(this.moduleConfig?.app?.logoNamePathLight ? this.moduleConfig.app.logoNamePathLight : this.moduleConfig?.app?.logoNamePath ?? 'assets/layout/images/logo-appname.png');
453
+ /**
454
+ * @deprecated Use layout app logo instead.
455
+ */
435
456
  this.appLogoNameDark = signal(this.moduleConfig?.app?.logoNamePathDark ? this.moduleConfig.app.logoNamePathDark : this.moduleConfig?.app?.logoNamePath ?? 'assets/layout/images/logo-appname.png');
457
+ /**
458
+ * @deprecated Use layout app logo instead.
459
+ */
436
460
  this.appLogoName = computed(() => (this.colorSchemeIsLight() ? this.appLogoNameLight() : this.appLogoNameDark()));
437
461
  this.appLocales = signal(this.moduleConfig?.app?.locales ?? ['en']);
438
462
  this._appLocale = signal(this.initAppLocale());
@@ -676,6 +700,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.5", ngImpor
676
700
  type: Injectable
677
701
  }], ctorParameters: () => [] });
678
702
 
703
+ /**
704
+ * @deprecated Use ErrorPageComponent from layout instead.
705
+ */
679
706
  class ErrorPageComponent {
680
707
  constructor(commons) {
681
708
  this.commons = commons;
@@ -688,6 +715,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.5", ngImpor
688
715
  args: [{ standalone: true, selector: 'mng-error-page', imports: [ButtonModule, TranslateModule, RouterLink], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div [class]=\"'exception-body min-h-screen ' + (commons.colorSchemeIsLight() ? 'layout-light' : 'layout-dark')\">\n <div class=\"exception-container min-h-screen flex align-items-center justify-content-center flex-column bg-auto md:bg-contain bg-no-repeat\">\n <div class=\"exception-panel text-center flex align-items-center justify-content-center flex-column\">\n <h1 class=\"text-red-400 mb-0\">{{ 'pages.notFound.title' | translate }}</h1>\n <h3 class=\"text-red-300\">{{ 'pages.notFound.subtitle' | translate }}</h3>\n <button type=\"button\" pButton [label]=\"'general.returnHome' | translate\" [routerLink]=\"['/']\"></button>\n </div>\n <div class=\"exception-footer align-items-center flex\">\n <img [src]=\"commons.appLogo()\" class=\"exception-logo\" alt=\"App logo\" />\n <img [src]=\"commons.appLogoName()\" class=\"exception-appname ml-3\" alt=\"App name\" />\n </div>\n </div>\n</div>\n", styles: [".exception-body{background:var(--surface-ground)}.exception-body .exception-container{background:var(--exception-pages-image);background-repeat:no-repeat;background-size:contain;box-sizing:border-box}.exception-body .exception-container .exception-panel{box-sizing:border-box;flex-grow:1;margin-top:3rem;margin-bottom:3rem}.exception-body .exception-container .exception-panel h1{font-size:140px;font-weight:900;text-shadow:0 0 50px rgba(252,97,97,.2)}.exception-body .exception-container .exception-panel h3{font-size:80px;font-weight:900;margin-top:-90px;margin-bottom:50px}.exception-body .exception-container .exception-panel button{margin-top:50px}.exception-body .exception-container .exception-footer{margin-bottom:2rem}.exception-body .exception-container .exception-footer .exception-logo{width:34px}.exception-body .exception-container .exception-footer .exception-appname{width:72px}\n"] }]
689
716
  }], ctorParameters: () => [{ type: CommonsService }] });
690
717
 
718
+ /**
719
+ * @deprecated Use ErrorPageComponent from layout instead.
720
+ */
691
721
  class NotFoundPageComponent {
692
722
  constructor(commons) {
693
723
  this.commons = commons;
@@ -1379,6 +1409,15 @@ function getEnumConstantNamesFromObject(enumObj) {
1379
1409
  // in number enum, the numbers are also represented in objects and should be filtered out
1380
1410
  return Object.keys(enumObj).filter(v => isNaN(+v));
1381
1411
  }
1412
+ /**
1413
+ * Returns array of values for constants in enum.
1414
+ * @param enumType Enum object.
1415
+ */
1416
+ function getEnumConstantValues(enumType) {
1417
+ return Object.keys(enumType)
1418
+ .filter(v => isNaN(+v))
1419
+ .map(v => enumType[v]);
1420
+ }
1382
1421
  /**
1383
1422
  * Returns array of string values for constants in enum.
1384
1423
  * @param enumType Enum object.
@@ -2287,14 +2326,25 @@ function findReflectEnumName(enumType) {
2287
2326
 
2288
2327
  class EnumPipe {
2289
2328
  transform(value, enumDesc, i18nPath) {
2290
- if (!value || (typeof value !== 'number' && typeof value !== 'string')) {
2329
+ if (value == null || (typeof value !== 'number' && typeof value !== 'string') || !enumDesc) {
2291
2330
  return value;
2292
2331
  }
2293
- const enumConstantName = !enumDesc || enumDesc.nameAsValue ? value : getEnumConstantNameFromObject(enumDesc.type, value) ?? value;
2332
+ const enumValue = enumDesc.nameAsValue ? value : getEnumConstantNameFromObject(enumDesc.type, value);
2333
+ if (enumValue == null) {
2334
+ // no constant name found (probably not enum), return value
2335
+ return value;
2336
+ }
2337
+ if (enumDesc.nameAsValue) {
2338
+ // check if value exists in enum if nameAsValue is used
2339
+ const enumValueCheck = getEnumConstantValues(enumDesc.type).find(v => v === enumValue);
2340
+ if (enumValueCheck == null) {
2341
+ return value;
2342
+ }
2343
+ }
2294
2344
  if (typeof i18nPath === 'undefined' && enumDesc) {
2295
2345
  i18nPath = enumDesc.i18nBaseKey ?? findReflectEnumName(enumDesc.type);
2296
2346
  }
2297
- return i18nPath ? `${i18nPath}.${enumConstantName}` : enumConstantName;
2347
+ return i18nPath ? `${i18nPath}.${enumValue}` : enumValue;
2298
2348
  }
2299
2349
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.5", ngImport: i0, type: EnumPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
2300
2350
  static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "18.0.5", ngImport: i0, type: EnumPipe, isStandalone: true, name: "mngEnum" }); }
@@ -2791,7 +2841,7 @@ class PermissionService {
2791
2841
  canActivateRouteService(permission, route) {
2792
2842
  const serviceInstance = this.injector.get(permission.service);
2793
2843
  if (!serviceInstance) {
2794
- this.logger.debug(`WARNING: Service instance could not be retreived for type ${permission.service}`);
2844
+ this.logger.debug(`WARNING: Service instance could not be retrieved for type ${permission.service}`);
2795
2845
  return of(false);
2796
2846
  }
2797
2847
  return serviceInstance.canActivateRoute(route);
@@ -2859,7 +2909,7 @@ const permissionGuard = (route) => {
2859
2909
  const permission = inject(PermissionService);
2860
2910
  const data = route.data;
2861
2911
  if (data.permissions) {
2862
- return permission.canActivateRoute(data.permissions).pipe(first());
2912
+ return permission.canActivateRoute(data.permissions, route).pipe(first());
2863
2913
  }
2864
2914
  else {
2865
2915
  return of(true);
@@ -3181,6 +3231,13 @@ class RouteBuilder {
3181
3231
  if (finalChild.routerLink) {
3182
3232
  finalChild.routerLink = removeRouteEmptyPathSegments(finalChild.routerLink);
3183
3233
  }
3234
+ // Propagate permissions to children
3235
+ if (!finalChild.permissions && this.routeData.permissions) {
3236
+ finalChild.permissions = this.routeData.permissions;
3237
+ }
3238
+ if (!finalChild.permissions && this.permissions) {
3239
+ finalChild.permissions = this.permissions;
3240
+ }
3184
3241
  return finalChild;
3185
3242
  };
3186
3243
  this.menuItemChildren.forEach(child => menuItemChildren.push(processMenuItemChild(child)));
@@ -3826,30 +3883,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.5", ngImpor
3826
3883
  type: Injectable
3827
3884
  }] });
3828
3885
 
3829
- class LocalStorageService {
3886
+ class CommonsStorageService {
3830
3887
  constructor() {
3888
+ this.localStorage = inject(BROWSER_STORAGE_IT);
3831
3889
  this._configKey = 'CommonsUserPrefs';
3832
3890
  }
3833
3891
  buildLocalStorageKey(type, key) {
3834
3892
  return `${this._configKey}_${type}_${key}`;
3835
3893
  }
3836
3894
  getItem(type, key) {
3837
- const localstorageData = localStorage.getItem(this.buildLocalStorageKey(type, key));
3895
+ const localstorageData = this.localStorage.getItem(this.buildLocalStorageKey(type, key));
3838
3896
  if (localstorageData) {
3839
3897
  return JSON.parse(localstorageData);
3840
3898
  }
3841
3899
  return undefined;
3842
3900
  }
3843
3901
  setItem(type, key, value) {
3844
- localStorage.setItem(this.buildLocalStorageKey(type, key), JSON.stringify(value));
3902
+ this.localStorage.setItem(this.buildLocalStorageKey(type, key), JSON.stringify(value));
3845
3903
  }
3846
3904
  removeItem(type, key) {
3847
- localStorage.removeItem(this.buildLocalStorageKey(type, key));
3905
+ this.localStorage.removeItem(this.buildLocalStorageKey(type, key));
3848
3906
  }
3849
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.5", ngImport: i0, type: LocalStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
3850
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.5", ngImport: i0, type: LocalStorageService }); }
3907
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.5", ngImport: i0, type: CommonsStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
3908
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.5", ngImport: i0, type: CommonsStorageService }); }
3851
3909
  }
3852
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.5", ngImport: i0, type: LocalStorageService, decorators: [{
3910
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.5", ngImport: i0, type: CommonsStorageService, decorators: [{
3853
3911
  type: Injectable
3854
3912
  }] });
3855
3913
 
@@ -3901,7 +3959,7 @@ function provideCommons(config, ...features) {
3901
3959
  CommonsService,
3902
3960
  CommonsRouterService,
3903
3961
  PermissionService,
3904
- LocalStorageService,
3962
+ CommonsStorageService,
3905
3963
  {
3906
3964
  provide: COMMONS_MODULE_CONFIG_IT,
3907
3965
  useValue: config
@@ -3950,5 +4008,5 @@ function provideCommons(config, ...features) {
3950
4008
  * Generated bundle index. Do not edit.
3951
4009
  */
3952
4010
 
3953
- export { ACommonsErrorBase, APermissions, BROWSER_STORAGE_IT, BooleanPipe, COMMONS_INITIALIZER_IT, COMMONS_MODULE_CONFIG_IT, ClassMapPipe, CommonsConfigurationService, CommonsErrorHandler, CommonsFeatureTypeEnum, CommonsHttpError, CommonsInitEventEnum, CommonsInitService, CommonsInternalError, CommonsRouterService, CommonsService, ComponentDirective, DataProvider, DataProviderInst, EnumName, EnumPipe, EnumerateAsyncPipe, EnumeratePipe, ErrorPageComponent, FilterMatchMode, GetterPipe, I18nPropertyPipe, JsonPathPipe, LOG_PUBLISHERS, LocalStorageService, LogLevelEnum, LogPublisherConsoleService, LoggerService, NotFoundPageComponent, NotificationWrapperComponent, ParametrizePipe, PermissionService, PermissionTypeEnum, Permissions, RouteBuilder, RoutesBuilder, StyleLevelEnum, StyleSizeEnum, Styles, TemplateDirective, TemplatePipe, TypeName, TypeRegistry, adjustRouteMenuLazyChildrenRouterLinks, angularDateFormatHasSeconds, angularDateFormatHasTime, appendRoutePathToBasePath, boolean$Attribute, booleanOrUndefinedAttribute, commonsActionErrorContextToString, commonsErrorToString, commonsInitializerProvider, copyDataListParams, createLazyChildrenRoute, createLazyRoute, createRoute, createRouteRedirect, createRoutes, dataListParamsFilterToUrlQuery, dataListParamsFilterValueToUrlString, dataListParamsFiltersToUrlQuery, dataListParamsSortToUrlQuery, dataListParamsToUrlQuery, dataProviderBase, dataProviderFromClass, dataProviderWithService, dateToIsoString, defineReflectEnumName, defineReflectTypeName, doesUrlMatchRouterLink, errorCauseToString, errorToString, escapeHtml, escapeHtmlAny, findReflectEnumName, findReflectTypeName, findTemplateByName, flattenObjectKeys, fromAngularDateFormatToPrime, fromEnumConstantsAsValueArray, fromEnumValuesAsValueArray, fromSubscribeError, fromTableLoadToDataListParams, fromUrlQueryToDataListParams, getEnumConstantName, getEnumConstantNameFromObject, getEnumConstantNames, getEnumConstantNamesFromObject, getEnumConstantValuesAsNumber, getEnumConstantValuesAsString, getEnumerationI18nBaseKey, getErrorLogLevel, getErrorName, getHttpErrorResponse, getHttpErrorResponseStatus, getHttpErrorResponseStatusText, getI18n, getI18nAsync, getI18nErrorParams, getI18nForError, getI18nTypeGroupKey, getI18nTypeKeyBasePath, getI18nTypeName, getI18nTypeNameAsync, getI18nTypeParams, getI18nTypeParamsAsync, getI18nTypePropertyKey, getI18nTypeTabKey, getObjectGetters, getObjectProperties, getObjectPropertyByPath, httpErrorResponseToString, isHttpErrorResponse, isPermitted, isRbacPermitted, itemIdToDefined, itemIdToNumber, itemIdToString, mapToDataList, mergeDataListParamsWithDefaults, number$Attribute, objectDeepCopy, objectDeepMerge, permissionGuard, populateI18nParams, populateI18nTypeParams, provideCommons, reflectEnumNameKey, reflectTypeNameExists, reflectTypeNameKey, removeRouteEmptyPathSegments, selectEnumerationI18n, selectI18n, stringify, throwError, toEnumerationI18nEnumerate, toObservable, toastMessage, valueToDefined };
4011
+ export { ACommonsErrorBase, APermissions, BROWSER_STORAGE_IT, BooleanPipe, COMMONS_INITIALIZER_IT, COMMONS_MODULE_CONFIG_IT, ClassMapPipe, CommonsConfigurationService, CommonsErrorHandler, CommonsFeatureTypeEnum, CommonsHttpError, CommonsInitEventEnum, CommonsInitService, CommonsInternalError, CommonsRouterService, CommonsService, CommonsStorageService, ComponentDirective, DataProvider, DataProviderInst, EnumName, EnumPipe, EnumerateAsyncPipe, EnumeratePipe, ErrorPageComponent, FilterMatchMode, GetterPipe, I18nPropertyPipe, JsonPathPipe, LOG_PUBLISHERS, LogLevelEnum, LogPublisherConsoleService, LoggerService, NotFoundPageComponent, NotificationWrapperComponent, ParametrizePipe, PermissionService, PermissionTypeEnum, Permissions, RouteBuilder, RoutesBuilder, StyleLevelEnum, StyleSizeEnum, Styles, TemplateDirective, TemplatePipe, TypeName, TypeRegistry, adjustRouteMenuLazyChildrenRouterLinks, angularDateFormatHasSeconds, angularDateFormatHasTime, appendRoutePathToBasePath, boolean$Attribute, booleanOrUndefinedAttribute, commonsActionErrorContextToString, commonsErrorToString, commonsInitializerProvider, copyDataListParams, createLazyChildrenRoute, createLazyRoute, createRoute, createRouteRedirect, createRoutes, dataListParamsFilterToUrlQuery, dataListParamsFilterValueToUrlString, dataListParamsFiltersToUrlQuery, dataListParamsSortToUrlQuery, dataListParamsToUrlQuery, dataProviderBase, dataProviderFromClass, dataProviderWithService, dateToIsoString, defineReflectEnumName, defineReflectTypeName, doesUrlMatchRouterLink, errorCauseToString, errorToString, escapeHtml, escapeHtmlAny, findReflectEnumName, findReflectTypeName, findTemplateByName, flattenObjectKeys, fromAngularDateFormatToPrime, fromEnumConstantsAsValueArray, fromEnumValuesAsValueArray, fromSubscribeError, fromTableLoadToDataListParams, fromUrlQueryToDataListParams, getEnumConstantName, getEnumConstantNameFromObject, getEnumConstantNames, getEnumConstantNamesFromObject, getEnumConstantValues, getEnumConstantValuesAsNumber, getEnumConstantValuesAsString, getEnumerationI18nBaseKey, getErrorLogLevel, getErrorName, getHttpErrorResponse, getHttpErrorResponseStatus, getHttpErrorResponseStatusText, getI18n, getI18nAsync, getI18nErrorParams, getI18nForError, getI18nTypeGroupKey, getI18nTypeKeyBasePath, getI18nTypeName, getI18nTypeNameAsync, getI18nTypeParams, getI18nTypeParamsAsync, getI18nTypePropertyKey, getI18nTypeTabKey, getObjectGetters, getObjectProperties, getObjectPropertyByPath, httpErrorResponseToString, isHttpErrorResponse, isPermitted, isRbacPermitted, itemIdToDefined, itemIdToNumber, itemIdToString, mapToDataList, mergeDataListParamsWithDefaults, number$Attribute, objectDeepCopy, objectDeepMerge, permissionGuard, populateI18nParams, populateI18nTypeParams, provideCommons, reflectEnumNameKey, reflectTypeNameExists, reflectTypeNameKey, removeRouteEmptyPathSegments, selectEnumerationI18n, selectI18n, stringify, throwError, toEnumerationI18nEnumerate, toObservable, toastMessage, valueToDefined };
3954
4012
  //# sourceMappingURL=mediusinc-mng-commons-core.mjs.map