@kuzntsv/uikit 1.0.40 → 1.0.42

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