@kuzntsv/uikit 1.0.40 → 1.0.43

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.
@@ -2,7 +2,7 @@ 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
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";
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";
8
8
  import { MatAnchor, MatButton, MatIconButton } from "@angular/material/button";
@@ -10,7 +10,7 @@ import { MatCard, MatCardContent, MatCardHeader, MatCardTitle } from "@angular/m
10
10
  import { MatError, MatFormField, MatHint, MatLabel, MatSuffix } from "@angular/material/form-field";
11
11
  import { MatIcon } from "@angular/material/icon";
12
12
  import { MatInput } from "@angular/material/input";
13
- import { HttpClient, HttpContext, HttpParams } from "@angular/common/http";
13
+ import { HttpClient, HttpContext, HttpParams, httpResource } from "@angular/common/http";
14
14
  import { Overlay } from "@angular/cdk/overlay";
15
15
  import { ComponentPortal } from "@angular/cdk/portal";
16
16
  import { COMMA, ENTER } from "@angular/cdk/keycodes";
@@ -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 z, { z as z$1 } from "zod";
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";
@@ -2019,6 +2020,7 @@ i0.ɵɵngDeclareClassMetadata({
2019
2020
  }]
2020
2021
  }
2021
2022
  });
2023
+ const BaseSchema = z$1.object({ id: z$1.number() });
2022
2024
  var Action;
2023
2025
  (function(Action) {
2024
2026
  Action["Add"] = "Добавление";
@@ -2571,6 +2573,634 @@ i0.ɵɵngDeclareClassMetadata({
2571
2573
  args: [{ providedIn: "root" }]
2572
2574
  }]
2573
2575
  });
2576
+ var BaseSignalEditClass = class BaseSignalEditClass {
2577
+ formAction = computed(() => this.dialogData().action, ...ngDevMode ? [{ debugName: "formAction" }] : /* istanbul ignore next */ []);
2578
+ formActionIsAdd = computed(() => this.dialogData().action === Action.Add, ...ngDevMode ? [{ debugName: "formActionIsAdd" }] : /* istanbul ignore next */ []);
2579
+ formActionIsEdit = computed(() => this.dialogData().action === Action.Edit, ...ngDevMode ? [{ debugName: "formActionIsEdit" }] : /* istanbul ignore next */ []);
2580
+ domainModel = computed(() => this.dialogData().entity, ...ngDevMode ? [{ debugName: "domainModel" }] : /* istanbul ignore next */ []);
2581
+ formModel = linkedSignal({
2582
+ ...ngDevMode ? { debugName: "formModel" } : /* istanbul ignore next */ {},
2583
+ source: this.domainModel,
2584
+ computation: (domainModel) => this.domainModelToFormModel(domainModel)
2585
+ });
2586
+ loaderService = inject(LoaderService);
2587
+ notificationService = inject(NotificationService);
2588
+ subscription = new Subscription();
2589
+ domainModelToFormModel(domainModel) {
2590
+ return { ...domainModel };
2591
+ }
2592
+ formModelToDomainModel(formModel, originalDomain) {
2593
+ return {
2594
+ ...originalDomain,
2595
+ ...formModel
2596
+ };
2597
+ }
2598
+ ngOnDestroy() {
2599
+ this.subscription.unsubscribe();
2600
+ }
2601
+ onNoClick(event) {
2602
+ this.dialogRef?.close(null);
2603
+ event.preventDefault();
2604
+ }
2605
+ onSubmit() {
2606
+ if (this.form().valid()) {
2607
+ const updatedDomainEntity = this.formModelToDomainModel(this.formModel());
2608
+ this.dialogData.update((currentData) => ({
2609
+ ...currentData,
2610
+ entity: updatedDomainEntity
2611
+ }));
2612
+ this.dialogRef?.close(this.dialogData());
2613
+ } else this.form().markAsTouched();
2614
+ }
2615
+ static ɵfac = i0.ɵɵngDeclareFactory({
2616
+ minVersion: "12.0.0",
2617
+ version: "22.2.2",
2618
+ ngImport: i0,
2619
+ type: BaseSignalEditClass,
2620
+ deps: [],
2621
+ target: i0.ɵɵFactoryTarget.Directive
2622
+ });
2623
+ static ɵdir = i0.ɵɵngDeclareDirective({
2624
+ minVersion: "14.0.0",
2625
+ version: "22.2.2",
2626
+ type: BaseSignalEditClass,
2627
+ isStandalone: true,
2628
+ ngImport: i0
2629
+ });
2630
+ };
2631
+ i0.ɵɵngDeclareClassMetadata({
2632
+ minVersion: "12.0.0",
2633
+ version: "22.2.2",
2634
+ ngImport: i0,
2635
+ type: BaseSignalEditClass,
2636
+ decorators: [{ type: Directive }]
2637
+ });
2638
+ var BaseSignalFilterClass = class BaseSignalFilterClass {
2639
+ loaderService = inject(LoaderService);
2640
+ notificationService = inject(NotificationService);
2641
+ defaultDebounceTime = 500;
2642
+ initialValues = input({}, ...ngDevMode ? [{ debugName: "initialValues" }] : /* istanbul ignore next */ []);
2643
+ clearFilter = input(null, ...ngDevMode ? [{ debugName: "clearFilter" }] : /* istanbul ignore next */ []);
2644
+ filterChange = output();
2645
+ filter = linkedSignal(() => this.initialValues(), ...ngDevMode ? [{ debugName: "filter" }] : /* istanbul ignore next */ []);
2646
+ subscription = new Subscription();
2647
+ ngOnDestroy() {
2648
+ this.subscription.unsubscribe();
2649
+ }
2650
+ static ɵfac = i0.ɵɵngDeclareFactory({
2651
+ minVersion: "12.0.0",
2652
+ version: "22.2.2",
2653
+ ngImport: i0,
2654
+ type: BaseSignalFilterClass,
2655
+ deps: [],
2656
+ target: i0.ɵɵFactoryTarget.Directive
2657
+ });
2658
+ static ɵdir = i0.ɵɵngDeclareDirective({
2659
+ minVersion: "17.1.0",
2660
+ version: "22.2.2",
2661
+ type: BaseSignalFilterClass,
2662
+ isStandalone: true,
2663
+ inputs: {
2664
+ initialValues: {
2665
+ classPropertyName: "initialValues",
2666
+ publicName: "initialValues",
2667
+ isSignal: true,
2668
+ isRequired: false,
2669
+ transformFunction: null
2670
+ },
2671
+ clearFilter: {
2672
+ classPropertyName: "clearFilter",
2673
+ publicName: "clearFilter",
2674
+ isSignal: true,
2675
+ isRequired: false,
2676
+ transformFunction: null
2677
+ }
2678
+ },
2679
+ outputs: { filterChange: "filterChange" },
2680
+ ngImport: i0
2681
+ });
2682
+ };
2683
+ i0.ɵɵngDeclareClassMetadata({
2684
+ minVersion: "12.0.0",
2685
+ version: "22.2.2",
2686
+ ngImport: i0,
2687
+ type: BaseSignalFilterClass,
2688
+ decorators: [{ type: Directive }],
2689
+ propDecorators: {
2690
+ initialValues: [{
2691
+ type: i0.Input,
2692
+ args: [{
2693
+ isSignal: true,
2694
+ alias: "initialValues",
2695
+ required: false
2696
+ }]
2697
+ }],
2698
+ clearFilter: [{
2699
+ type: i0.Input,
2700
+ args: [{
2701
+ isSignal: true,
2702
+ alias: "clearFilter",
2703
+ required: false
2704
+ }]
2705
+ }],
2706
+ filterChange: [{
2707
+ type: i0.Output,
2708
+ args: ["filterChange"]
2709
+ }]
2710
+ }
2711
+ });
2712
+ var BaseSignalPageClass = class BaseSignalPageClass {
2713
+ dialog = inject(MatDialog);
2714
+ entityService;
2715
+ entityType;
2716
+ entityEditComponent;
2717
+ extraData;
2718
+ defaultPageIndex = 0;
2719
+ defaultPageSize = 10;
2720
+ dialogEditWidth = "auto";
2721
+ dialogRemoveWidth = "400px";
2722
+ routeAddress = "";
2723
+ removalMessage = "";
2724
+ pageTitle = "";
2725
+ beforeOpenDialogOnNewEvent;
2726
+ beforeOpenDialogOnEditEvent;
2727
+ beforeSaveOnNewEvent;
2728
+ beforeSaveOnEditEvent;
2729
+ afterSaveOnNewEvent;
2730
+ afterSaveOnEditEvent;
2731
+ editorRoles = [];
2732
+ executeRoles = [];
2733
+ hideRoles = [HIDE_ROLE_MARKER];
2734
+ clearFilters = signal(null, ...ngDevMode ? [{ debugName: "clearFilters" }] : /* istanbul ignore next */ []);
2735
+ allowMultiSelect = false;
2736
+ selected = [];
2737
+ fnGetData = signal(null, ...ngDevMode ? [{ debugName: "fnGetData" }] : /* istanbul ignore next */ []);
2738
+ fnGetCount = signal(null, ...ngDevMode ? [{ debugName: "fnGetCount" }] : /* istanbul ignore next */ []);
2739
+ fnMapEntity = signal(void 0, ...ngDevMode ? [{ debugName: "fnMapEntity" }] : /* istanbul ignore next */ []);
2740
+ dataResource = computed(() => {
2741
+ const fetchFn = this.fnGetData();
2742
+ if (!fetchFn) return null;
2743
+ this.tableState();
2744
+ this.filters();
2745
+ return fetchFn();
2746
+ }, ...ngDevMode ? [{ debugName: "dataResource" }] : /* istanbul ignore next */ []);
2747
+ countResource = computed(() => {
2748
+ const fetchCountFn = this.fnGetCount();
2749
+ if (!fetchCountFn) return null;
2750
+ this.filters();
2751
+ return fetchCountFn();
2752
+ }, ...ngDevMode ? [{ debugName: "countResource" }] : /* istanbul ignore next */ []);
2753
+ data = computed(() => {
2754
+ const rawData = this.dataResource()?.value() || [];
2755
+ const mapFn = this.fnMapEntity();
2756
+ if (mapFn && Array.isArray(rawData)) return rawData.map(mapFn());
2757
+ return rawData;
2758
+ }, ...ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []);
2759
+ length = computed(() => this.countResource()?.value() || 0, ...ngDevMode ? [{ debugName: "length" }] : /* istanbul ignore next */ []);
2760
+ isLoading = computed(() => {
2761
+ const dataLoading = this.dataResource()?.isLoading() ?? false;
2762
+ const countLoading = this.countResource()?.isLoading() ?? false;
2763
+ return dataLoading || countLoading;
2764
+ }, ...ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []);
2765
+ editBtnDisabled = true;
2766
+ removeBtnDisabled = true;
2767
+ dblClickedEventEnable = true;
2768
+ opt = [];
2769
+ router = inject(Router);
2770
+ localStorageService = inject(LocalStorageService);
2771
+ loaderService = inject(LoaderService);
2772
+ notificationService = inject(UIKIT_NOTIFICATION_TOKEN);
2773
+ subscription = new Subscription();
2774
+ getInitialFilters() {
2775
+ const saved = this.localStorageService.getData(this.constructor.name + "_Filters");
2776
+ return saved ? JSON.parse(saved) : {};
2777
+ }
2778
+ getInitialFilters2() {
2779
+ const prefix = this.constructor.name + "_Filter_";
2780
+ const state = {};
2781
+ for (let i = 0; i < localStorage.length; i++) {
2782
+ const key = localStorage.key(i);
2783
+ if (key && key.startsWith(prefix)) {
2784
+ const filterKey = key.replace(prefix, "");
2785
+ const rawValue = this.localStorageService.getData(key);
2786
+ try {
2787
+ state[filterKey] = rawValue ? JSON.parse(rawValue) : rawValue;
2788
+ } catch {
2789
+ state[filterKey] = rawValue;
2790
+ }
2791
+ }
2792
+ }
2793
+ return state;
2794
+ }
2795
+ filters = signal(this.getInitialFilters(), ...ngDevMode ? [{ debugName: "filters" }] : /* istanbul ignore next */ []);
2796
+ filters2 = signal(this.getInitialFilters2(), ...ngDevMode ? [{ debugName: "filters2" }] : /* istanbul ignore next */ []);
2797
+ tableState = signal({
2798
+ sortActive: "",
2799
+ sortDirection: "",
2800
+ pageIndex: this.defaultPageIndex,
2801
+ pageSize: this.defaultPageSize
2802
+ }, ...ngDevMode ? [{ debugName: "tableState" }] : /* istanbul ignore next */ []);
2803
+ constructor() {
2804
+ this.tableState.set({
2805
+ sortActive: this.localStorageService.getData(this.constructor.name + "SortActive") || "",
2806
+ sortDirection: this.localStorageService.getData(this.constructor.name + "SortDirection") || "",
2807
+ pageIndex: Number(this.localStorageService.getData(this.constructor.name + "PageIndex")) || this.defaultPageIndex,
2808
+ pageSize: Number(this.localStorageService.getData(this.constructor.name + "PageSize")) || this.defaultPageSize
2809
+ });
2810
+ effect(() => {
2811
+ if (this.isLoading()) this.loaderService.show();
2812
+ else this.loaderService.hide();
2813
+ });
2814
+ }
2815
+ ngOnDestroy() {
2816
+ this.subscription.unsubscribe();
2817
+ }
2818
+ subscribeToLoadData(fnGetData, fnGetCount, fnMapEntity) {
2819
+ this.fnMapEntity.set(fnMapEntity);
2820
+ this.fnGetData.set(fnGetData);
2821
+ this.fnGetCount.set(fnGetCount);
2822
+ }
2823
+ setFilter(key, value) {
2824
+ const storageKey = `${this.constructor.name}_Filter_${key}`;
2825
+ this.tableState.update((prev) => ({
2826
+ ...prev,
2827
+ pageIndex: 0
2828
+ }));
2829
+ this.filters.update((prev) => {
2830
+ const next = { ...prev };
2831
+ if (value === null || value === void 0 || value === "" || value === "-1") {
2832
+ delete next[key];
2833
+ localStorage.removeItem(storageKey);
2834
+ } else {
2835
+ next[key] = value;
2836
+ this.localStorageService.saveData(storageKey, JSON.stringify(value));
2837
+ }
2838
+ return next;
2839
+ });
2840
+ }
2841
+ onPageChange(pageState) {
2842
+ this.localStorageService.saveData(this.constructor.name + "PageIndex", pageState.pageIndex.toString());
2843
+ this.localStorageService.saveData(this.constructor.name + "PageSize", pageState.pageSize.toString());
2844
+ this.tableState.update((prev) => ({
2845
+ ...prev,
2846
+ pageIndex: pageState.pageIndex,
2847
+ pageSize: pageState.pageSize
2848
+ }));
2849
+ }
2850
+ onSortChange(sortState) {
2851
+ this.localStorageService.saveData(this.constructor.name + "SortActive", sortState.sortActive);
2852
+ this.localStorageService.saveData(this.constructor.name + "SortDirection", sortState.sortDirection);
2853
+ this.tableState.update((prev) => ({
2854
+ ...prev,
2855
+ sortActive: sortState.sortActive,
2856
+ sortDirection: sortState.sortDirection
2857
+ }));
2858
+ }
2859
+ entityFactory(type) {
2860
+ return new type();
2861
+ }
2862
+ onSelectionChange(selected) {
2863
+ this.selected = selected;
2864
+ this.editBtnDisabledUpdate(this.selected);
2865
+ this.removeBtnDisabledUpdate(this.selected);
2866
+ }
2867
+ editBtnDisabledUpdate(selected) {
2868
+ this.editBtnDisabled = !(selected && selected.length === 1);
2869
+ }
2870
+ removeBtnDisabledUpdate(selected) {
2871
+ this.removeBtnDisabled = !(selected && selected.length > 0);
2872
+ }
2873
+ onRowDoubleClicked() {
2874
+ this.editEvent();
2875
+ }
2876
+ newEvent() {
2877
+ if (this.entityEditComponent) {
2878
+ const data = {
2879
+ action: Action.Add,
2880
+ entity: new this.entityType(null)
2881
+ };
2882
+ if (this.beforeOpenDialogOnNewEvent) this.beforeOpenDialogOnNewEvent(data.entity, data.extraData);
2883
+ const dialogRef = this.openDialog(this.entityEditComponent, data, this.dialog);
2884
+ const subs = dialogRef.afterClosed().subscribe((result) => {
2885
+ if (result && result.entity && Object.keys(result.entity).length !== 0) {
2886
+ if (this.beforeSaveOnNewEvent) this.beforeSaveOnNewEvent(result.entity, result.extraData);
2887
+ const subs = this.entityService.newObject(result.entity).subscribe({
2888
+ next: (obj) => {
2889
+ if (this.afterSaveOnNewEvent) {
2890
+ const callback = () => {
2891
+ this.refreshEvent();
2892
+ this.notificationService.success("Запись добавлена.");
2893
+ };
2894
+ this.afterSaveOnNewEvent(callback.bind(this), obj, result.extraData);
2895
+ } else {
2896
+ this.refreshEvent();
2897
+ this.notificationService?.success("Запись добавлена.");
2898
+ }
2899
+ },
2900
+ error: (error) => {
2901
+ console.log("error", error);
2902
+ this.notificationService.error("Произошла ошибка при добавлении записи: " + error, 0);
2903
+ }
2904
+ });
2905
+ this.subscription.add(subs);
2906
+ }
2907
+ });
2908
+ this.subscription.add(subs);
2909
+ const subs2 = dialogRef.keydownEvents().subscribe((event) => {
2910
+ if (event.key === "Escape") dialogRef.close(null);
2911
+ });
2912
+ this.subscription.add(subs2);
2913
+ } else this.notificationService.warning("Действие не доступно.");
2914
+ }
2915
+ editEvent() {
2916
+ if (this.selected && this.selected.length === 1) {
2917
+ if (this.entityEditComponent) {
2918
+ const data = {
2919
+ action: Action.Edit,
2920
+ entity: this.selected[0]
2921
+ };
2922
+ if (this.beforeOpenDialogOnEditEvent) this.beforeOpenDialogOnEditEvent(data.entity, data.extraData);
2923
+ const dialogRef = this.openDialog(this.entityEditComponent, data, this.dialog);
2924
+ const subs = dialogRef.afterClosed().subscribe((result) => {
2925
+ if (result && result.entity && Object.keys(result.entity).length !== 0) {
2926
+ if (this.beforeSaveOnEditEvent) this.beforeSaveOnEditEvent(result.entity, result.extraData);
2927
+ const subs = this.entityService.editObject(result.entity).subscribe({
2928
+ next: () => {
2929
+ if (this.afterSaveOnEditEvent) {
2930
+ const callback = () => {
2931
+ this.refreshEvent();
2932
+ this.notificationService.success("Запись изменена.");
2933
+ };
2934
+ this.afterSaveOnEditEvent(callback.bind(this), result.entity, result.extraData);
2935
+ } else {
2936
+ this.refreshEvent();
2937
+ this.notificationService.success("Запись изменена.");
2938
+ }
2939
+ },
2940
+ error: (error) => {
2941
+ console.log("error", error);
2942
+ this.notificationService.error("Произошла ошибка при изменении записи: " + error, 0);
2943
+ }
2944
+ });
2945
+ this.subscription.add(subs);
2946
+ }
2947
+ });
2948
+ this.subscription.add(subs);
2949
+ const subs2 = dialogRef.keydownEvents().subscribe((event) => {
2950
+ if (event.key === "Escape") dialogRef.close(null);
2951
+ });
2952
+ this.subscription.add(subs2);
2953
+ } else this.notificationService.warning("Действие не доступно.");
2954
+ }
2955
+ }
2956
+ removeEvent() {
2957
+ if (this.selected && this.selected.length > 0) {
2958
+ const dialogRef = this.openDialogRemoveConfirm(this.removalMessage);
2959
+ if (dialogRef) {
2960
+ const subs = dialogRef.afterClosed().subscribe((result) => {
2961
+ if (result === "delete") {
2962
+ const sourcesObject = {};
2963
+ this.selected.forEach((item, index) => sourcesObject["obj" + index] = this.entityService.deleteObject(item));
2964
+ const subs = forkJoin(sourcesObject).subscribe({
2965
+ next: () => {
2966
+ this.refreshEvent();
2967
+ this.notificationService.success("Выбранные записи удалены.");
2968
+ },
2969
+ error: (error) => {
2970
+ console.log("error", error);
2971
+ this.notificationService?.error("Произошла ошибка при удалении записи: " + error, 0);
2972
+ }
2973
+ });
2974
+ this.subscription.add(subs);
2975
+ }
2976
+ });
2977
+ this.subscription.add(subs);
2978
+ const subs2 = dialogRef.keydownEvents().subscribe((event) => {
2979
+ if (event.key === "Escape") dialogRef.close(null);
2980
+ });
2981
+ this.subscription.add(subs2);
2982
+ }
2983
+ }
2984
+ }
2985
+ refreshEvent() {
2986
+ this.dataResource()?.reload();
2987
+ this.countResource()?.reload();
2988
+ }
2989
+ clearEvent() {
2990
+ const prefix = this.constructor.name + "_Filter_";
2991
+ const keysToRemove = [];
2992
+ for (let i = 0; i < localStorage.length; i++) {
2993
+ const key = localStorage.key(i);
2994
+ if (key && key.startsWith(prefix)) keysToRemove.push(key);
2995
+ }
2996
+ keysToRemove.forEach((key) => localStorage.removeItem(key));
2997
+ this.filters.set({});
2998
+ this.tableState.update((prev) => ({
2999
+ ...prev,
3000
+ pageIndex: 0
3001
+ }));
3002
+ this.clearFilters.set({});
3003
+ }
3004
+ onRemovalMessageChange(message) {
3005
+ this.removalMessage = message;
3006
+ }
3007
+ onPageTitleChange(title) {
3008
+ this.pageTitle = title;
3009
+ }
3010
+ openDialog(entityComponent, data, dialog) {
3011
+ const dialogConfig = new MatDialogConfig();
3012
+ dialogConfig.disableClose = true;
3013
+ dialogConfig.autoFocus = true;
3014
+ dialogConfig.width = this.dialogEditWidth;
3015
+ dialogConfig.data = data;
3016
+ dialogConfig.panelClass = this.entityType.name + "-edit-dialog";
3017
+ return dialog.open(entityComponent, dialogConfig);
3018
+ }
3019
+ openDialogRemoveConfirm(removalMessage) {
3020
+ let message = "Вы хотите удалить ";
3021
+ message += removalMessage ? removalMessage : this.allowMultiSelect ? `выбранные записи (${this.selected.length})?` : "выбранную запись?";
3022
+ return this.dialog.open(DialogComponent, {
3023
+ width: this.dialogRemoveWidth,
3024
+ data: {
3025
+ id: "delete",
3026
+ title: "Подтверждение",
3027
+ message,
3028
+ btnNoTitle: "Отмена",
3029
+ btnYesTitle: "Удалить"
3030
+ }
3031
+ });
3032
+ }
3033
+ onMiddleButton(baseUrl, queryParamName, queryParamValue) {
3034
+ return ($event, item, contextMenu) => {
3035
+ if ($event.button === 1 && item) {
3036
+ contextMenu.closeMenu();
3037
+ const url = this.router.serializeUrl(queryParamName && queryParamValue ? this.router.createUrlTree([baseUrl], { queryParams: { [queryParamName]: item[queryParamValue] } }) : this.router.createUrlTree([baseUrl]));
3038
+ window.open(url, "_blank");
3039
+ }
3040
+ };
3041
+ }
3042
+ onActionMiddleButton(baseUrl, queryParamName, queryParamValue) {
3043
+ return ($event, item) => {
3044
+ if ($event.button === 1 && item) {
3045
+ const url = this.router.serializeUrl(queryParamName && queryParamValue ? this.router.createUrlTree([baseUrl], { queryParams: { [queryParamName]: item[queryParamValue] } }) : this.router.createUrlTree([baseUrl]));
3046
+ window.open(url, "_blank");
3047
+ }
3048
+ };
3049
+ }
3050
+ dateToString(date) {
3051
+ return date ? new Date(date).toLocaleString("ru-RU", { timeZone: "Europe/Samara" }) : null;
3052
+ }
3053
+ static ɵfac = i0.ɵɵngDeclareFactory({
3054
+ minVersion: "12.0.0",
3055
+ version: "22.2.2",
3056
+ ngImport: i0,
3057
+ type: BaseSignalPageClass,
3058
+ deps: [],
3059
+ target: i0.ɵɵFactoryTarget.Directive
3060
+ });
3061
+ static ɵdir = i0.ɵɵngDeclareDirective({
3062
+ minVersion: "14.0.0",
3063
+ version: "22.2.2",
3064
+ type: BaseSignalPageClass,
3065
+ isStandalone: true,
3066
+ ngImport: i0
3067
+ });
3068
+ };
3069
+ i0.ɵɵngDeclareClassMetadata({
3070
+ minVersion: "12.0.0",
3071
+ version: "22.2.2",
3072
+ ngImport: i0,
3073
+ type: BaseSignalPageClass,
3074
+ decorators: [{ type: Directive }],
3075
+ ctorParameters: () => []
3076
+ });
3077
+ var BaseSignalServiceClass = class BaseSignalServiceClass {
3078
+ countRoute = "count";
3079
+ pageIndexParam = "page";
3080
+ pageSizeParam = "limit";
3081
+ sortColumnParam = "column";
3082
+ directionParam = "direction";
3083
+ apiContextName = "";
3084
+ http = inject(HttpClient);
3085
+ _refreshTrigger = signal(0, ...ngDevMode ? [{ debugName: "_refreshTrigger" }] : /* istanbul ignore next */ []);
3086
+ refresh() {
3087
+ this._refreshTrigger.update((v) => v + 1);
3088
+ }
3089
+ getObjects() {
3090
+ return httpResource(() => {
3091
+ this._refreshTrigger();
3092
+ return { url: this.baseRoute };
3093
+ }, {
3094
+ ...this.getHttpContext(),
3095
+ parse: (data) => {
3096
+ if (!data) return [];
3097
+ return z.array(this.schema).parse(data);
3098
+ }
3099
+ });
3100
+ }
3101
+ getObject(id) {
3102
+ const idSignal = typeof id === "function" ? id : () => id;
3103
+ return httpResource(() => {
3104
+ this._refreshTrigger();
3105
+ return { url: `${this.baseRoute}${idSignal()}` };
3106
+ }, {
3107
+ ...this.getHttpContext(),
3108
+ parse: (data) => data ? new this.entityType(data).deserialize(data) : null
3109
+ });
3110
+ }
3111
+ getCount() {
3112
+ return httpResource(() => {
3113
+ this._refreshTrigger();
3114
+ return { url: `${this.baseRoute}${this.countRoute}` };
3115
+ }, {
3116
+ ...this.getHttpContext(),
3117
+ parse: (data) => Number(data)
3118
+ });
3119
+ }
3120
+ getObjectsByPaging(pageIndex, pageSize, sortColumn, direction) {
3121
+ return httpResource(() => {
3122
+ this._refreshTrigger();
3123
+ const queryParams = {};
3124
+ if (pageIndex() + 1) queryParams[this.pageIndexParam] = pageIndex() + 1;
3125
+ if (pageSize()) queryParams[this.pageSizeParam] = pageSize();
3126
+ if (sortColumn()) queryParams[this.sortColumnParam] = sortColumn();
3127
+ if (direction()) queryParams[this.directionParam] = direction();
3128
+ return {
3129
+ url: this.baseRoute,
3130
+ params: queryParams
3131
+ };
3132
+ }, {
3133
+ ...this.getHttpContext(),
3134
+ parse: (data) => Array.isArray(data) ? data.map((item) => new this.entityType(item).deserialize(item)) : []
3135
+ });
3136
+ }
3137
+ newObject(entity) {
3138
+ return this.http.post(this.baseRoute, entity, this.getHttpContext());
3139
+ }
3140
+ create(dto) {
3141
+ return httpResource(() => ({
3142
+ url: this.baseRoute,
3143
+ method: "POST",
3144
+ body: dto
3145
+ }), {
3146
+ ...this.getHttpContext(),
3147
+ parse: (data) => this.schema.parse(data)
3148
+ });
3149
+ }
3150
+ editObject(entity) {
3151
+ return this.http.put(this.baseRoute + entity.id, entity, this.getHttpContext());
3152
+ }
3153
+ update(id, dto) {
3154
+ return httpResource(() => ({
3155
+ url: `${this.baseRoute}/${id}`,
3156
+ method: "PUT",
3157
+ body: dto
3158
+ }), {
3159
+ ...this.getHttpContext(),
3160
+ parse: (data) => this.schema.parse(data)
3161
+ });
3162
+ }
3163
+ deleteObject(entity) {
3164
+ return this.http.delete(this.baseRoute + entity.id, this.getHttpContext()).pipe(tap(() => this.refresh()));
3165
+ }
3166
+ getParams(pageIndex, pageSize, sortColumn, direction) {
3167
+ let params = new HttpParams();
3168
+ if (pageIndex + 1) params = params.append(this.pageIndexParam, pageIndex + 1);
3169
+ if (pageSize) params = params.append(this.pageSizeParam, pageSize);
3170
+ if (sortColumn) params = params.append(this.sortColumnParam, sortColumn);
3171
+ if (direction) params = params.append(this.directionParam, direction);
3172
+ return params;
3173
+ }
3174
+ getHttpContext() {
3175
+ if (!this.apiContextName) return {};
3176
+ return { context: new HttpContext().set(API_NAME, this.apiContextName) };
3177
+ }
3178
+ static ɵfac = i0.ɵɵngDeclareFactory({
3179
+ minVersion: "12.0.0",
3180
+ version: "22.2.2",
3181
+ ngImport: i0,
3182
+ type: BaseSignalServiceClass,
3183
+ deps: [],
3184
+ target: i0.ɵɵFactoryTarget.Injectable
3185
+ });
3186
+ static ɵprov = i0.ɵɵngDeclareInjectable({
3187
+ minVersion: "12.0.0",
3188
+ version: "22.2.2",
3189
+ ngImport: i0,
3190
+ type: BaseSignalServiceClass,
3191
+ providedIn: "root"
3192
+ });
3193
+ };
3194
+ i0.ɵɵngDeclareClassMetadata({
3195
+ minVersion: "12.0.0",
3196
+ version: "22.2.2",
3197
+ ngImport: i0,
3198
+ type: BaseSignalServiceClass,
3199
+ decorators: [{
3200
+ type: Injectable,
3201
+ args: [{ providedIn: "root" }]
3202
+ }]
3203
+ });
2574
3204
  var SafePipe = class SafePipe {
2575
3205
  sanitizer = inject(DomSanitizer);
2576
3206
  transform(url) {
@@ -4917,6 +5547,6 @@ var SecUser = class {
4917
5547
  return this;
4918
5548
  }
4919
5549
  };
4920
- export { Action, AvatarService, BaseEditClass, BaseFilterClass, BaseMatChipComponent, BaseNavBarMenuClass, BasePageClass, BaseSelectAutocompleteWithVsComponent, BaseSelectWithGroupComponent, BaseServiceClass, BaseToolbarComponent, CustomDateAdapter, DateRangeInputComponent, DialogAction, DialogComponent, DisableIfRoleDirective, EmptyComponent, EntityAction, ExportService, HideIfForbiddenRoleDirective, LOGGER_CONFIG, LoaderService, LocalStorageService, LoggerService, LoginPageComponent, MY_NATIVE_FORMATS, NavBarComponent, NotFoundComponent, ProgressSpinnerComponent, SafePipe, SecUser, SecureImageService, SetValueDirective, SseService, TableComponent, TimePipe, TruncatePipe, authGuard, dateFormat, provideLogger, redirectGuard, roleGuard };
5550
+ 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, SecUser, SecureImageService, SetValueDirective, SseService, TableComponent, TimePipe, TruncatePipe, authGuard, dateFormat, provideLogger, redirectGuard, roleGuard };
4921
5551
 
4922
5552
  //# sourceMappingURL=kuzntsv-uikit-ui.mjs.map