@kuzntsv/uikit 1.0.35 → 1.0.37
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,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
2
|
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Directive, ElementRef, HostListener, Injectable, InjectionToken, NgZone, Pipe, computed, effect, inject, input, linkedSignal, makeEnvironmentProviders, output, signal, viewChild } from "@angular/core";
|
|
3
3
|
import { Router, RouterLink } from "@angular/router";
|
|
4
|
-
import { ReplaySubject, Subject, Subscription, filter, finalize, forkJoin, map, of, startWith,
|
|
4
|
+
import { ReplaySubject, Subject, Subscription, filter, finalize, forkJoin, map, of, startWith, take } from "rxjs";
|
|
5
5
|
import { API_NAME, AuthService, HIDE_ROLE_MARKER, NotificationService, RoleService, UIKIT_NOTIFICATION_TOKEN } from "@kuzntsv/uikit";
|
|
6
6
|
import * as i1$1 from "@angular/forms";
|
|
7
7
|
import { FormControl, FormGroup, FormsModule, NgControl, ReactiveFormsModule, Validators } from "@angular/forms";
|
|
@@ -28,6 +28,7 @@ import { MatTooltip, MatTooltipModule } from "@angular/material/tooltip";
|
|
|
28
28
|
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
|
+
import { rxResource } from "@angular/core/rxjs-interop";
|
|
31
32
|
import { DomSanitizer } from "@angular/platform-browser";
|
|
32
33
|
import { MatProgressSpinner } from "@angular/material/progress-spinner";
|
|
33
34
|
import * as i3 from "@angular/cdk/scrolling";
|
|
@@ -2087,10 +2088,11 @@ var EntityAction;
|
|
|
2087
2088
|
EntityAction["Delete"] = "Удаление";
|
|
2088
2089
|
})(EntityAction || (EntityAction = {}));
|
|
2089
2090
|
var BaseFilterClass = class BaseFilterClass {
|
|
2090
|
-
localStorageService = inject(LocalStorageService);
|
|
2091
2091
|
loaderService = inject(LoaderService);
|
|
2092
2092
|
notificationService = inject(NotificationService);
|
|
2093
2093
|
defaultDebounceTime = 500;
|
|
2094
|
+
filters = input({}, ...ngDevMode ? [{ debugName: "filters" }] : /* istanbul ignore next */ []);
|
|
2095
|
+
clearFilters = input(null, ...ngDevMode ? [{ debugName: "clearFilters" }] : /* istanbul ignore next */ []);
|
|
2094
2096
|
subscription = new Subscription();
|
|
2095
2097
|
constructor() {}
|
|
2096
2098
|
ngOnDestroy() {
|
|
@@ -2105,10 +2107,26 @@ var BaseFilterClass = class BaseFilterClass {
|
|
|
2105
2107
|
target: i0.ɵɵFactoryTarget.Directive
|
|
2106
2108
|
});
|
|
2107
2109
|
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
2108
|
-
minVersion: "
|
|
2110
|
+
minVersion: "17.1.0",
|
|
2109
2111
|
version: "22.2.2",
|
|
2110
2112
|
type: BaseFilterClass,
|
|
2111
2113
|
isStandalone: true,
|
|
2114
|
+
inputs: {
|
|
2115
|
+
filters: {
|
|
2116
|
+
classPropertyName: "filters",
|
|
2117
|
+
publicName: "filters",
|
|
2118
|
+
isSignal: true,
|
|
2119
|
+
isRequired: false,
|
|
2120
|
+
transformFunction: null
|
|
2121
|
+
},
|
|
2122
|
+
clearFilters: {
|
|
2123
|
+
classPropertyName: "clearFilters",
|
|
2124
|
+
publicName: "clearFilters",
|
|
2125
|
+
isSignal: true,
|
|
2126
|
+
isRequired: false,
|
|
2127
|
+
transformFunction: null
|
|
2128
|
+
}
|
|
2129
|
+
},
|
|
2112
2130
|
ngImport: i0
|
|
2113
2131
|
});
|
|
2114
2132
|
};
|
|
@@ -2118,7 +2136,25 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
2118
2136
|
ngImport: i0,
|
|
2119
2137
|
type: BaseFilterClass,
|
|
2120
2138
|
decorators: [{ type: Directive }],
|
|
2121
|
-
ctorParameters: () => []
|
|
2139
|
+
ctorParameters: () => [],
|
|
2140
|
+
propDecorators: {
|
|
2141
|
+
filters: [{
|
|
2142
|
+
type: i0.Input,
|
|
2143
|
+
args: [{
|
|
2144
|
+
isSignal: true,
|
|
2145
|
+
alias: "filters",
|
|
2146
|
+
required: false
|
|
2147
|
+
}]
|
|
2148
|
+
}],
|
|
2149
|
+
clearFilters: [{
|
|
2150
|
+
type: i0.Input,
|
|
2151
|
+
args: [{
|
|
2152
|
+
isSignal: true,
|
|
2153
|
+
alias: "clearFilters",
|
|
2154
|
+
required: false
|
|
2155
|
+
}]
|
|
2156
|
+
}]
|
|
2157
|
+
}
|
|
2122
2158
|
});
|
|
2123
2159
|
var BaseNavBarMenuClass = class BaseNavBarMenuClass {
|
|
2124
2160
|
roleService = inject(RoleService);
|
|
@@ -2202,8 +2238,6 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
2202
2238
|
});
|
|
2203
2239
|
var BasePageClass = class BasePageClass {
|
|
2204
2240
|
dialog = inject(MatDialog);
|
|
2205
|
-
data = signal([], ...ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []);
|
|
2206
|
-
length = signal(0, ...ngDevMode ? [{ debugName: "length" }] : /* istanbul ignore next */ []);
|
|
2207
2241
|
entityService;
|
|
2208
2242
|
entityType;
|
|
2209
2243
|
entityEditComponent;
|
|
@@ -2226,11 +2260,46 @@ var BasePageClass = class BasePageClass {
|
|
|
2226
2260
|
hideRoles = [HIDE_ROLE_MARKER];
|
|
2227
2261
|
loadData$ = new Subject();
|
|
2228
2262
|
loadLength$ = new Subject();
|
|
2229
|
-
|
|
2230
|
-
clearFilter = null;
|
|
2263
|
+
clearFilters = signal(null, ...ngDevMode ? [{ debugName: "clearFilters" }] : /* istanbul ignore next */ []);
|
|
2231
2264
|
allowMultiSelect = false;
|
|
2232
2265
|
selected = [];
|
|
2233
|
-
|
|
2266
|
+
fnGetData = signal(null, ...ngDevMode ? [{ debugName: "fnGetData" }] : /* istanbul ignore next */ []);
|
|
2267
|
+
fnGetCount = signal(null, ...ngDevMode ? [{ debugName: "fnGetCount" }] : /* istanbul ignore next */ []);
|
|
2268
|
+
fnMapEntity = signal(void 0, ...ngDevMode ? [{ debugName: "fnMapEntity" }] : /* istanbul ignore next */ []);
|
|
2269
|
+
dataResource = rxResource({
|
|
2270
|
+
params: () => {
|
|
2271
|
+
const fetchFn = this.fnGetData();
|
|
2272
|
+
if (!fetchFn) return null;
|
|
2273
|
+
return {
|
|
2274
|
+
fetchFn,
|
|
2275
|
+
state: this.tableState(),
|
|
2276
|
+
mapFn: this.fnMapEntity()
|
|
2277
|
+
};
|
|
2278
|
+
},
|
|
2279
|
+
stream: ({ params, abortSignal }) => {
|
|
2280
|
+
if (!params) return of([]);
|
|
2281
|
+
this.loaderService.show();
|
|
2282
|
+
return params.fetchFn().pipe(map((v) => params.mapFn && Array.isArray(v) ? v.map(params.mapFn()) : v), finalize(() => {
|
|
2283
|
+
this.loaderService.hide();
|
|
2284
|
+
}));
|
|
2285
|
+
}
|
|
2286
|
+
});
|
|
2287
|
+
countResource = rxResource({
|
|
2288
|
+
params: () => {
|
|
2289
|
+
const fetchCountFn = this.fnGetCount();
|
|
2290
|
+
if (!fetchCountFn) return null;
|
|
2291
|
+
return {
|
|
2292
|
+
fetchCountFn,
|
|
2293
|
+
state: this.tableState()
|
|
2294
|
+
};
|
|
2295
|
+
},
|
|
2296
|
+
stream: ({ params }) => {
|
|
2297
|
+
if (!params) return of(0);
|
|
2298
|
+
return params.fetchCountFn();
|
|
2299
|
+
}
|
|
2300
|
+
});
|
|
2301
|
+
data = computed(() => this.dataResource.value() || [], ...ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []);
|
|
2302
|
+
length = computed(() => this.countResource.value() || 0, ...ngDevMode ? [{ debugName: "length" }] : /* istanbul ignore next */ []);
|
|
2234
2303
|
editBtnDisabled = true;
|
|
2235
2304
|
removeBtnDisabled = true;
|
|
2236
2305
|
dblClickedEventEnable = true;
|
|
@@ -2240,59 +2309,62 @@ var BasePageClass = class BasePageClass {
|
|
|
2240
2309
|
loaderService = inject(LoaderService);
|
|
2241
2310
|
notificationService = inject(UIKIT_NOTIFICATION_TOKEN);
|
|
2242
2311
|
subscription = new Subscription();
|
|
2312
|
+
filters = signal(() => {
|
|
2313
|
+
const saved = this.localStorageService.getData(this.constructor.name + "_Filters");
|
|
2314
|
+
return saved ? JSON.parse(saved) : {};
|
|
2315
|
+
}, ...ngDevMode ? [{ debugName: "filters" }] : /* istanbul ignore next */ []);
|
|
2316
|
+
tableState = signal({
|
|
2317
|
+
sortActive: "",
|
|
2318
|
+
sortDirection: "",
|
|
2319
|
+
pageIndex: this.defaultPageIndex,
|
|
2320
|
+
pageSize: this.defaultPageSize
|
|
2321
|
+
}, ...ngDevMode ? [{ debugName: "tableState" }] : /* istanbul ignore next */ []);
|
|
2243
2322
|
constructor() {
|
|
2244
|
-
this.tableState
|
|
2323
|
+
this.tableState.set({
|
|
2245
2324
|
sortActive: this.localStorageService.getData(this.constructor.name + "SortActive") || "",
|
|
2246
2325
|
sortDirection: this.localStorageService.getData(this.constructor.name + "SortDirection") || "",
|
|
2247
2326
|
pageIndex: Number(this.localStorageService.getData(this.constructor.name + "PageIndex")) || this.defaultPageIndex,
|
|
2248
2327
|
pageSize: Number(this.localStorageService.getData(this.constructor.name + "PageSize")) || this.defaultPageSize
|
|
2249
|
-
};
|
|
2328
|
+
});
|
|
2250
2329
|
}
|
|
2251
2330
|
ngOnDestroy() {
|
|
2252
2331
|
this.subscription.unsubscribe();
|
|
2253
2332
|
}
|
|
2254
2333
|
subscribeToLoadData(fnGetData, fnGetCount, fnMapEntity) {
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2334
|
+
this.fnMapEntity.set(fnMapEntity);
|
|
2335
|
+
this.fnGetData.set(fnGetData);
|
|
2336
|
+
this.fnGetCount.set(fnGetCount);
|
|
2337
|
+
}
|
|
2338
|
+
setFilter(key, value) {
|
|
2339
|
+
this.filters.update((prev) => {
|
|
2340
|
+
const next = { ...prev };
|
|
2341
|
+
if (value === null || value === void 0 || value === "" || value === "-1") delete next[key];
|
|
2342
|
+
else next[key] = value;
|
|
2343
|
+
this.localStorageService.saveData(this.constructor.name + "_Filters", JSON.stringify(next));
|
|
2344
|
+
return next;
|
|
2266
2345
|
});
|
|
2267
|
-
this.
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
},
|
|
2272
|
-
error: (error) => {
|
|
2273
|
-
console.log(error);
|
|
2274
|
-
this.notificationService.error("Произошла ошибка: " + error, 0);
|
|
2275
|
-
}
|
|
2276
|
-
});
|
|
2277
|
-
this.subscription?.add(subs2);
|
|
2278
|
-
this.loadData$.next(null);
|
|
2279
|
-
this.loadLength$.next(null);
|
|
2346
|
+
this.tableState.update((prev) => ({
|
|
2347
|
+
...prev,
|
|
2348
|
+
pageIndex: 0
|
|
2349
|
+
}));
|
|
2280
2350
|
}
|
|
2281
2351
|
onPageChange(pageState) {
|
|
2282
|
-
this.tableState.pageIndex = pageState.pageIndex;
|
|
2283
|
-
this.tableState.pageSize = pageState.pageSize;
|
|
2284
2352
|
this.localStorageService.saveData(this.constructor.name + "PageIndex", pageState.pageIndex.toString());
|
|
2285
2353
|
this.localStorageService.saveData(this.constructor.name + "PageSize", pageState.pageSize.toString());
|
|
2286
|
-
this.
|
|
2287
|
-
|
|
2354
|
+
this.tableState.update((prev) => ({
|
|
2355
|
+
...prev,
|
|
2356
|
+
pageIndex: pageState.pageIndex,
|
|
2357
|
+
pageSize: pageState.pageSize
|
|
2358
|
+
}));
|
|
2288
2359
|
}
|
|
2289
2360
|
onSortChange(sortState) {
|
|
2290
|
-
this.tableState.sortActive = sortState.sortActive;
|
|
2291
|
-
this.tableState.sortDirection = sortState.sortDirection;
|
|
2292
2361
|
this.localStorageService.saveData(this.constructor.name + "SortActive", sortState.sortActive);
|
|
2293
2362
|
this.localStorageService.saveData(this.constructor.name + "SortDirection", sortState.sortDirection);
|
|
2294
|
-
this.
|
|
2295
|
-
|
|
2363
|
+
this.tableState.update((prev) => ({
|
|
2364
|
+
...prev,
|
|
2365
|
+
sortActive: sortState.sortActive,
|
|
2366
|
+
sortDirection: sortState.sortDirection
|
|
2367
|
+
}));
|
|
2296
2368
|
}
|
|
2297
2369
|
entityFactory(type) {
|
|
2298
2370
|
return new type();
|
|
@@ -2421,12 +2493,17 @@ var BasePageClass = class BasePageClass {
|
|
|
2421
2493
|
}
|
|
2422
2494
|
}
|
|
2423
2495
|
refreshEvent() {
|
|
2424
|
-
this.
|
|
2425
|
-
this.
|
|
2496
|
+
this.dataResource.reload();
|
|
2497
|
+
this.countResource.reload();
|
|
2426
2498
|
}
|
|
2427
2499
|
clearEvent() {
|
|
2428
|
-
this.
|
|
2429
|
-
this.
|
|
2500
|
+
this.filters.set({});
|
|
2501
|
+
this.localStorageService.saveData(this.constructor.name + "_Filters", "{}");
|
|
2502
|
+
this.tableState.update((prev) => ({
|
|
2503
|
+
...prev,
|
|
2504
|
+
pageIndex: 0
|
|
2505
|
+
}));
|
|
2506
|
+
this.clearFilters.set({});
|
|
2430
2507
|
}
|
|
2431
2508
|
onRemovalMessageChange(message) {
|
|
2432
2509
|
this.removalMessage = message;
|