@kuzntsv/uikit 1.0.56 → 1.0.58

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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from "@angular/core";
2
- import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Directive, ElementRef, HostListener, Injectable, InjectionToken, NgZone, Pipe, computed, effect, inject, input, linkedSignal, makeEnvironmentProviders, model, output, signal, viewChild } from "@angular/core";
2
+ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Directive, ElementRef, HostListener, Injectable, InjectionToken, Injector, NgZone, Pipe, computed, effect, inject, input, linkedSignal, makeEnvironmentProviders, model, output, runInInjectionContext, signal, viewChild } from "@angular/core";
3
3
  import { Router, RouterLink } from "@angular/router";
4
4
  import { ReplaySubject, Subject, Subscription, filter, finalize, forkJoin, map, of, startWith, switchMap, take, tap } from "rxjs";
5
5
  import { API_NAME, AuthService, HIDE_ROLE_MARKER, NotificationService, RoleService, UIKIT_NOTIFICATION_TOKEN } from "@kuzntsv/uikit";
@@ -2582,6 +2582,7 @@ var BaseSignalEditClass = class BaseSignalEditClass {
2582
2582
  });
2583
2583
  loaderService = inject(LoaderService);
2584
2584
  notificationService = inject(NotificationService);
2585
+ roleService = inject(RoleService);
2585
2586
  subscription = new Subscription();
2586
2587
  domainModelToFormModel(domainModel) {
2587
2588
  return { ...domainModel };
@@ -2609,6 +2610,12 @@ var BaseSignalEditClass = class BaseSignalEditClass {
2609
2610
  this.dialogRef?.close(this.dialogData());
2610
2611
  } else this.form().markAsTouched();
2611
2612
  }
2613
+ isVisibleForForbiddenRoles(forbiddenRoles) {
2614
+ return !this.roleService.hasForbiddenRole(forbiddenRoles);
2615
+ }
2616
+ isVisibleForAllowedRoles(allowedRoles) {
2617
+ return this.roleService.hasAnyRole(allowedRoles);
2618
+ }
2612
2619
  static ɵfac = i0.ɵɵngDeclareFactory({
2613
2620
  minVersion: "12.0.0",
2614
2621
  version: "22.2.2",
@@ -2729,6 +2736,7 @@ i0.ɵɵngDeclareClassMetadata({
2729
2736
  });
2730
2737
  var BaseSignalPageClass = class BaseSignalPageClass {
2731
2738
  dialog = inject(MatDialog);
2739
+ injector = inject(Injector);
2732
2740
  entityService;
2733
2741
  entityEditComponent;
2734
2742
  extraData;
@@ -2763,13 +2771,13 @@ var BaseSignalPageClass = class BaseSignalPageClass {
2763
2771
  if (!fetchFn) return null;
2764
2772
  this.tableState();
2765
2773
  this.filters();
2766
- return fetchFn();
2774
+ return runInInjectionContext(this.componentInjector || this.injector, () => fetchFn());
2767
2775
  }, ...ngDevMode ? [{ debugName: "dataResource" }] : /* istanbul ignore next */ []);
2768
2776
  countResource = computed(() => {
2769
2777
  const fetchCountFn = this.fnGetCount();
2770
2778
  if (!fetchCountFn) return null;
2771
2779
  this.filters();
2772
- return fetchCountFn();
2780
+ return runInInjectionContext(this.componentInjector || this.injector, () => fetchCountFn());
2773
2781
  }, ...ngDevMode ? [{ debugName: "countResource" }] : /* istanbul ignore next */ []);
2774
2782
  data = computed(() => {
2775
2783
  const rawData = this.dataResource()?.value() || [];
@@ -2783,6 +2791,7 @@ var BaseSignalPageClass = class BaseSignalPageClass {
2783
2791
  const countLoading = this.countResource()?.isLoading() ?? false;
2784
2792
  return dataLoading || countLoading;
2785
2793
  }, ...ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []);
2794
+ componentInjector = null;
2786
2795
  editBtnDisabled = true;
2787
2796
  removeBtnDisabled = true;
2788
2797
  dblClickedEventEnable = true;
@@ -2883,7 +2892,8 @@ var BaseSignalPageClass = class BaseSignalPageClass {
2883
2892
  ngOnDestroy() {
2884
2893
  this.subscription.unsubscribe();
2885
2894
  }
2886
- subscribeToLoadData(fnGetData, fnGetCount, fnMapEntity) {
2895
+ subscribeToLoadData(fnGetData, fnGetCount, fnMapEntity, injector) {
2896
+ if (injector) this.componentInjector = injector;
2887
2897
  this.fnMapEntity.set(fnMapEntity);
2888
2898
  this.fnGetData.set(fnGetData);
2889
2899
  this.fnGetCount.set(fnGetCount);