@verisoft/ui-core 18.0.0 → 18.3.1
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.
- package/package.json +7 -4
- package/src/index.ts +3 -1
- package/src/lib/common/constants.ts +5 -1
- package/src/lib/common/control.models.ts +14 -0
- package/src/lib/common/datasource-component.model.ts +6 -4
- package/src/lib/common/deactivate-guard.model.ts +5 -0
- package/src/lib/common/download-file.ts +20 -0
- package/src/lib/common/filter.ts +7 -0
- package/src/lib/common/icons.ts +34 -0
- package/src/lib/common/index.ts +7 -1
- package/src/lib/common/notificable-property.model.ts +5 -0
- package/src/lib/common/rxjs.spec.ts +58 -0
- package/src/lib/common/rxjs.ts +21 -0
- package/src/lib/components/action-button-group/action-button-group.model.ts +9 -10
- package/src/lib/components/action-button-group/action-button.model.ts +14 -15
- package/src/lib/components/base-form/base-form-input.component.ts +7 -1
- package/src/lib/components/base-form/base-form.component.ts +33 -6
- package/src/lib/components/base-form/directives/detail-store.directive.ts +104 -31
- package/src/lib/components/breadcrumb/breadcrumbcore.component.ts +50 -29
- package/src/lib/components/button/button.model.ts +0 -1
- package/src/lib/components/calendar/calendar.model.ts +1 -1
- package/src/lib/components/checkbox/checkbox.model.ts +1 -2
- package/src/lib/components/confirm-dialog/confirm-dialog.model.ts +22 -17
- package/src/lib/components/confirm-dialog/index.ts +1 -1
- package/src/lib/components/dropdown/dropdown.model.ts +3 -0
- package/src/lib/components/dynamic-component/dynamic-component.model.ts +2 -0
- package/src/lib/components/dynamic-component/index.ts +1 -0
- package/src/lib/components/filter/filter.model.ts +17 -0
- package/src/lib/components/filter/index.ts +1 -0
- package/src/lib/components/generic-field/generic-field.model.ts +1 -1
- package/src/lib/components/generic-form/generic-form.component.ts +33 -0
- package/src/lib/components/generic-form/index.ts +1 -0
- package/src/lib/components/header/header.model.ts +2 -2
- package/src/lib/components/icons/icons.component.ts +17 -0
- package/src/lib/components/icons/icons.model.ts +10 -0
- package/src/lib/components/icons/index.ts +2 -0
- package/src/lib/components/index.ts +4 -0
- package/src/lib/components/loader/loader.model.ts +1 -2
- package/src/lib/components/page-header/index.ts +3 -1
- package/src/lib/components/page-header/page-header.model.ts +1 -7
- package/src/lib/components/page-header/page-header.service.ts +9 -0
- package/src/lib/components/page-header/page-headercore.component.ts +40 -0
- package/src/lib/components/password/password.model.ts +14 -0
- package/src/lib/components/side-menu/directives/side-menu-service.directive.ts +31 -0
- package/src/lib/components/side-menu/index.ts +2 -1
- package/src/lib/components/side-menu/services/side-menu.service.ts +8 -4
- package/src/lib/components/side-menu/side-menu.model.ts +14 -11
- package/src/lib/components/snackbar/snackbar.model.ts +1 -2
- package/src/lib/components/stepper/stepper.model.ts +13 -3
- package/src/lib/components/switch/switch.model.ts +1 -2
- package/src/lib/components/tab-view/tab-view.model.ts +7 -4
- package/src/lib/components/table/column-configuration.ts +38 -0
- package/src/lib/components/table/index.ts +3 -1
- package/src/lib/components/table/table-builder.ts +93 -0
- package/src/lib/components/table/table-column.directive.ts +62 -0
- package/src/lib/components/table/table.models.ts +116 -44
- package/src/lib/components/textfield/textfield.model.ts +1 -1
- package/src/lib/components/tristatecheckbox/tristatecheckbox.model.ts +1 -2
- package/src/lib/directives/datasource.directive.ts +10 -10
- package/src/lib/directives/index.ts +3 -0
- package/src/lib/directives/shortcut.directive.ts +37 -0
- package/src/lib/directives/table-datasource.directive.ts +184 -0
- package/src/lib/directives/table-filter.directive.ts +69 -0
- package/src/lib/format/format.ts +74 -0
- package/src/lib/pipes/error/error.codes.ts +6 -1
- package/src/lib/pipes/helper/enumToList.pipe.ts +16 -0
- package/src/lib/pipes/index.ts +1 -2
- package/src/lib/services/confirm-dialog.service.ts +44 -0
- package/src/lib/services/index.ts +4 -0
- package/src/lib/services/leave-form.service.ts +53 -0
- package/src/lib/services/screen-size.service.ts +25 -0
- package/src/lib/services/table.service.ts +22 -0
- package/src/lib/components/table/template-column.directive.ts +0 -45
- package/src/lib/pipes/gov/gov-color.pipe.ts +0 -24
- package/src/lib/pipes/gov/gov-size.pipe.ts +0 -16
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectorRef,
|
|
3
|
+
Directive,
|
|
4
|
+
Input,
|
|
5
|
+
inject,
|
|
6
|
+
OnInit,
|
|
7
|
+
} from '@angular/core';
|
|
2
8
|
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
|
|
3
9
|
import { filter, takeUntil } from 'rxjs';
|
|
4
10
|
import { MenuItem } from '../side-menu';
|
|
@@ -17,6 +23,8 @@ export class BreadcrumbCoreComponent
|
|
|
17
23
|
|
|
18
24
|
static readonly ROUTE_DATA_BREADCRUMB = 'breadcrumb';
|
|
19
25
|
static readonly ROUTE_DATA_BREADCRUMB_URL = 'breadcrumb_url';
|
|
26
|
+
static readonly ROUTE_DATA_NO_BREADCRUMB_ROUTE = 'breadcrumb_no_route';
|
|
27
|
+
static readonly BREADCRUMB_HIDE = 'breadcrumb_hide';
|
|
20
28
|
readonly home = { icon: 'pi pi-home', routerLink: this.homeRoute };
|
|
21
29
|
|
|
22
30
|
router = inject(Router);
|
|
@@ -31,7 +39,10 @@ export class BreadcrumbCoreComponent
|
|
|
31
39
|
|
|
32
40
|
private initBreadcrumbsCreation() {
|
|
33
41
|
this.router.events
|
|
34
|
-
.pipe(
|
|
42
|
+
.pipe(
|
|
43
|
+
filter((event) => event instanceof NavigationEnd),
|
|
44
|
+
takeUntil(this.destroyed$)
|
|
45
|
+
)
|
|
35
46
|
.subscribe(
|
|
36
47
|
() => (this.items = this.createBreadcrumbs(this.activatedRoute.root))
|
|
37
48
|
);
|
|
@@ -39,22 +50,22 @@ export class BreadcrumbCoreComponent
|
|
|
39
50
|
|
|
40
51
|
private initRouteChangeListen() {
|
|
41
52
|
this.breadcrumbService.routeChange
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
.pipe(
|
|
54
|
+
filter((x) => x.label !== 'Undefined'),
|
|
55
|
+
takeUntil(this.destroyed$)
|
|
56
|
+
)
|
|
57
|
+
.subscribe((x) => {
|
|
58
|
+
this.items = [
|
|
59
|
+
...this.items,
|
|
60
|
+
{
|
|
61
|
+
label: x.label,
|
|
62
|
+
routerLink: x.routerLink,
|
|
63
|
+
url: x.url,
|
|
64
|
+
class: 'breadcrumb',
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
this.cdr.detectChanges();
|
|
68
|
+
});
|
|
58
69
|
}
|
|
59
70
|
|
|
60
71
|
private createBreadcrumbs(
|
|
@@ -73,19 +84,29 @@ export class BreadcrumbCoreComponent
|
|
|
73
84
|
.map((segment) => segment.path)
|
|
74
85
|
.join('/');
|
|
75
86
|
|
|
76
|
-
if (BreadcrumbCoreComponent.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
87
|
+
if (!child.snapshot.data[BreadcrumbCoreComponent.BREADCRUMB_HIDE]) {
|
|
88
|
+
if (BreadcrumbCoreComponent.ROUTE_DATA_BREADCRUMB_URL !== undefined) {
|
|
89
|
+
const route =
|
|
90
|
+
child.snapshot.data[BreadcrumbCoreComponent.ROUTE_DATA_BREADCRUMB_URL];
|
|
91
|
+
routerLink += `/${route}`;
|
|
92
|
+
}
|
|
81
93
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
94
|
+
if (!BreadcrumbCoreComponent.ROUTE_DATA_BREADCRUMB_URL && routeURL !== '') {
|
|
95
|
+
routerLink += `/${routeURL}`;
|
|
96
|
+
}
|
|
85
97
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
98
|
+
const label = child.snapshot.data[BreadcrumbCoreComponent.ROUTE_DATA_BREADCRUMB];
|
|
99
|
+
if (
|
|
100
|
+
label &&
|
|
101
|
+
BreadcrumbCoreComponent.ROUTE_DATA_NO_BREADCRUMB_ROUTE &&
|
|
102
|
+
child.snapshot.data[
|
|
103
|
+
BreadcrumbCoreComponent.ROUTE_DATA_NO_BREADCRUMB_ROUTE
|
|
104
|
+
]
|
|
105
|
+
) {
|
|
106
|
+
breadcrumbs.push({ label, routerLink: undefined });
|
|
107
|
+
} else if (label && child.snapshot.routeConfig?.path !== '') {
|
|
108
|
+
breadcrumbs.push({ label, routerLink: routerLink });
|
|
109
|
+
}
|
|
89
110
|
}
|
|
90
111
|
|
|
91
112
|
return this.createBreadcrumbs(child, routerLink, breadcrumbs);
|
|
@@ -5,5 +5,4 @@ export const CHECKBOX_COMPONENT_TOKEN = new InjectionToken<CheckboxCore>(
|
|
|
5
5
|
'CheckboxComponentToken'
|
|
6
6
|
);
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
export interface CheckboxCore extends BaseFormCore {}
|
|
8
|
+
export type CheckboxCore = BaseFormCore
|
|
@@ -3,24 +3,29 @@ import { SafeHtml } from "@angular/platform-browser";
|
|
|
3
3
|
import { ControlSeverityType } from '../../common';
|
|
4
4
|
|
|
5
5
|
export const CONFIRM_DIALOG_COMPONENT_TOKEN = new InjectionToken<ConfirmDialogCore>(
|
|
6
|
-
|
|
6
|
+
'ConfirmDialogComponentToken'
|
|
7
7
|
);
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
export interface ConfirmDialogCore {}
|
|
9
|
+
export type ConfirmDialogCore = object
|
|
11
10
|
|
|
12
11
|
export interface DialogData {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
12
|
+
title?: string;
|
|
13
|
+
headerIcon?: string;
|
|
14
|
+
severity?: ControlSeverityType;
|
|
15
|
+
showCancelButton?: boolean;
|
|
16
|
+
buttonOrder?: 'confirm-cancel' | 'cancel-confirm';
|
|
17
|
+
confirmButtonText?: string;
|
|
18
|
+
confirmButtonFn?: () => void;
|
|
19
|
+
cancelButtonFn?: () => void;
|
|
20
|
+
cancelButtonText?: string;
|
|
21
|
+
innerHTML?: string | SafeHtml;
|
|
22
|
+
data?: unknown;
|
|
23
|
+
componentType?: Type<unknown>;
|
|
24
|
+
closable?: boolean;
|
|
25
|
+
width?: string;
|
|
26
|
+
height?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface ExtendedDialogData<TInputs = any, TOutputs = any> extends DialogData {
|
|
30
|
+
data?: TInputs & TOutputs;
|
|
31
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './confirm-dialog.model';
|
|
1
|
+
export * from './confirm-dialog.model';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dynamic-component.model';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { ControlValueAccessor } from '@angular/forms';
|
|
3
|
+
import { GenericFieldDefinition } from '../generic-form';
|
|
4
|
+
|
|
5
|
+
export const FILTER_COMPONENT_TOKEN = new InjectionToken<FilterCore>(
|
|
6
|
+
'FilterComponentToken'
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
export interface FilterCore extends ControlValueAccessor {
|
|
10
|
+
fields: GenericFieldDefinition[];
|
|
11
|
+
title?: string;
|
|
12
|
+
fulltextFieldName: string;
|
|
13
|
+
showFulltext: boolean;
|
|
14
|
+
showFilters: boolean;
|
|
15
|
+
autoBind: boolean;
|
|
16
|
+
debounceTime?: number;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './filter.model';
|
|
@@ -3,7 +3,7 @@ import { DataSourceComponentModel } from '../../common';
|
|
|
3
3
|
import { BaseFormCore } from '../base-form';
|
|
4
4
|
|
|
5
5
|
export const GENERIC_FIELD_COMPONENT_TOKEN = new InjectionToken<GenericFieldCore<any>>(
|
|
6
|
-
'
|
|
6
|
+
'GenericFieldComponentToken'
|
|
7
7
|
);
|
|
8
8
|
|
|
9
9
|
export interface GenericFieldCore<T> extends DataSourceComponentModel<T>, BaseFormCore {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ValidatorFn } from '@angular/forms';
|
|
2
|
+
import { DatasourceType } from '@verisoft/core';
|
|
3
|
+
import { FieldSizeType } from '../../common';
|
|
4
|
+
|
|
5
|
+
export interface GenericFieldDefinition {
|
|
6
|
+
validator?: ValidatorFn[];
|
|
7
|
+
type?: GenericFieldTypeType;
|
|
8
|
+
label?: string;
|
|
9
|
+
floatLabel?: boolean;
|
|
10
|
+
name: string;
|
|
11
|
+
optionLabel?: string;
|
|
12
|
+
optionValue?: string;
|
|
13
|
+
options?: unknown[];
|
|
14
|
+
value?: unknown;
|
|
15
|
+
testId?: string;
|
|
16
|
+
size?: FieldSizeType;
|
|
17
|
+
readonly?: boolean;
|
|
18
|
+
datasource?: DatasourceType<any>;
|
|
19
|
+
filterField?: string;
|
|
20
|
+
showFilter?: boolean;
|
|
21
|
+
localSearch?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export enum GenericFieldType {
|
|
25
|
+
'dropdown' = 'dropdown',
|
|
26
|
+
'checkbox' = 'checkbox',
|
|
27
|
+
'simplecheckbox' = 'simplecheckbox',
|
|
28
|
+
'calendar' = 'calendar',
|
|
29
|
+
'multiselect' = 'multiselect',
|
|
30
|
+
'text' = 'text',
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type GenericFieldTypeType = keyof typeof GenericFieldType;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './generic-form.component';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InjectionToken } from '@angular/core';
|
|
2
|
-
import { MenuItem } from '
|
|
2
|
+
import { MenuItem } from '../side-menu/side-menu.model';
|
|
3
3
|
|
|
4
4
|
export const HEADER_COMPONENT_TOKEN = new InjectionToken<HeaderCore>(
|
|
5
5
|
'HeaderComponentToken'
|
|
@@ -7,7 +7,7 @@ export const HEADER_COMPONENT_TOKEN = new InjectionToken<HeaderCore>(
|
|
|
7
7
|
|
|
8
8
|
export const SETTINGS_MENU = new InjectionToken<MenuItem[]>(
|
|
9
9
|
'SETTINGS_MENU'
|
|
10
|
-
|
|
10
|
+
);
|
|
11
11
|
|
|
12
12
|
export interface HeaderCore {
|
|
13
13
|
title: string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Component, Input } from "@angular/core";
|
|
2
|
+
import { ICONS_COMPONENT_TOKEN } from "./icons.model";
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
standalone: true,
|
|
6
|
+
template: '',
|
|
7
|
+
providers: [
|
|
8
|
+
{
|
|
9
|
+
provide: ICONS_COMPONENT_TOKEN,
|
|
10
|
+
useExisting: IconsComponent
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
export class IconsComponent{
|
|
16
|
+
@Input() name!: string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { InjectionToken } from "@angular/core";
|
|
2
|
+
import { CommonIcons } from "../../common/icons"
|
|
3
|
+
|
|
4
|
+
export const ICONS_COMPONENT_TOKEN = new InjectionToken<IconsCore>(
|
|
5
|
+
'IconsComponentToken'
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
export interface IconsCore extends CommonIcons {
|
|
9
|
+
name: string;
|
|
10
|
+
}
|
|
@@ -6,8 +6,11 @@ export * from './calendar';
|
|
|
6
6
|
export * from './checkbox';
|
|
7
7
|
export * from './confirm-dialog';
|
|
8
8
|
export * from './dropdown';
|
|
9
|
+
export * from './dynamic-component';
|
|
10
|
+
export * from './filter';
|
|
9
11
|
export * from './form-field';
|
|
10
12
|
export * from './generic-field';
|
|
13
|
+
export * from './generic-form';
|
|
11
14
|
export * from './header';
|
|
12
15
|
export * from './input-group';
|
|
13
16
|
export * from './loader';
|
|
@@ -29,3 +32,4 @@ export * from './textarea';
|
|
|
29
32
|
export * from './textfield';
|
|
30
33
|
export * from './tristatecheckbox';
|
|
31
34
|
export * from './unsubscribe.component';
|
|
35
|
+
export * from './icons';
|
|
@@ -7,11 +7,5 @@ export const PAGE_HEADER_COMPONENT_TOKEN = new InjectionToken<PageHeaderCore>(
|
|
|
7
7
|
export interface PageHeaderCore {
|
|
8
8
|
title: string;
|
|
9
9
|
subtitle: string | undefined;
|
|
10
|
-
showBackButton: boolean;
|
|
10
|
+
showBackButton: boolean | undefined;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
export interface PageHeader {
|
|
14
|
-
title: string;
|
|
15
|
-
subtitle?: string;
|
|
16
|
-
showBackButton?: boolean;
|
|
17
|
-
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EventEmitter, Injectable, Output } from '@angular/core';
|
|
2
|
+
import { PageHeaderCore } from './page-header.model';
|
|
3
|
+
|
|
4
|
+
@Injectable({
|
|
5
|
+
providedIn: 'root',
|
|
6
|
+
})
|
|
7
|
+
export class PageHeaderService {
|
|
8
|
+
@Output() pageHeader = new EventEmitter<PageHeaderCore>();
|
|
9
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ChangeDetectorRef, Directive, Input, OnInit } from '@angular/core';
|
|
2
|
+
import { Router } from '@angular/router';
|
|
3
|
+
import { takeUntil } from 'rxjs';
|
|
4
|
+
import { FieldSize, FieldSizeType } from '../../common';
|
|
5
|
+
import { UnsubscribeComponent } from '../unsubscribe.component';
|
|
6
|
+
import { PageHeaderService } from './page-header.service';
|
|
7
|
+
|
|
8
|
+
@Directive({})
|
|
9
|
+
export class PageHeaderCoreComponent
|
|
10
|
+
extends UnsubscribeComponent
|
|
11
|
+
implements OnInit
|
|
12
|
+
{
|
|
13
|
+
@Input() title!: string;
|
|
14
|
+
@Input() subtitle: string | undefined;
|
|
15
|
+
@Input() showBackButton!: boolean;
|
|
16
|
+
@Input() size: FieldSizeType = FieldSize.small;
|
|
17
|
+
|
|
18
|
+
constructor(
|
|
19
|
+
readonly router: Router,
|
|
20
|
+
readonly cdr: ChangeDetectorRef,
|
|
21
|
+
readonly headerService: PageHeaderService
|
|
22
|
+
) {
|
|
23
|
+
super();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
ngOnInit(): void {
|
|
27
|
+
this.headerService.pageHeader
|
|
28
|
+
.pipe(takeUntil(this.destroyed$))
|
|
29
|
+
.subscribe((x: any) => {
|
|
30
|
+
this.title = x.title;
|
|
31
|
+
this.subtitle = x.subtitle;
|
|
32
|
+
this.showBackButton = x.showBackButton ?? false;
|
|
33
|
+
this.cdr.detectChanges();
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
protected locationBack() {
|
|
38
|
+
history.back();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -5,7 +5,21 @@ export const PASSWORD_COMPONENT_TOKEN = new InjectionToken<PasswordCore>(
|
|
|
5
5
|
'PasswordComponentToken'
|
|
6
6
|
);
|
|
7
7
|
|
|
8
|
+
export enum PasswordStrength {
|
|
9
|
+
None = 0,
|
|
10
|
+
Low = 1,
|
|
11
|
+
Medium = 2,
|
|
12
|
+
High = 3,
|
|
13
|
+
Superb = 4
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
export interface PasswordCore extends BaseFormCore {
|
|
9
17
|
toggleMask: boolean;
|
|
10
18
|
feedback: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface PasswordValidationItem {
|
|
22
|
+
severity: 'success' | 'error';
|
|
23
|
+
validationLabel: string;
|
|
24
|
+
validationFn: (x: string) => boolean;
|
|
11
25
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AfterViewInit, ChangeDetectorRef, Directive, inject } from "@angular/core";
|
|
2
|
+
import { takeUntil } from "rxjs";
|
|
3
|
+
import { UnsubscribeComponent } from "../../unsubscribe.component";
|
|
4
|
+
import { SideMenuService } from "../services/side-menu.service";
|
|
5
|
+
import { SIDE_MENU_COMPONENT_TOKEN } from "../side-menu.model";
|
|
6
|
+
|
|
7
|
+
@Directive({
|
|
8
|
+
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
9
|
+
selector: 'v-side-menu[useMenuService]',
|
|
10
|
+
exportAs: 'useMenuService',
|
|
11
|
+
standalone: true,
|
|
12
|
+
})
|
|
13
|
+
export class MenuServiceDirective
|
|
14
|
+
extends UnsubscribeComponent
|
|
15
|
+
implements AfterViewInit
|
|
16
|
+
{
|
|
17
|
+
private readonly menuService = inject(SideMenuService);
|
|
18
|
+
private readonly cdr = inject(ChangeDetectorRef);
|
|
19
|
+
private readonly sideMenu = inject(SIDE_MENU_COMPONENT_TOKEN);
|
|
20
|
+
|
|
21
|
+
ngAfterViewInit() {
|
|
22
|
+
this.menuService.menuItems$.pipe(takeUntil(this.destroyed$)).subscribe((items) => {
|
|
23
|
+
|
|
24
|
+
if (this.sideMenu) {
|
|
25
|
+
this.sideMenu.items = items;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
this.cdr.detectChanges();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -26,7 +26,7 @@ export class SideMenuService {
|
|
|
26
26
|
);
|
|
27
27
|
|
|
28
28
|
if (!expanded) {
|
|
29
|
-
this.stateToken.expanded?.push(item.label);
|
|
29
|
+
this.stateToken.expanded?.push(item.label!);
|
|
30
30
|
localStorage.setItem(
|
|
31
31
|
'SideMenuStateToken',
|
|
32
32
|
JSON.stringify(this.stateToken)
|
|
@@ -50,9 +50,13 @@ export class SideMenuService {
|
|
|
50
50
|
const localStorageValue = this.stateToken.expanded;
|
|
51
51
|
|
|
52
52
|
if (!localStorageValue) return;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
if (items) {
|
|
54
|
+
for (let index = 0; index < items.length; index++) {
|
|
55
|
+
const element = items[index];
|
|
56
|
+
element.expanded = !!localStorageValue.find(
|
|
57
|
+
(i: string) => i === element.label
|
|
58
|
+
);
|
|
59
|
+
}
|
|
56
60
|
}
|
|
57
61
|
}
|
|
58
62
|
}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
2
3
|
|
|
3
4
|
export const MENU_TOKEN = new InjectionToken<MenuItem[]>(
|
|
4
|
-
|
|
5
|
+
'MENU'
|
|
5
6
|
);
|
|
6
7
|
|
|
7
8
|
export const LOGO_ROUTER_ROUTE = new InjectionToken<string>(
|
|
8
9
|
'LOGO_ROUTER_ROUTE'
|
|
9
10
|
);
|
|
10
11
|
|
|
11
|
-
export const SIDE_MENU_COMPONENT_TOKEN = new InjectionToken<
|
|
12
|
+
export const SIDE_MENU_COMPONENT_TOKEN = new InjectionToken<SideMenuCore>(
|
|
12
13
|
'SideMenuComponentToken'
|
|
13
14
|
);
|
|
14
15
|
|
|
15
16
|
export const SIDE_MENU_STATE_TOKEN = new InjectionToken<SideMenuState>(
|
|
16
|
-
|
|
17
|
+
'SideMenuStateToken'
|
|
17
18
|
);
|
|
18
19
|
|
|
19
20
|
export interface SideMenuState {
|
|
@@ -23,17 +24,19 @@ export interface SideMenuState {
|
|
|
23
24
|
|
|
24
25
|
export interface MenuItem {
|
|
25
26
|
id?: string;
|
|
26
|
-
label
|
|
27
|
+
label?: string | undefined;
|
|
27
28
|
icon?: string;
|
|
28
29
|
expanded?: boolean;
|
|
29
30
|
data?: MenuItemData;
|
|
30
31
|
tooltip?: string;
|
|
31
32
|
url?: string;
|
|
32
|
-
visible?: boolean
|
|
33
|
+
visible?: boolean | Observable<boolean>;
|
|
33
34
|
type?: string;
|
|
34
35
|
children?: MenuItem[];
|
|
35
36
|
routerLink?: any;
|
|
36
37
|
class?: string;
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
39
|
+
command?: Function;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
type ExtendableType = {
|
|
@@ -56,9 +59,9 @@ export interface SideMenuModuleConfig {
|
|
|
56
59
|
items?: MenuItem[];
|
|
57
60
|
}
|
|
58
61
|
|
|
59
|
-
export interface
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
62
|
+
export interface SideMenuCore {
|
|
63
|
+
items: MenuItem[];
|
|
64
|
+
logoUrl: string;
|
|
65
|
+
userName: string;
|
|
66
|
+
userRole: any | any[] | undefined;
|
|
67
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { InjectionToken, TemplateRef } from "@angular/core";
|
|
1
|
+
import { EventEmitter, InjectionToken, TemplateRef } from "@angular/core";
|
|
2
|
+
import { FieldSizeType, LayoutTypeType } from "../../common";
|
|
2
3
|
|
|
3
4
|
export const STEPPER_COMPONENT_TOKEN = new InjectionToken<StepperCore>(
|
|
4
5
|
'StepperComponentToken'
|
|
@@ -6,9 +7,18 @@ export const STEPPER_COMPONENT_TOKEN = new InjectionToken<StepperCore>(
|
|
|
6
7
|
|
|
7
8
|
export interface StepperItem {
|
|
8
9
|
header: string;
|
|
9
|
-
template
|
|
10
|
+
template?: TemplateRef<any>;
|
|
11
|
+
annotation?: string;
|
|
12
|
+
prefix?: string;
|
|
10
13
|
}
|
|
11
14
|
|
|
12
15
|
export interface StepperCore {
|
|
13
|
-
items: StepperItem[]
|
|
16
|
+
items: StepperItem[]
|
|
17
|
+
layout: LayoutTypeType
|
|
18
|
+
activeIndexChange: EventEmitter<number>
|
|
19
|
+
size: FieldSizeType | undefined;
|
|
20
|
+
icon: string;
|
|
21
|
+
prefix: string;
|
|
22
|
+
annotation: string;
|
|
23
|
+
label: string;
|
|
14
24
|
}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import { InjectionToken, TemplateRef } from "@angular/core";
|
|
1
|
+
import { EventEmitter, InjectionToken, TemplateRef } from "@angular/core";
|
|
2
2
|
|
|
3
3
|
export const TAB_VIEW_COMPONENT_TOKEN = new InjectionToken<TabViewCore>(
|
|
4
4
|
'TabVIewComponentToken'
|
|
5
5
|
);
|
|
6
6
|
|
|
7
|
-
export interface
|
|
7
|
+
export interface TabViewItemCore {
|
|
8
8
|
title: string;
|
|
9
9
|
url?: string;
|
|
10
10
|
icon?: string;
|
|
11
|
+
disabled?: boolean;
|
|
11
12
|
content?: string;
|
|
12
|
-
contentTemplate?: TemplateRef<unknown
|
|
13
|
+
contentTemplate?: TemplateRef<unknown>;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export interface TabViewCore {
|
|
16
|
-
items:
|
|
17
|
+
items: TabViewItemCore[];
|
|
17
18
|
useRouting: boolean;
|
|
18
19
|
activeIndex: number;
|
|
20
|
+
activeIndexChange: EventEmitter<number>;
|
|
21
|
+
url?: string;
|
|
19
22
|
}
|