@kuzntsv/uikit 1.0.49 → 1.0.51
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, output, signal, viewChild } 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";
|
|
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";
|
|
@@ -2636,14 +2636,8 @@ var BaseSignalFilterClass = class BaseSignalFilterClass {
|
|
|
2636
2636
|
loaderService = inject(LoaderService);
|
|
2637
2637
|
notificationService = inject(NotificationService);
|
|
2638
2638
|
defaultDebounceTime = 500;
|
|
2639
|
-
|
|
2639
|
+
filter = model({}, ...ngDevMode ? [{ debugName: "filter" }] : /* istanbul ignore next */ []);
|
|
2640
2640
|
clearFilter = input(null, ...ngDevMode ? [{ debugName: "clearFilter" }] : /* istanbul ignore next */ []);
|
|
2641
|
-
filterChange = output();
|
|
2642
|
-
filter = linkedSignal(() => this.initialValues(), ...ngDevMode ? [{ debugName: "filter" }] : /* istanbul ignore next */ []);
|
|
2643
|
-
subscription = new Subscription();
|
|
2644
|
-
ngOnDestroy() {
|
|
2645
|
-
this.subscription.unsubscribe();
|
|
2646
|
-
}
|
|
2647
2641
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
2648
2642
|
minVersion: "12.0.0",
|
|
2649
2643
|
version: "22.2.2",
|
|
@@ -2658,9 +2652,9 @@ var BaseSignalFilterClass = class BaseSignalFilterClass {
|
|
|
2658
2652
|
type: BaseSignalFilterClass,
|
|
2659
2653
|
isStandalone: true,
|
|
2660
2654
|
inputs: {
|
|
2661
|
-
|
|
2662
|
-
classPropertyName: "
|
|
2663
|
-
publicName: "
|
|
2655
|
+
filter: {
|
|
2656
|
+
classPropertyName: "filter",
|
|
2657
|
+
publicName: "filter",
|
|
2664
2658
|
isSignal: true,
|
|
2665
2659
|
isRequired: false,
|
|
2666
2660
|
transformFunction: null
|
|
@@ -2673,7 +2667,7 @@ var BaseSignalFilterClass = class BaseSignalFilterClass {
|
|
|
2673
2667
|
transformFunction: null
|
|
2674
2668
|
}
|
|
2675
2669
|
},
|
|
2676
|
-
outputs: {
|
|
2670
|
+
outputs: { filter: "filterChange" },
|
|
2677
2671
|
ngImport: i0
|
|
2678
2672
|
});
|
|
2679
2673
|
};
|
|
@@ -2684,13 +2678,16 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
2684
2678
|
type: BaseSignalFilterClass,
|
|
2685
2679
|
decorators: [{ type: Directive }],
|
|
2686
2680
|
propDecorators: {
|
|
2687
|
-
|
|
2681
|
+
filter: [{
|
|
2688
2682
|
type: i0.Input,
|
|
2689
2683
|
args: [{
|
|
2690
2684
|
isSignal: true,
|
|
2691
|
-
alias: "
|
|
2685
|
+
alias: "filter",
|
|
2692
2686
|
required: false
|
|
2693
2687
|
}]
|
|
2688
|
+
}, {
|
|
2689
|
+
type: i0.Output,
|
|
2690
|
+
args: ["filterChange"]
|
|
2694
2691
|
}],
|
|
2695
2692
|
clearFilter: [{
|
|
2696
2693
|
type: i0.Input,
|
|
@@ -2699,10 +2696,6 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
2699
2696
|
alias: "clearFilter",
|
|
2700
2697
|
required: false
|
|
2701
2698
|
}]
|
|
2702
|
-
}],
|
|
2703
|
-
filterChange: [{
|
|
2704
|
-
type: i0.Output,
|
|
2705
|
-
args: ["filterChange"]
|
|
2706
2699
|
}]
|
|
2707
2700
|
}
|
|
2708
2701
|
});
|
|
@@ -2710,6 +2703,11 @@ var BaseSignalPageClass = class BaseSignalPageClass {
|
|
|
2710
2703
|
dialog = inject(MatDialog);
|
|
2711
2704
|
entityEditComponent;
|
|
2712
2705
|
extraData;
|
|
2706
|
+
filterSchema;
|
|
2707
|
+
defaultFilters;
|
|
2708
|
+
get storagePrefix() {
|
|
2709
|
+
return `${this.constructor.name}_Filter_`;
|
|
2710
|
+
}
|
|
2713
2711
|
defaultPageIndex = 0;
|
|
2714
2712
|
defaultPageSize = 10;
|
|
2715
2713
|
dialogEditWidth = "auto";
|
|
@@ -2726,7 +2724,6 @@ var BaseSignalPageClass = class BaseSignalPageClass {
|
|
|
2726
2724
|
editorRoles = [];
|
|
2727
2725
|
executeRoles = [];
|
|
2728
2726
|
hideRoles = [HIDE_ROLE_MARKER];
|
|
2729
|
-
clearFilters = signal(null, ...ngDevMode ? [{ debugName: "clearFilters" }] : /* istanbul ignore next */ []);
|
|
2730
2727
|
allowMultiSelect = false;
|
|
2731
2728
|
selected = [];
|
|
2732
2729
|
fnGetData = signal(null, ...ngDevMode ? [{ debugName: "fnGetData" }] : /* istanbul ignore next */ []);
|
|
@@ -2770,6 +2767,53 @@ var BaseSignalPageClass = class BaseSignalPageClass {
|
|
|
2770
2767
|
const saved = this.localStorageService.getData(this.constructor.name + "_Filters");
|
|
2771
2768
|
return saved ? JSON.parse(saved) : {};
|
|
2772
2769
|
}
|
|
2770
|
+
initFilters() {
|
|
2771
|
+
if (!this.filterSchema || !this.defaultFilters) return;
|
|
2772
|
+
const prefix = this.storagePrefix;
|
|
2773
|
+
const initial = { ...this.defaultFilters };
|
|
2774
|
+
Object.keys(this.defaultFilters).forEach((key) => {
|
|
2775
|
+
const storageKey = `${prefix}${key}`;
|
|
2776
|
+
const rawValue = this.localStorageService.getData(storageKey);
|
|
2777
|
+
if (rawValue !== null && rawValue !== void 0) try {
|
|
2778
|
+
initial[key] = JSON.parse(rawValue);
|
|
2779
|
+
} catch {
|
|
2780
|
+
initial[key] = rawValue;
|
|
2781
|
+
}
|
|
2782
|
+
});
|
|
2783
|
+
const validation = this.filterSchema.safeParse(initial);
|
|
2784
|
+
this.filters.set(validation.success ? validation.data : this.defaultFilters);
|
|
2785
|
+
this.trackFilterChanges();
|
|
2786
|
+
}
|
|
2787
|
+
trackFilterChanges() {
|
|
2788
|
+
if (!this.defaultFilters) return;
|
|
2789
|
+
let previousFilters = { ...this.filters() };
|
|
2790
|
+
effect(() => {
|
|
2791
|
+
const currentFilters = this.filters();
|
|
2792
|
+
const prefix = this.storagePrefix;
|
|
2793
|
+
let filterChanged = false;
|
|
2794
|
+
Object.keys(currentFilters).forEach((key) => {
|
|
2795
|
+
const prevVal = previousFilters[key];
|
|
2796
|
+
const currVal = currentFilters[key];
|
|
2797
|
+
if (prevVal !== currVal) {
|
|
2798
|
+
filterChanged = true;
|
|
2799
|
+
const storageKey = `${prefix}${String(key)}`;
|
|
2800
|
+
if (currVal === null || currVal === void 0 || currVal === "" || currVal === 0 || currVal === -1 || Array.isArray(currVal) && currVal.length === 0) localStorage.removeItem(storageKey);
|
|
2801
|
+
else this.localStorageService.saveData(storageKey, JSON.stringify(currVal));
|
|
2802
|
+
}
|
|
2803
|
+
});
|
|
2804
|
+
if (filterChanged) {}
|
|
2805
|
+
previousFilters = { ...currentFilters };
|
|
2806
|
+
});
|
|
2807
|
+
}
|
|
2808
|
+
clearEvent() {
|
|
2809
|
+
if (!this.defaultFilters) return;
|
|
2810
|
+
const prefix = this.storagePrefix;
|
|
2811
|
+
Object.keys(this.defaultFilters).forEach((key) => {
|
|
2812
|
+
localStorage.removeItem(`${prefix}${key}`);
|
|
2813
|
+
});
|
|
2814
|
+
this.filters.set({ ...this.defaultFilters });
|
|
2815
|
+
this.clearFilters.set({});
|
|
2816
|
+
}
|
|
2773
2817
|
getInitialFilters2() {
|
|
2774
2818
|
const prefix = this.constructor.name + "_Filter_";
|
|
2775
2819
|
const state = {};
|
|
@@ -2787,8 +2831,8 @@ var BaseSignalPageClass = class BaseSignalPageClass {
|
|
|
2787
2831
|
}
|
|
2788
2832
|
return state;
|
|
2789
2833
|
}
|
|
2790
|
-
filters = signal(
|
|
2791
|
-
|
|
2834
|
+
filters = signal({}, ...ngDevMode ? [{ debugName: "filters" }] : /* istanbul ignore next */ []);
|
|
2835
|
+
clearFilters = signal(null, ...ngDevMode ? [{ debugName: "clearFilters" }] : /* istanbul ignore next */ []);
|
|
2792
2836
|
tableState = signal({
|
|
2793
2837
|
sortActive: "",
|
|
2794
2838
|
sortDirection: "",
|
|
@@ -2816,21 +2860,25 @@ var BaseSignalPageClass = class BaseSignalPageClass {
|
|
|
2816
2860
|
this.fnGetCount.set(fnGetCount);
|
|
2817
2861
|
}
|
|
2818
2862
|
setFilter(key, value) {
|
|
2819
|
-
const storageKey = `${this.constructor.name}_Filter_${key}`;
|
|
2863
|
+
const storageKey = `${this.constructor.name}_Filter_${String(key)}`;
|
|
2820
2864
|
this.tableState.update((prev) => ({
|
|
2821
2865
|
...prev,
|
|
2822
2866
|
pageIndex: 0
|
|
2823
2867
|
}));
|
|
2868
|
+
let isValueEmpty = value === null || value === void 0 || value === "" || value === "-1";
|
|
2869
|
+
if (Array.isArray(value) && value.length === 0) isValueEmpty = true;
|
|
2870
|
+
if (isValueEmpty) this.localStorageService.removeData(storageKey);
|
|
2871
|
+
else this.localStorageService.saveData(storageKey, JSON.stringify(value));
|
|
2824
2872
|
this.filters.update((prev) => {
|
|
2825
|
-
|
|
2826
|
-
|
|
2873
|
+
if (isValueEmpty) {
|
|
2874
|
+
const next = { ...prev };
|
|
2827
2875
|
delete next[key];
|
|
2828
|
-
|
|
2829
|
-
} else {
|
|
2830
|
-
next[key] = value;
|
|
2831
|
-
this.localStorageService.saveData(storageKey, JSON.stringify(value));
|
|
2876
|
+
return next;
|
|
2832
2877
|
}
|
|
2833
|
-
return
|
|
2878
|
+
return {
|
|
2879
|
+
...prev,
|
|
2880
|
+
[key]: value
|
|
2881
|
+
};
|
|
2834
2882
|
});
|
|
2835
2883
|
}
|
|
2836
2884
|
onPageChange(pageState) {
|
|
@@ -2979,21 +3027,6 @@ var BaseSignalPageClass = class BaseSignalPageClass {
|
|
|
2979
3027
|
this.dataResource()?.reload();
|
|
2980
3028
|
this.countResource()?.reload();
|
|
2981
3029
|
}
|
|
2982
|
-
clearEvent() {
|
|
2983
|
-
const prefix = this.constructor.name + "_Filter_";
|
|
2984
|
-
const keysToRemove = [];
|
|
2985
|
-
for (let i = 0; i < localStorage.length; i++) {
|
|
2986
|
-
const key = localStorage.key(i);
|
|
2987
|
-
if (key && key.startsWith(prefix)) keysToRemove.push(key);
|
|
2988
|
-
}
|
|
2989
|
-
keysToRemove.forEach((key) => localStorage.removeItem(key));
|
|
2990
|
-
this.filters.set({});
|
|
2991
|
-
this.tableState.update((prev) => ({
|
|
2992
|
-
...prev,
|
|
2993
|
-
pageIndex: 0
|
|
2994
|
-
}));
|
|
2995
|
-
this.clearFilters.set({});
|
|
2996
|
-
}
|
|
2997
3030
|
onRemovalMessageChange(message) {
|
|
2998
3031
|
this.removalMessage = message;
|
|
2999
3032
|
}
|
|
@@ -3067,6 +3100,16 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
3067
3100
|
decorators: [{ type: Directive }],
|
|
3068
3101
|
ctorParameters: () => []
|
|
3069
3102
|
});
|
|
3103
|
+
function cleanFilterParams(filters) {
|
|
3104
|
+
const cleanParams = {};
|
|
3105
|
+
Object.keys(filters).forEach((key) => {
|
|
3106
|
+
const value = filters[key];
|
|
3107
|
+
if (value === null || value === void 0 || value === "") return;
|
|
3108
|
+
if (Array.isArray(value) && value.length === 0) return;
|
|
3109
|
+
cleanParams[key] = value;
|
|
3110
|
+
});
|
|
3111
|
+
return cleanParams;
|
|
3112
|
+
}
|
|
3070
3113
|
var BaseSignalServiceClass = class BaseSignalServiceClass {
|
|
3071
3114
|
countRoute = "count";
|
|
3072
3115
|
pageIndexParam = "page";
|
|
@@ -3139,6 +3182,41 @@ var BaseSignalServiceClass = class BaseSignalServiceClass {
|
|
|
3139
3182
|
}
|
|
3140
3183
|
});
|
|
3141
3184
|
}
|
|
3185
|
+
getObjectsByFilterPaging(pageIndex, pageSize, sortColumn, direction, filters) {
|
|
3186
|
+
return httpResource(() => {
|
|
3187
|
+
this._refreshTrigger();
|
|
3188
|
+
const queryParams = { ...cleanFilterParams(filters) };
|
|
3189
|
+
if (pageIndex + 1) queryParams[this.pageIndexParam] = pageIndex + 1;
|
|
3190
|
+
if (pageSize) queryParams[this.pageSizeParam] = pageSize;
|
|
3191
|
+
if (sortColumn) queryParams[this.sortColumnParam] = sortColumn;
|
|
3192
|
+
if (direction) queryParams[this.directionParam] = direction;
|
|
3193
|
+
return {
|
|
3194
|
+
url: this.baseRoute,
|
|
3195
|
+
params: queryParams
|
|
3196
|
+
};
|
|
3197
|
+
}, {
|
|
3198
|
+
...this.getHttpContext(),
|
|
3199
|
+
defaultValue: [],
|
|
3200
|
+
parse: (data) => {
|
|
3201
|
+
if (!data) return [];
|
|
3202
|
+
return z.array(this.schema).parse(data);
|
|
3203
|
+
}
|
|
3204
|
+
});
|
|
3205
|
+
}
|
|
3206
|
+
getObjectsCountByFilter(filters) {
|
|
3207
|
+
return httpResource(() => {
|
|
3208
|
+
this._refreshTrigger();
|
|
3209
|
+
const cleanFields = cleanFilterParams(filters);
|
|
3210
|
+
return {
|
|
3211
|
+
url: `${this.baseRoute}${this.countRoute}`,
|
|
3212
|
+
params: { ...cleanFields }
|
|
3213
|
+
};
|
|
3214
|
+
}, {
|
|
3215
|
+
...this.getHttpContext(),
|
|
3216
|
+
defaultValue: 0,
|
|
3217
|
+
parse: (data) => z.coerce.number().parse(data)
|
|
3218
|
+
});
|
|
3219
|
+
}
|
|
3142
3220
|
newObject(entity) {
|
|
3143
3221
|
return this.http.post(this.baseRoute, entity, this.getHttpContext());
|
|
3144
3222
|
}
|