@kuzntsv/uikit 1.0.42 → 1.0.43

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.
@@ -29,7 +29,6 @@ import { MatDivider } from "@angular/material/divider";
29
29
  import { MatMenu, MatMenuContent, MatMenuItem, MatMenuTrigger } from "@angular/material/menu";
30
30
  import { MatToolbar } from "@angular/material/toolbar";
31
31
  import z, { z as z$1 } from "zod";
32
- import { rxResource } from "@angular/core/rxjs-interop";
33
32
  import { DomSanitizer } from "@angular/platform-browser";
34
33
  import { MatProgressSpinner } from "@angular/material/progress-spinner";
35
34
  import * as i3 from "@angular/cdk/scrolling";
@@ -2732,48 +2731,37 @@ var BaseSignalPageClass = class BaseSignalPageClass {
2732
2731
  editorRoles = [];
2733
2732
  executeRoles = [];
2734
2733
  hideRoles = [HIDE_ROLE_MARKER];
2735
- loadData$ = new Subject();
2736
- loadLength$ = new Subject();
2737
2734
  clearFilters = signal(null, ...ngDevMode ? [{ debugName: "clearFilters" }] : /* istanbul ignore next */ []);
2738
2735
  allowMultiSelect = false;
2739
2736
  selected = [];
2740
2737
  fnGetData = signal(null, ...ngDevMode ? [{ debugName: "fnGetData" }] : /* istanbul ignore next */ []);
2741
2738
  fnGetCount = signal(null, ...ngDevMode ? [{ debugName: "fnGetCount" }] : /* istanbul ignore next */ []);
2742
2739
  fnMapEntity = signal(void 0, ...ngDevMode ? [{ debugName: "fnMapEntity" }] : /* istanbul ignore next */ []);
2743
- dataResource = rxResource({
2744
- params: () => {
2745
- const fetchFn = this.fnGetData();
2746
- if (!fetchFn) return null;
2747
- return {
2748
- fetchFn,
2749
- state: this.tableState(),
2750
- mapFn: this.fnMapEntity()
2751
- };
2752
- },
2753
- stream: ({ params, abortSignal }) => {
2754
- if (!params) return of([]);
2755
- this.loaderService.show();
2756
- return params.fetchFn().pipe(map((v) => params.mapFn && Array.isArray(v) ? v.map(params.mapFn()) : v), finalize(() => {
2757
- this.loaderService.hide();
2758
- }));
2759
- }
2760
- });
2761
- countResource = rxResource({
2762
- params: () => {
2763
- const fetchCountFn = this.fnGetCount();
2764
- if (!fetchCountFn) return null;
2765
- return {
2766
- fetchCountFn,
2767
- state: this.tableState()
2768
- };
2769
- },
2770
- stream: ({ params }) => {
2771
- if (!params) return of(0);
2772
- return params.fetchCountFn();
2773
- }
2774
- });
2775
- data = computed(() => this.dataResource.value() || [], ...ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []);
2776
- length = computed(() => this.countResource.value() || 0, ...ngDevMode ? [{ debugName: "length" }] : /* istanbul ignore next */ []);
2740
+ dataResource = computed(() => {
2741
+ const fetchFn = this.fnGetData();
2742
+ if (!fetchFn) return null;
2743
+ this.tableState();
2744
+ this.filters();
2745
+ return fetchFn();
2746
+ }, ...ngDevMode ? [{ debugName: "dataResource" }] : /* istanbul ignore next */ []);
2747
+ countResource = computed(() => {
2748
+ const fetchCountFn = this.fnGetCount();
2749
+ if (!fetchCountFn) return null;
2750
+ this.filters();
2751
+ return fetchCountFn();
2752
+ }, ...ngDevMode ? [{ debugName: "countResource" }] : /* istanbul ignore next */ []);
2753
+ data = computed(() => {
2754
+ const rawData = this.dataResource()?.value() || [];
2755
+ const mapFn = this.fnMapEntity();
2756
+ if (mapFn && Array.isArray(rawData)) return rawData.map(mapFn());
2757
+ return rawData;
2758
+ }, ...ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []);
2759
+ length = computed(() => this.countResource()?.value() || 0, ...ngDevMode ? [{ debugName: "length" }] : /* istanbul ignore next */ []);
2760
+ isLoading = computed(() => {
2761
+ const dataLoading = this.dataResource()?.isLoading() ?? false;
2762
+ const countLoading = this.countResource()?.isLoading() ?? false;
2763
+ return dataLoading || countLoading;
2764
+ }, ...ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []);
2777
2765
  editBtnDisabled = true;
2778
2766
  removeBtnDisabled = true;
2779
2767
  dblClickedEventEnable = true;
@@ -2819,6 +2807,10 @@ var BaseSignalPageClass = class BaseSignalPageClass {
2819
2807
  pageIndex: Number(this.localStorageService.getData(this.constructor.name + "PageIndex")) || this.defaultPageIndex,
2820
2808
  pageSize: Number(this.localStorageService.getData(this.constructor.name + "PageSize")) || this.defaultPageSize
2821
2809
  });
2810
+ effect(() => {
2811
+ if (this.isLoading()) this.loaderService.show();
2812
+ else this.loaderService.hide();
2813
+ });
2822
2814
  }
2823
2815
  ngOnDestroy() {
2824
2816
  this.subscription.unsubscribe();
@@ -2830,6 +2822,10 @@ var BaseSignalPageClass = class BaseSignalPageClass {
2830
2822
  }
2831
2823
  setFilter(key, value) {
2832
2824
  const storageKey = `${this.constructor.name}_Filter_${key}`;
2825
+ this.tableState.update((prev) => ({
2826
+ ...prev,
2827
+ pageIndex: 0
2828
+ }));
2833
2829
  this.filters.update((prev) => {
2834
2830
  const next = { ...prev };
2835
2831
  if (value === null || value === void 0 || value === "" || value === "-1") {
@@ -2841,10 +2837,6 @@ var BaseSignalPageClass = class BaseSignalPageClass {
2841
2837
  }
2842
2838
  return next;
2843
2839
  });
2844
- this.tableState.update((prev) => ({
2845
- ...prev,
2846
- pageIndex: 0
2847
- }));
2848
2840
  }
2849
2841
  onPageChange(pageState) {
2850
2842
  this.localStorageService.saveData(this.constructor.name + "PageIndex", pageState.pageIndex.toString());
@@ -2991,8 +2983,8 @@ var BaseSignalPageClass = class BaseSignalPageClass {
2991
2983
  }
2992
2984
  }
2993
2985
  refreshEvent() {
2994
- this.dataResource.reload();
2995
- this.countResource.reload();
2986
+ this.dataResource()?.reload();
2987
+ this.countResource()?.reload();
2996
2988
  }
2997
2989
  clearEvent() {
2998
2990
  const prefix = this.constructor.name + "_Filter_";
@@ -3095,7 +3087,10 @@ var BaseSignalServiceClass = class BaseSignalServiceClass {
3095
3087
  this._refreshTrigger.update((v) => v + 1);
3096
3088
  }
3097
3089
  getObjects() {
3098
- return httpResource(() => ({ url: this.baseRoute }), {
3090
+ return httpResource(() => {
3091
+ this._refreshTrigger();
3092
+ return { url: this.baseRoute };
3093
+ }, {
3099
3094
  ...this.getHttpContext(),
3100
3095
  parse: (data) => {
3101
3096
  if (!data) return [];
@@ -3105,19 +3100,26 @@ var BaseSignalServiceClass = class BaseSignalServiceClass {
3105
3100
  }
3106
3101
  getObject(id) {
3107
3102
  const idSignal = typeof id === "function" ? id : () => id;
3108
- return httpResource(() => `${this.baseRoute}${idSignal()}`, {
3103
+ return httpResource(() => {
3104
+ this._refreshTrigger();
3105
+ return { url: `${this.baseRoute}${idSignal()}` };
3106
+ }, {
3109
3107
  ...this.getHttpContext(),
3110
3108
  parse: (data) => data ? new this.entityType(data).deserialize(data) : null
3111
3109
  });
3112
3110
  }
3113
3111
  getCount() {
3114
- return httpResource(() => ({ url: `${this.baseRoute}${this.countRoute}` }), {
3112
+ return httpResource(() => {
3113
+ this._refreshTrigger();
3114
+ return { url: `${this.baseRoute}${this.countRoute}` };
3115
+ }, {
3115
3116
  ...this.getHttpContext(),
3116
3117
  parse: (data) => Number(data)
3117
3118
  });
3118
3119
  }
3119
3120
  getObjectsByPaging(pageIndex, pageSize, sortColumn, direction) {
3120
3121
  return httpResource(() => {
3122
+ this._refreshTrigger();
3121
3123
  const queryParams = {};
3122
3124
  if (pageIndex() + 1) queryParams[this.pageIndexParam] = pageIndex() + 1;
3123
3125
  if (pageSize()) queryParams[this.pageSizeParam] = pageSize();