@kuzntsv/uikit 1.0.58 → 1.0.59
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,
|
|
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";
|
|
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";
|
|
@@ -2736,7 +2736,6 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
2736
2736
|
});
|
|
2737
2737
|
var BaseSignalPageClass = class BaseSignalPageClass {
|
|
2738
2738
|
dialog = inject(MatDialog);
|
|
2739
|
-
injector = inject(Injector);
|
|
2740
2739
|
entityService;
|
|
2741
2740
|
entityEditComponent;
|
|
2742
2741
|
extraData;
|
|
@@ -2763,27 +2762,18 @@ var BaseSignalPageClass = class BaseSignalPageClass {
|
|
|
2763
2762
|
hideRoles = [HIDE_ROLE_MARKER];
|
|
2764
2763
|
allowMultiSelect = false;
|
|
2765
2764
|
selected = [];
|
|
2766
|
-
fnGetData = signal(null, ...ngDevMode ? [{ debugName: "fnGetData" }] : /* istanbul ignore next */ []);
|
|
2767
|
-
fnGetCount = signal(null, ...ngDevMode ? [{ debugName: "fnGetCount" }] : /* istanbul ignore next */ []);
|
|
2768
|
-
fnMapEntity = signal(void 0, ...ngDevMode ? [{ debugName: "fnMapEntity" }] : /* istanbul ignore next */ []);
|
|
2769
2765
|
dataResource = computed(() => {
|
|
2770
|
-
const fetchFn = this.fnGetData();
|
|
2771
|
-
if (!fetchFn) return null;
|
|
2772
2766
|
this.tableState();
|
|
2773
2767
|
this.filters();
|
|
2774
|
-
return
|
|
2768
|
+
return this.fnGetData();
|
|
2775
2769
|
}, ...ngDevMode ? [{ debugName: "dataResource" }] : /* istanbul ignore next */ []);
|
|
2776
2770
|
countResource = computed(() => {
|
|
2777
|
-
const fetchCountFn = this.fnGetCount();
|
|
2778
|
-
if (!fetchCountFn) return null;
|
|
2779
2771
|
this.filters();
|
|
2780
|
-
return
|
|
2772
|
+
return this.fnGetCount();
|
|
2781
2773
|
}, ...ngDevMode ? [{ debugName: "countResource" }] : /* istanbul ignore next */ []);
|
|
2782
2774
|
data = computed(() => {
|
|
2783
2775
|
const rawData = this.dataResource()?.value() || [];
|
|
2784
|
-
|
|
2785
|
-
if (mapFn && Array.isArray(rawData)) return rawData.map(mapFn());
|
|
2786
|
-
return rawData;
|
|
2776
|
+
return this.fnMapEntity && Array.isArray(rawData) ? rawData.map(this.fnMapEntity()) : rawData;
|
|
2787
2777
|
}, ...ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []);
|
|
2788
2778
|
length = computed(() => this.countResource()?.value() || 0, ...ngDevMode ? [{ debugName: "length" }] : /* istanbul ignore next */ []);
|
|
2789
2779
|
isLoading = computed(() => {
|
|
@@ -2791,7 +2781,6 @@ var BaseSignalPageClass = class BaseSignalPageClass {
|
|
|
2791
2781
|
const countLoading = this.countResource()?.isLoading() ?? false;
|
|
2792
2782
|
return dataLoading || countLoading;
|
|
2793
2783
|
}, ...ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []);
|
|
2794
|
-
componentInjector = null;
|
|
2795
2784
|
editBtnDisabled = true;
|
|
2796
2785
|
removeBtnDisabled = true;
|
|
2797
2786
|
dblClickedEventEnable = true;
|
|
@@ -2820,28 +2809,6 @@ var BaseSignalPageClass = class BaseSignalPageClass {
|
|
|
2820
2809
|
});
|
|
2821
2810
|
const validation = this.filterSchema.safeParse(initial);
|
|
2822
2811
|
this.filters.set(validation.success ? validation.data : this.defaultFilters);
|
|
2823
|
-
this.trackFilterChanges();
|
|
2824
|
-
}
|
|
2825
|
-
trackFilterChanges() {
|
|
2826
|
-
if (!this.defaultFilters) return;
|
|
2827
|
-
let previousFilters = { ...this.filters() };
|
|
2828
|
-
effect(() => {
|
|
2829
|
-
const currentFilters = this.filters();
|
|
2830
|
-
const prefix = this.storagePrefix;
|
|
2831
|
-
let filterChanged = false;
|
|
2832
|
-
Object.keys(currentFilters).forEach((key) => {
|
|
2833
|
-
const prevVal = previousFilters[key];
|
|
2834
|
-
const currVal = currentFilters[key];
|
|
2835
|
-
if (prevVal !== currVal) {
|
|
2836
|
-
filterChanged = true;
|
|
2837
|
-
const storageKey = `${prefix}${String(key)}`;
|
|
2838
|
-
if (currVal === null || currVal === void 0 || currVal === "" || currVal === 0 || currVal === -1 || Array.isArray(currVal) && currVal.length === 0) localStorage.removeItem(storageKey);
|
|
2839
|
-
else this.localStorageService.saveData(storageKey, JSON.stringify(currVal));
|
|
2840
|
-
}
|
|
2841
|
-
});
|
|
2842
|
-
if (filterChanged) {}
|
|
2843
|
-
previousFilters = { ...currentFilters };
|
|
2844
|
-
});
|
|
2845
2812
|
}
|
|
2846
2813
|
clearEvent() {
|
|
2847
2814
|
if (!this.defaultFilters) return;
|
|
@@ -2888,16 +2855,28 @@ var BaseSignalPageClass = class BaseSignalPageClass {
|
|
|
2888
2855
|
if (this.isLoading()) this.loaderService.show();
|
|
2889
2856
|
else this.loaderService.hide();
|
|
2890
2857
|
});
|
|
2858
|
+
let previousFilters = { ...this.filters() };
|
|
2859
|
+
effect(() => {
|
|
2860
|
+
const currentFilters = this.filters();
|
|
2861
|
+
const prefix = this.storagePrefix;
|
|
2862
|
+
let filterChanged = false;
|
|
2863
|
+
Object.keys(currentFilters).forEach((key) => {
|
|
2864
|
+
const prevVal = previousFilters[key];
|
|
2865
|
+
const currVal = currentFilters[key];
|
|
2866
|
+
if (prevVal !== currVal) {
|
|
2867
|
+
filterChanged = true;
|
|
2868
|
+
const storageKey = `${prefix}${String(key)}`;
|
|
2869
|
+
if (currVal === null || currVal === void 0 || currVal === "" || currVal === 0 || currVal === -1 || Array.isArray(currVal) && currVal.length === 0) localStorage.removeItem(storageKey);
|
|
2870
|
+
else this.localStorageService.saveData(storageKey, JSON.stringify(currVal));
|
|
2871
|
+
}
|
|
2872
|
+
});
|
|
2873
|
+
if (filterChanged) {}
|
|
2874
|
+
previousFilters = { ...currentFilters };
|
|
2875
|
+
});
|
|
2891
2876
|
}
|
|
2892
2877
|
ngOnDestroy() {
|
|
2893
2878
|
this.subscription.unsubscribe();
|
|
2894
2879
|
}
|
|
2895
|
-
subscribeToLoadData(fnGetData, fnGetCount, fnMapEntity, injector) {
|
|
2896
|
-
if (injector) this.componentInjector = injector;
|
|
2897
|
-
this.fnMapEntity.set(fnMapEntity);
|
|
2898
|
-
this.fnGetData.set(fnGetData);
|
|
2899
|
-
this.fnGetCount.set(fnGetCount);
|
|
2900
|
-
}
|
|
2901
2880
|
setFilter(key, value) {
|
|
2902
2881
|
const storageKey = `${this.constructor.name}_Filter_${String(key)}`;
|
|
2903
2882
|
this.tableState.update((prev) => ({
|