@kuzntsv/uikit 1.0.37 → 1.0.38
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,8 +1,8 @@
|
|
|
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, take } from "rxjs";
|
|
5
|
-
import { API_NAME, AuthService,
|
|
4
|
+
import { ReplaySubject, Subject, Subscription, filter, finalize, forkJoin, map, of, startWith, switchMap, take, tap } from "rxjs";
|
|
5
|
+
import { API_NAME, AuthService, 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";
|
|
8
8
|
import { MatAnchor, MatButton, MatIconButton } from "@angular/material/button";
|
|
@@ -28,7 +28,6 @@ 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";
|
|
32
31
|
import { DomSanitizer } from "@angular/platform-browser";
|
|
33
32
|
import { MatProgressSpinner } from "@angular/material/progress-spinner";
|
|
34
33
|
import * as i3 from "@angular/cdk/scrolling";
|
|
@@ -2088,11 +2087,10 @@ var EntityAction;
|
|
|
2088
2087
|
EntityAction["Delete"] = "Удаление";
|
|
2089
2088
|
})(EntityAction || (EntityAction = {}));
|
|
2090
2089
|
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 */ []);
|
|
2096
2094
|
subscription = new Subscription();
|
|
2097
2095
|
constructor() {}
|
|
2098
2096
|
ngOnDestroy() {
|
|
@@ -2107,26 +2105,10 @@ var BaseFilterClass = class BaseFilterClass {
|
|
|
2107
2105
|
target: i0.ɵɵFactoryTarget.Directive
|
|
2108
2106
|
});
|
|
2109
2107
|
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
2110
|
-
minVersion: "
|
|
2108
|
+
minVersion: "14.0.0",
|
|
2111
2109
|
version: "22.2.2",
|
|
2112
2110
|
type: BaseFilterClass,
|
|
2113
2111
|
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
|
-
},
|
|
2130
2112
|
ngImport: i0
|
|
2131
2113
|
});
|
|
2132
2114
|
};
|
|
@@ -2136,25 +2118,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
2136
2118
|
ngImport: i0,
|
|
2137
2119
|
type: BaseFilterClass,
|
|
2138
2120
|
decorators: [{ type: Directive }],
|
|
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
|
-
}
|
|
2121
|
+
ctorParameters: () => []
|
|
2158
2122
|
});
|
|
2159
2123
|
var BaseNavBarMenuClass = class BaseNavBarMenuClass {
|
|
2160
2124
|
roleService = inject(RoleService);
|
|
@@ -2238,6 +2202,8 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
2238
2202
|
});
|
|
2239
2203
|
var BasePageClass = class BasePageClass {
|
|
2240
2204
|
dialog = inject(MatDialog);
|
|
2205
|
+
data = signal([], ...ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []);
|
|
2206
|
+
length = signal(0, ...ngDevMode ? [{ debugName: "length" }] : /* istanbul ignore next */ []);
|
|
2241
2207
|
entityService;
|
|
2242
2208
|
entityType;
|
|
2243
2209
|
entityEditComponent;
|
|
@@ -2257,49 +2223,14 @@ var BasePageClass = class BasePageClass {
|
|
|
2257
2223
|
afterSaveOnEditEvent;
|
|
2258
2224
|
editorRoles = [];
|
|
2259
2225
|
executeRoles = [];
|
|
2260
|
-
hideRoles = [
|
|
2226
|
+
hideRoles = ["HIDE"];
|
|
2261
2227
|
loadData$ = new Subject();
|
|
2262
2228
|
loadLength$ = new Subject();
|
|
2263
|
-
|
|
2229
|
+
clearFilter$ = new Subject();
|
|
2230
|
+
clearFilter = null;
|
|
2264
2231
|
allowMultiSelect = false;
|
|
2265
2232
|
selected = [];
|
|
2266
|
-
|
|
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 */ []);
|
|
2233
|
+
tableState;
|
|
2303
2234
|
editBtnDisabled = true;
|
|
2304
2235
|
removeBtnDisabled = true;
|
|
2305
2236
|
dblClickedEventEnable = true;
|
|
@@ -2307,64 +2238,60 @@ var BasePageClass = class BasePageClass {
|
|
|
2307
2238
|
router = inject(Router);
|
|
2308
2239
|
localStorageService = inject(LocalStorageService);
|
|
2309
2240
|
loaderService = inject(LoaderService);
|
|
2310
|
-
notificationService = inject(
|
|
2241
|
+
notificationService = inject(NotificationService);
|
|
2311
2242
|
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 */ []);
|
|
2322
2243
|
constructor() {
|
|
2323
|
-
this.tableState
|
|
2244
|
+
this.tableState = {
|
|
2324
2245
|
sortActive: this.localStorageService.getData(this.constructor.name + "SortActive") || "",
|
|
2325
2246
|
sortDirection: this.localStorageService.getData(this.constructor.name + "SortDirection") || "",
|
|
2326
2247
|
pageIndex: Number(this.localStorageService.getData(this.constructor.name + "PageIndex")) || this.defaultPageIndex,
|
|
2327
2248
|
pageSize: Number(this.localStorageService.getData(this.constructor.name + "PageSize")) || this.defaultPageSize
|
|
2328
|
-
}
|
|
2249
|
+
};
|
|
2329
2250
|
}
|
|
2330
2251
|
ngOnDestroy() {
|
|
2331
2252
|
this.subscription.unsubscribe();
|
|
2332
2253
|
}
|
|
2333
2254
|
subscribeToLoadData(fnGetData, fnGetCount, fnMapEntity) {
|
|
2334
|
-
this.fnMapEntity.
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
return next;
|
|
2255
|
+
const subs = this.loadData$.pipe(tap(() => this.loaderService.show()), switchMap(() => fnGetData()), map((v) => fnMapEntity ? v.map(fnMapEntity()) : v)).subscribe({
|
|
2256
|
+
next: (response) => {
|
|
2257
|
+
this.data.set(response);
|
|
2258
|
+
this.loaderService.hide();
|
|
2259
|
+
},
|
|
2260
|
+
error: (error) => {
|
|
2261
|
+
this.loaderService.hide();
|
|
2262
|
+
console.log(error);
|
|
2263
|
+
this.notificationService.error("Произошла ошибка: " + error, 0);
|
|
2264
|
+
}
|
|
2345
2265
|
});
|
|
2346
|
-
this.
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2266
|
+
this.subscription?.add(subs);
|
|
2267
|
+
const subs2 = this.loadLength$.pipe(switchMap(() => fnGetCount())).subscribe({
|
|
2268
|
+
next: (response) => {
|
|
2269
|
+
this.length.set(response);
|
|
2270
|
+
},
|
|
2271
|
+
error: (error) => {
|
|
2272
|
+
console.log(error);
|
|
2273
|
+
this.notificationService.error("Произошла ошибка: " + error, 0);
|
|
2274
|
+
}
|
|
2275
|
+
});
|
|
2276
|
+
this.subscription?.add(subs2);
|
|
2277
|
+
this.loadData$.next(null);
|
|
2278
|
+
this.loadLength$.next(null);
|
|
2350
2279
|
}
|
|
2351
2280
|
onPageChange(pageState) {
|
|
2281
|
+
this.tableState.pageIndex = pageState.pageIndex;
|
|
2282
|
+
this.tableState.pageSize = pageState.pageSize;
|
|
2352
2283
|
this.localStorageService.saveData(this.constructor.name + "PageIndex", pageState.pageIndex.toString());
|
|
2353
2284
|
this.localStorageService.saveData(this.constructor.name + "PageSize", pageState.pageSize.toString());
|
|
2354
|
-
this.
|
|
2355
|
-
|
|
2356
|
-
pageIndex: pageState.pageIndex,
|
|
2357
|
-
pageSize: pageState.pageSize
|
|
2358
|
-
}));
|
|
2285
|
+
this.loadData$.next(null);
|
|
2286
|
+
this.loadLength$.next(null);
|
|
2359
2287
|
}
|
|
2360
2288
|
onSortChange(sortState) {
|
|
2289
|
+
this.tableState.sortActive = sortState.sortActive;
|
|
2290
|
+
this.tableState.sortDirection = sortState.sortDirection;
|
|
2361
2291
|
this.localStorageService.saveData(this.constructor.name + "SortActive", sortState.sortActive);
|
|
2362
2292
|
this.localStorageService.saveData(this.constructor.name + "SortDirection", sortState.sortDirection);
|
|
2363
|
-
this.
|
|
2364
|
-
|
|
2365
|
-
sortActive: sortState.sortActive,
|
|
2366
|
-
sortDirection: sortState.sortDirection
|
|
2367
|
-
}));
|
|
2293
|
+
this.loadData$.next(null);
|
|
2294
|
+
this.loadLength$.next(null);
|
|
2368
2295
|
}
|
|
2369
2296
|
entityFactory(type) {
|
|
2370
2297
|
return new type();
|
|
@@ -2404,7 +2331,7 @@ var BasePageClass = class BasePageClass {
|
|
|
2404
2331
|
this.afterSaveOnNewEvent(callback.bind(this), obj, result.extraData);
|
|
2405
2332
|
} else {
|
|
2406
2333
|
this.refreshEvent();
|
|
2407
|
-
this.notificationService
|
|
2334
|
+
this.notificationService.success("Запись добавлена.");
|
|
2408
2335
|
}
|
|
2409
2336
|
},
|
|
2410
2337
|
error: (error) => {
|
|
@@ -2478,7 +2405,7 @@ var BasePageClass = class BasePageClass {
|
|
|
2478
2405
|
},
|
|
2479
2406
|
error: (error) => {
|
|
2480
2407
|
console.log("error", error);
|
|
2481
|
-
this.notificationService
|
|
2408
|
+
this.notificationService.error("Произошла ошибка при удалении записи: " + error, 0);
|
|
2482
2409
|
}
|
|
2483
2410
|
});
|
|
2484
2411
|
this.subscription.add(subs);
|
|
@@ -2493,17 +2420,12 @@ var BasePageClass = class BasePageClass {
|
|
|
2493
2420
|
}
|
|
2494
2421
|
}
|
|
2495
2422
|
refreshEvent() {
|
|
2496
|
-
this.
|
|
2497
|
-
this.
|
|
2423
|
+
this.loadData$.next(null);
|
|
2424
|
+
this.loadLength$.next(null);
|
|
2498
2425
|
}
|
|
2499
2426
|
clearEvent() {
|
|
2500
|
-
this.
|
|
2501
|
-
this.
|
|
2502
|
-
this.tableState.update((prev) => ({
|
|
2503
|
-
...prev,
|
|
2504
|
-
pageIndex: 0
|
|
2505
|
-
}));
|
|
2506
|
-
this.clearFilters.set({});
|
|
2427
|
+
this.clearFilter$.next(null);
|
|
2428
|
+
this.clearFilter = {};
|
|
2507
2429
|
}
|
|
2508
2430
|
onRemovalMessageChange(message) {
|
|
2509
2431
|
this.removalMessage = message;
|
|
@@ -2536,22 +2458,18 @@ var BasePageClass = class BasePageClass {
|
|
|
2536
2458
|
}
|
|
2537
2459
|
onMiddleButton(baseUrl, queryParamName, queryParamValue) {
|
|
2538
2460
|
return ($event, item, contextMenu) => {
|
|
2539
|
-
if (
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
window.open(url, "_blank");
|
|
2544
|
-
}
|
|
2461
|
+
if ($event.button === 1) {
|
|
2462
|
+
contextMenu.closeMenu();
|
|
2463
|
+
const url = this.router.serializeUrl(queryParamName && queryParamValue ? this.router.createUrlTree([baseUrl], { queryParams: { [queryParamName]: item[queryParamValue] } }) : this.router.createUrlTree([baseUrl]));
|
|
2464
|
+
window.open(url, "_blank");
|
|
2545
2465
|
}
|
|
2546
2466
|
};
|
|
2547
2467
|
}
|
|
2548
2468
|
onActionMiddleButton(baseUrl, queryParamName, queryParamValue) {
|
|
2549
2469
|
return ($event, item) => {
|
|
2550
|
-
if (
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
window.open(url, "_blank");
|
|
2554
|
-
}
|
|
2470
|
+
if ($event.button === 1) {
|
|
2471
|
+
const url = this.router.serializeUrl(queryParamName && queryParamValue ? this.router.createUrlTree([baseUrl], { queryParams: { [queryParamName]: item[queryParamValue] } }) : this.router.createUrlTree([baseUrl]));
|
|
2472
|
+
window.open(url, "_blank");
|
|
2555
2473
|
}
|
|
2556
2474
|
};
|
|
2557
2475
|
}
|