@kuzntsv/uikit 1.0.58 → 1.0.60
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) => ({
|
|
@@ -3200,17 +3179,12 @@ var BaseSignalServiceClass = class BaseSignalServiceClass {
|
|
|
3200
3179
|
parse: (data) => z.coerce.number().parse(data)
|
|
3201
3180
|
});
|
|
3202
3181
|
}
|
|
3203
|
-
getObjectsByPaging(
|
|
3182
|
+
getObjectsByPaging(tableState) {
|
|
3204
3183
|
return httpResource(() => {
|
|
3205
3184
|
this._refreshTrigger();
|
|
3206
|
-
const queryParams = {};
|
|
3207
|
-
if (pageIndex + 1) queryParams[this.pageIndexParam] = pageIndex + 1;
|
|
3208
|
-
if (pageSize) queryParams[this.pageSizeParam] = pageSize;
|
|
3209
|
-
if (sortColumn) queryParams[this.sortColumnParam] = sortColumn;
|
|
3210
|
-
if (direction) queryParams[this.directionParam] = direction;
|
|
3211
3185
|
return {
|
|
3212
3186
|
url: this.baseRoute,
|
|
3213
|
-
params:
|
|
3187
|
+
params: this.buildTableParams(tableState)
|
|
3214
3188
|
};
|
|
3215
3189
|
}, {
|
|
3216
3190
|
...this.getHttpContext(),
|
|
@@ -3221,17 +3195,17 @@ var BaseSignalServiceClass = class BaseSignalServiceClass {
|
|
|
3221
3195
|
}
|
|
3222
3196
|
});
|
|
3223
3197
|
}
|
|
3224
|
-
getObjectsByFilterPaging(
|
|
3198
|
+
getObjectsByFilterPaging(tableState, filters) {
|
|
3225
3199
|
return httpResource(() => {
|
|
3226
3200
|
this._refreshTrigger();
|
|
3227
|
-
const
|
|
3228
|
-
|
|
3229
|
-
if (pageSize) queryParams[this.pageSizeParam] = pageSize;
|
|
3230
|
-
if (sortColumn) queryParams[this.sortColumnParam] = sortColumn;
|
|
3231
|
-
if (direction) queryParams[this.directionParam] = direction;
|
|
3201
|
+
const cleanFields = cleanFilterParams(filters);
|
|
3202
|
+
const tableParams = this.buildTableParams(tableState);
|
|
3232
3203
|
return {
|
|
3233
3204
|
url: this.baseRoute,
|
|
3234
|
-
params:
|
|
3205
|
+
params: {
|
|
3206
|
+
...cleanFields,
|
|
3207
|
+
...tableParams
|
|
3208
|
+
}
|
|
3235
3209
|
};
|
|
3236
3210
|
}, {
|
|
3237
3211
|
...this.getHttpContext(),
|
|
@@ -3256,6 +3230,15 @@ var BaseSignalServiceClass = class BaseSignalServiceClass {
|
|
|
3256
3230
|
parse: (data) => z.coerce.number().parse(data)
|
|
3257
3231
|
});
|
|
3258
3232
|
}
|
|
3233
|
+
buildTableParams(tableState) {
|
|
3234
|
+
const queryParams = {};
|
|
3235
|
+
const { pageIndex, pageSize, sortActive, sortDirection } = tableState;
|
|
3236
|
+
if (pageIndex + 1) queryParams[this.pageIndexParam] = pageIndex + 1;
|
|
3237
|
+
if (pageSize) queryParams[this.pageSizeParam] = pageSize;
|
|
3238
|
+
if (sortActive) queryParams[this.sortColumnParam] = sortActive;
|
|
3239
|
+
if (sortDirection) queryParams[this.directionParam] = sortDirection;
|
|
3240
|
+
return queryParams;
|
|
3241
|
+
}
|
|
3259
3242
|
newObject(entity) {
|
|
3260
3243
|
return this.http.post(this.baseRoute, entity, this.getHttpContext());
|
|
3261
3244
|
}
|
|
@@ -4388,6 +4371,16 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
4388
4371
|
}]
|
|
4389
4372
|
}
|
|
4390
4373
|
});
|
|
4374
|
+
const SortDirectionSchema = z.custom((val) => val === "asc" || val === "desc" || val === "", { message: "Допустимы только значения 'asc', 'desc' или ''" });
|
|
4375
|
+
const SortStateSchema = z.object({
|
|
4376
|
+
sortActive: z.string(),
|
|
4377
|
+
sortDirection: SortDirectionSchema
|
|
4378
|
+
});
|
|
4379
|
+
const PageStateSchema = z.object({
|
|
4380
|
+
pageIndex: z.number().int().min(0),
|
|
4381
|
+
pageSize: z.number().int().positive()
|
|
4382
|
+
});
|
|
4383
|
+
const TableStateSchema = SortStateSchema.merge(PageStateSchema);
|
|
4391
4384
|
var TableComponent = class TableComponent {
|
|
4392
4385
|
data = input([], ...ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []);
|
|
4393
4386
|
length = input(0, ...ngDevMode ? [{ debugName: "length" }] : /* istanbul ignore next */ []);
|
|
@@ -5648,6 +5641,6 @@ const secUserSchema = z.object({
|
|
|
5648
5641
|
tabnum: z.number().default(0),
|
|
5649
5642
|
userView: secUserViewSchema.optional()
|
|
5650
5643
|
});
|
|
5651
|
-
export { Action, AvatarService, BaseEditClass, BaseFilterClass, BaseMatChipComponent, BaseNavBarMenuClass, BasePageClass, BaseSchema, BaseSelectAutocompleteWithVsComponent, BaseSelectWithGroupComponent, BaseServiceClass, BaseSignalEditClass, BaseSignalFilterClass, BaseSignalPageClass, BaseSignalServiceClass, BaseToolbarComponent, CustomDateAdapter, DateRangeInputComponent, DialogAction, DialogComponent, DisableIfRoleDirective, EmptyComponent, EntityAction, ExportService, HideIfForbiddenRoleDirective, LOGGER_CONFIG, LoaderService, LocalStorageService, LoggerService, LoginPageComponent, MY_NATIVE_FORMATS, NavBarComponent, NotFoundComponent, ProgressSpinnerComponent, SafePipe, SecureImageService, SetValueDirective, SseService, TableComponent, TimePipe, TruncatePipe, authGuard, dateFormat, provideLogger, redirectGuard, roleGuard, secUserSchema };
|
|
5644
|
+
export { Action, AvatarService, BaseEditClass, BaseFilterClass, BaseMatChipComponent, BaseNavBarMenuClass, BasePageClass, BaseSchema, BaseSelectAutocompleteWithVsComponent, BaseSelectWithGroupComponent, BaseServiceClass, BaseSignalEditClass, BaseSignalFilterClass, BaseSignalPageClass, BaseSignalServiceClass, BaseToolbarComponent, CustomDateAdapter, DateRangeInputComponent, DialogAction, DialogComponent, DisableIfRoleDirective, EmptyComponent, EntityAction, ExportService, HideIfForbiddenRoleDirective, LOGGER_CONFIG, LoaderService, LocalStorageService, LoggerService, LoginPageComponent, MY_NATIVE_FORMATS, NavBarComponent, NotFoundComponent, PageStateSchema, ProgressSpinnerComponent, SafePipe, SecureImageService, SetValueDirective, SortDirectionSchema, SortStateSchema, SseService, TableComponent, TableStateSchema, TimePipe, TruncatePipe, authGuard, dateFormat, provideLogger, redirectGuard, roleGuard, secUserSchema };
|
|
5652
5645
|
|
|
5653
5646
|
//# sourceMappingURL=kuzntsv-uikit-ui.mjs.map
|