@verisoft/ui-core 19.0.0-rc001 → 20.1.0
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/.eslintrc.json +48 -0
- package/README.md +314 -3
- package/jest.config.ts +21 -0
- package/ng-package.json +11 -0
- package/package.json +16 -31
- package/project.json +36 -0
- package/{index.d.ts → src/index.ts} +1 -1
- package/src/lib/common/angular-helper.ts +44 -0
- package/src/lib/common/constants.ts +5 -0
- package/src/lib/common/control.models.ts +80 -0
- package/src/lib/common/datasource-component.model.spec.ts +42 -0
- package/src/lib/common/datasource-component.model.ts +43 -0
- package/{lib/common/deactivate-guard.model.d.ts → src/lib/common/deactivate-guard.model.ts} +2 -1
- package/src/lib/common/download-file.ts +20 -0
- package/src/lib/common/filter.ts +7 -0
- package/{lib/common/icons.d.ts → src/lib/common/icons.ts} +34 -34
- package/{lib/common/index.d.ts → src/lib/common/index.ts} +10 -10
- package/{lib/common/notificable-property.model.d.ts → src/lib/common/notificable-property.model.ts} +5 -4
- 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 +15 -0
- package/src/lib/components/action-button-group/action-button.model.ts +15 -0
- package/{lib/components/action-button-group/index.d.ts → src/lib/components/action-button-group/index.ts} +2 -2
- package/src/lib/components/base-form/base-form-input.component.ts +120 -0
- package/src/lib/components/base-form/base-form.component.ts +236 -0
- package/src/lib/components/base-form/directives/detail-store.directive.ts +219 -0
- package/{lib/components/base-form/index.d.ts → src/lib/components/base-form/index.ts} +2 -2
- package/src/lib/components/base-form/models/base-form-input.models.ts +11 -0
- package/src/lib/components/base-form/models/base-form.models.ts +31 -0
- package/{lib/components/base-form/models/index.d.ts → src/lib/components/base-form/models/index.ts} +1 -1
- package/{lib/components/breadcrumb/breadcrumb.model.d.ts → src/lib/components/breadcrumb/breadcrumb.model.ts} +6 -1
- package/src/lib/components/breadcrumb/breadcrumb.service.ts +9 -0
- package/src/lib/components/breadcrumb/breadcrumbcore.component.ts +117 -0
- package/src/lib/components/breadcrumb/index.ts +3 -0
- package/{lib/components/button/button.model.d.ts → src/lib/components/button/button.model.ts} +5 -1
- package/src/lib/components/button/index.ts +1 -0
- package/{lib/components/calendar/calendar.model.d.ts → src/lib/components/calendar/calendar.model.ts} +6 -2
- package/src/lib/components/calendar/index.ts +1 -0
- package/{lib/components/checkbox/checkbox.model.d.ts → src/lib/components/checkbox/checkbox.model.ts} +5 -1
- package/src/lib/components/checkbox/index.ts +1 -0
- package/src/lib/components/confirm-dialog/confirm-dialog.model.ts +31 -0
- package/src/lib/components/confirm-dialog/index.ts +1 -0
- package/{lib/components/dropdown/dropdown.model.d.ts → src/lib/components/dropdown/dropdown.model.ts} +5 -1
- package/src/lib/components/dropdown/index.ts +1 -0
- package/{lib/components/dropdown-button/dropdown-button.model.d.ts → src/lib/components/dropdown-button/dropdown-button.model.ts} +18 -14
- package/src/lib/components/dropdown-button/index.ts +1 -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/{lib/components/filter/index.d.ts → src/lib/components/filter/index.ts} +1 -1
- package/{lib/components/form-field/form-field.model.d.ts → src/lib/components/form-field/form-field.model.ts} +6 -2
- package/src/lib/components/form-field/index.ts +1 -0
- package/{lib/components/generic-field/generic-field.model.d.ts → src/lib/components/generic-field/generic-field.model.ts} +5 -1
- package/src/lib/components/generic-field/index.ts +1 -0
- package/src/lib/components/generic-form/generic-form.component.ts +33 -0
- package/{lib/components/generic-form/index.d.ts → src/lib/components/generic-form/index.ts} +1 -1
- package/{lib/components/header/header.model.d.ts → src/lib/components/header/header.model.ts} +9 -2
- package/src/lib/components/header/index.ts +1 -0
- package/src/lib/components/icons/icons.component.ts +22 -0
- package/src/lib/components/icons/icons.model.ts +16 -0
- package/src/lib/components/icons/index.ts +2 -0
- package/{lib/components/index.d.ts → src/lib/components/index.ts} +2 -0
- package/src/lib/components/input-group/index.ts +1 -0
- package/{lib/components/input-group/input-group.model.d.ts → src/lib/components/input-group/input-group.model.ts} +7 -2
- package/src/lib/components/loader/index.ts +1 -0
- package/src/lib/components/loader/loader.model.ts +7 -0
- package/src/lib/components/multiselect/index.ts +1 -0
- package/{lib/components/multiselect/mutiselect.model.d.ts → src/lib/components/multiselect/mutiselect.model.ts} +6 -2
- package/src/lib/components/number-input/index.ts +1 -0
- package/{lib/components/number-input/number-input.model.d.ts → src/lib/components/number-input/number-input.model.ts} +6 -2
- package/{lib/components/page-header/index.d.ts → src/lib/components/page-header/index.ts} +1 -1
- package/{lib/components/page-header/page-header.model.d.ts → src/lib/components/page-header/page-header.model.ts} +5 -1
- package/src/lib/components/page-header/page-header.service.ts +9 -0
- package/src/lib/components/page-header/page-headercore.component.ts +42 -0
- package/src/lib/components/password/index.ts +1 -0
- package/{lib/components/password/password.model.d.ts → src/lib/components/password/password.model.ts} +9 -3
- package/src/lib/components/radiobutton/index.ts +1 -0
- package/{lib/components/radiobutton/radiobutton.model.d.ts → src/lib/components/radiobutton/radiobutton.model.ts} +8 -3
- package/src/lib/components/section/index.ts +1 -0
- package/{lib/components/section/section.model.d.ts → src/lib/components/section/section.model.ts} +6 -2
- package/src/lib/components/side-menu/directives/side-menu-service.directive.ts +31 -0
- package/{lib/components/side-menu/index.d.ts → src/lib/components/side-menu/index.ts} +1 -1
- package/src/lib/components/side-menu/services/side-menu-provider.service.ts +13 -0
- package/src/lib/components/side-menu/services/side-menu.service.ts +62 -0
- package/src/lib/components/side-menu/side-menu.model.ts +67 -0
- package/src/lib/components/slider/index.ts +1 -0
- package/{lib/components/slider/slider.model.d.ts → src/lib/components/slider/slider.model.ts} +6 -2
- package/src/lib/components/snackbar/index.ts +1 -0
- package/src/lib/components/snackbar/snackbar.model.ts +7 -0
- package/src/lib/components/stepper/index.ts +1 -0
- package/{lib/components/stepper/stepper.model.d.ts → src/lib/components/stepper/stepper.model.ts} +10 -5
- package/src/lib/components/switch/index.ts +1 -0
- package/src/lib/components/switch/switch.model.ts +8 -0
- package/src/lib/components/tab-view/index.ts +1 -0
- package/{lib/components/tab-view/tab-view.model.d.ts → src/lib/components/tab-view/tab-view.model.ts} +8 -3
- package/src/lib/components/table/column-configuration.ts +38 -0
- 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 +261 -0
- package/src/lib/components/table-filter/index.ts +1 -0
- package/{lib/components/table-filter/table-filter.model.d.ts → src/lib/components/table-filter/table-filter.model.ts} +6 -1
- package/src/lib/components/tag/index.ts +1 -0
- package/src/lib/components/tag/tag.model.ts +13 -0
- package/src/lib/components/textarea/index.ts +1 -0
- package/{lib/components/textarea/textarea.model.d.ts → src/lib/components/textarea/textarea.model.ts} +5 -1
- package/src/lib/components/textfield/index.ts +1 -0
- package/{lib/components/textfield/textfield.model.d.ts → src/lib/components/textfield/textfield.model.ts} +6 -2
- package/src/lib/components/tooltip/index.ts +1 -0
- package/src/lib/components/tooltip/tooltip.model.ts +13 -0
- package/src/lib/components/unsubscribe.component.ts +12 -0
- package/src/lib/directives/datasource.directive.ts +275 -0
- package/{lib/directives/index.d.ts → src/lib/directives/index.ts} +4 -4
- 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 +11 -0
- package/src/lib/pipes/error/error.models.ts +27 -0
- package/src/lib/pipes/error/error.pipe.ts +27 -0
- package/src/lib/pipes/error/warning.codes.ts +5 -0
- package/src/lib/pipes/error/warning.pipe.ts +27 -0
- package/src/lib/pipes/helper/enumToList.pipe.ts +16 -0
- package/{lib/pipes/index.d.ts → src/lib/pipes/index.ts} +1 -1
- package/src/lib/pipes/keyOrFn/keyOrFn.pipe.ts +23 -0
- package/src/lib/services/confirm-dialog.service.ts +44 -0
- package/{lib/services/index.d.ts → src/lib/services/index.ts} +4 -4
- 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/test-setup.ts +8 -0
- package/tsconfig.json +28 -0
- package/tsconfig.lib.json +17 -0
- package/tsconfig.lib.prod.json +9 -0
- package/tsconfig.spec.json +16 -0
- package/fesm2022/verisoft-ui-core.mjs +0 -2013
- package/fesm2022/verisoft-ui-core.mjs.map +0 -1
- package/lib/common/angular-helper.d.ts +0 -1
- package/lib/common/constants.d.ts +0 -3
- package/lib/common/control.models.d.ts +0 -62
- package/lib/common/datasource-component.model.d.ts +0 -19
- package/lib/common/download-file.d.ts +0 -2
- package/lib/common/filter.d.ts +0 -1
- package/lib/common/rxjs.d.ts +0 -2
- package/lib/components/action-button-group/action-button-group.model.d.ts +0 -12
- package/lib/components/action-button-group/action-button.model.d.ts +0 -14
- package/lib/components/base-form/base-form-input.component.d.ts +0 -30
- package/lib/components/base-form/base-form.component.d.ts +0 -50
- package/lib/components/base-form/directives/detail-store.directive.d.ts +0 -35
- package/lib/components/base-form/models/base-form-input.models.d.ts +0 -7
- package/lib/components/base-form/models/base-form.models.d.ts +0 -18
- package/lib/components/breadcrumb/breadcrumb.service.d.ts +0 -8
- package/lib/components/breadcrumb/breadcrumbcore.component.d.ts +0 -30
- package/lib/components/breadcrumb/index.d.ts +0 -3
- package/lib/components/button/index.d.ts +0 -1
- package/lib/components/calendar/index.d.ts +0 -1
- package/lib/components/checkbox/index.d.ts +0 -1
- package/lib/components/confirm-dialog/confirm-dialog.model.d.ts +0 -25
- package/lib/components/confirm-dialog/index.d.ts +0 -1
- package/lib/components/dropdown/index.d.ts +0 -1
- package/lib/components/dropdown-button/index.d.ts +0 -1
- package/lib/components/dynamic-component/dynamic-component.model.d.ts +0 -3
- package/lib/components/dynamic-component/index.d.ts +0 -1
- package/lib/components/filter/filter.model.d.ts +0 -13
- package/lib/components/form-field/index.d.ts +0 -1
- package/lib/components/generic-field/index.d.ts +0 -1
- package/lib/components/generic-form/generic-form.component.d.ts +0 -30
- package/lib/components/header/index.d.ts +0 -1
- package/lib/components/icons/icons.component.d.ts +0 -6
- package/lib/components/icons/icons.model.d.ts +0 -6
- package/lib/components/icons/index.d.ts +0 -2
- package/lib/components/input-group/index.d.ts +0 -1
- package/lib/components/loader/index.d.ts +0 -1
- package/lib/components/loader/loader.model.d.ts +0 -3
- package/lib/components/multiselect/index.d.ts +0 -1
- package/lib/components/number-input/index.d.ts +0 -1
- package/lib/components/page-header/page-header.service.d.ts +0 -8
- package/lib/components/page-header/page-headercore.component.d.ts +0 -20
- package/lib/components/password/index.d.ts +0 -1
- package/lib/components/radiobutton/index.d.ts +0 -1
- package/lib/components/section/index.d.ts +0 -1
- package/lib/components/side-menu/directives/side-menu-service.directive.d.ts +0 -11
- package/lib/components/side-menu/services/side-menu-provider.service.d.ts +0 -10
- package/lib/components/side-menu/services/side-menu.service.d.ts +0 -15
- package/lib/components/side-menu/side-menu.model.d.ts +0 -42
- package/lib/components/slider/index.d.ts +0 -1
- package/lib/components/snackbar/index.d.ts +0 -1
- package/lib/components/snackbar/snackbar.model.d.ts +0 -3
- package/lib/components/stepper/index.d.ts +0 -1
- package/lib/components/switch/index.d.ts +0 -1
- package/lib/components/switch/switch.model.d.ts +0 -4
- package/lib/components/tab-view/index.d.ts +0 -1
- package/lib/components/table/column-configuration.d.ts +0 -12
- package/lib/components/table/table-builder.d.ts +0 -15
- package/lib/components/table/table-column.directive.d.ts +0 -25
- package/lib/components/table/table.models.d.ts +0 -132
- package/lib/components/table-filter/index.d.ts +0 -1
- package/lib/components/textarea/index.d.ts +0 -1
- package/lib/components/textfield/index.d.ts +0 -1
- package/lib/components/unsubscribe.component.d.ts +0 -9
- package/lib/directives/datasource.directive.d.ts +0 -32
- package/lib/directives/shortcut.directive.d.ts +0 -11
- package/lib/directives/table-datasource.directive.d.ts +0 -29
- package/lib/directives/table-filter.directive.d.ts +0 -17
- package/lib/format/format.d.ts +0 -9
- package/lib/pipes/error/error.codes.d.ts +0 -5
- package/lib/pipes/error/error.models.d.ts +0 -8
- package/lib/pipes/error/error.pipe.d.ts +0 -8
- package/lib/pipes/error/warning.codes.d.ts +0 -5
- package/lib/pipes/error/warning.pipe.d.ts +0 -8
- package/lib/pipes/helper/enumToList.pipe.d.ts +0 -7
- package/lib/pipes/keyOrFn/keyOrFn.pipe.d.ts +0 -7
- package/lib/services/confirm-dialog.service.d.ts +0 -12
- package/lib/services/leave-form.service.d.ts +0 -13
- package/lib/services/screen-size.service.d.ts +0 -10
- package/lib/services/table.service.d.ts +0 -13
- /package/{lib/components/table/index.d.ts → src/lib/components/table/index.ts} +0 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Directive,
|
|
3
|
+
AfterViewInit,
|
|
4
|
+
inject,
|
|
5
|
+
Input,
|
|
6
|
+
OnInit,
|
|
7
|
+
ChangeDetectorRef,
|
|
8
|
+
OnDestroy,
|
|
9
|
+
} from '@angular/core';
|
|
10
|
+
import { ActivatedRoute } from '@angular/router';
|
|
11
|
+
import { createFeatureSelector, createSelector, Store } from '@ngrx/store';
|
|
12
|
+
import {
|
|
13
|
+
BackendValidationError,
|
|
14
|
+
createInitDetailAction,
|
|
15
|
+
createInitNewDetailAction,
|
|
16
|
+
createResetStateAction,
|
|
17
|
+
createUpdateDetailAction,
|
|
18
|
+
createUpdateDetailSetErrorsAction,
|
|
19
|
+
createUpdateFormStateAction,
|
|
20
|
+
DetailState,
|
|
21
|
+
} from '@verisoft/store';
|
|
22
|
+
import { takeUntil } from 'rxjs';
|
|
23
|
+
import { UnsubscribeComponent } from '../../unsubscribe.component';
|
|
24
|
+
import { BaseFormDirective } from '../base-form.component';
|
|
25
|
+
|
|
26
|
+
@Directive({
|
|
27
|
+
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
28
|
+
selector: '[v-useDetailStore]',
|
|
29
|
+
exportAs: 'useDetailStore',
|
|
30
|
+
standalone: true,
|
|
31
|
+
})
|
|
32
|
+
export class DetailStoreDirective
|
|
33
|
+
extends UnsubscribeComponent
|
|
34
|
+
implements OnInit, AfterViewInit, OnDestroy
|
|
35
|
+
{
|
|
36
|
+
@Input({ required: true }) form!: BaseFormDirective<any>;
|
|
37
|
+
|
|
38
|
+
@Input({ required: true }) detailsRepository!: string;
|
|
39
|
+
|
|
40
|
+
@Input() autoBind = true;
|
|
41
|
+
|
|
42
|
+
@Input() detailId!: string | number | undefined;
|
|
43
|
+
|
|
44
|
+
@Input({ required: true }) ngrxFeatureKey!: string;
|
|
45
|
+
|
|
46
|
+
@Input() destroyForm = true;
|
|
47
|
+
|
|
48
|
+
@Input() readonly = false;
|
|
49
|
+
|
|
50
|
+
@Input() readonlyControlNames: string[] = [];
|
|
51
|
+
|
|
52
|
+
store = inject(Store);
|
|
53
|
+
cdr = inject(ChangeDetectorRef);
|
|
54
|
+
route = inject(ActivatedRoute);
|
|
55
|
+
|
|
56
|
+
private itemCache: any = null;
|
|
57
|
+
private loaded!: boolean;
|
|
58
|
+
|
|
59
|
+
ngOnInit(): void {
|
|
60
|
+
if (!this.loaded) {
|
|
61
|
+
this.listenFormState();
|
|
62
|
+
}
|
|
63
|
+
this.listenFormChange();
|
|
64
|
+
this.listenFormStatusChange();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
ngAfterViewInit(): void {
|
|
68
|
+
if (this.autoBind && !this.loaded) {
|
|
69
|
+
this.initForm();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
override ngOnDestroy(): void {
|
|
74
|
+
super.ngOnDestroy();
|
|
75
|
+
if (this.destroyForm) {
|
|
76
|
+
this.store.dispatch(createResetStateAction(this.detailsRepository)());
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private initForm() {
|
|
81
|
+
if (this.detailId === 'create') {
|
|
82
|
+
this.store.dispatch(createInitNewDetailAction(this.detailsRepository)());
|
|
83
|
+
} else {
|
|
84
|
+
this.store.dispatch(
|
|
85
|
+
createInitDetailAction(this.detailsRepository)({ obj: this.detailId })
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (this.readonly) {
|
|
90
|
+
this.form.formGroup.disable();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
this.readonlyControlNames.forEach(x => {
|
|
95
|
+
this.form.formGroup.get(x)?.disable();
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private listenFormState() {
|
|
100
|
+
const selectIncomeData = createSelector(
|
|
101
|
+
createFeatureSelector<any>(this.ngrxFeatureKey),
|
|
102
|
+
(state: any) => state?.[this.detailsRepository] as DetailState<any>
|
|
103
|
+
);
|
|
104
|
+
this.store
|
|
105
|
+
.select(selectIncomeData)
|
|
106
|
+
.pipe(takeUntil(this.destroyed$))
|
|
107
|
+
.subscribe(
|
|
108
|
+
(
|
|
109
|
+
{ item, loaded, backendValidationErrors } = {
|
|
110
|
+
item: undefined,
|
|
111
|
+
loaded: false,
|
|
112
|
+
saveItemState: { saveInProgress: false },
|
|
113
|
+
backendValidationErrors: []
|
|
114
|
+
}
|
|
115
|
+
) => {
|
|
116
|
+
if (item
|
|
117
|
+
&& ((item.validationErrors || item.validationWarnings) && !this.form.formGroup.dirty)
|
|
118
|
+
|| backendValidationErrors.length
|
|
119
|
+
) {
|
|
120
|
+
this.handleValidation(
|
|
121
|
+
'propertyName',
|
|
122
|
+
item.validationWarnings || [],
|
|
123
|
+
'validationWarning',
|
|
124
|
+
'warningMessage'
|
|
125
|
+
);
|
|
126
|
+
this.handleValidation(
|
|
127
|
+
'propertyName',
|
|
128
|
+
item.validationErrors || [],
|
|
129
|
+
'validationError',
|
|
130
|
+
'errorMessage'
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
if (this.itemCache && this.isStateChanged(item) && backendValidationErrors.length) {
|
|
134
|
+
backendValidationErrors = this.dispatchErrors(item, backendValidationErrors);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
this.handleBackendValidation(backendValidationErrors);
|
|
138
|
+
this.cdr.markForCheck();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
this.itemCache = item;
|
|
142
|
+
|
|
143
|
+
this.loaded = loaded;
|
|
144
|
+
this.cdr.detectChanges();
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
private listenFormChange() {
|
|
150
|
+
this.form.dataChange.pipe(takeUntil(this.destroyed$)).subscribe((item) => {
|
|
151
|
+
this.store.dispatch(
|
|
152
|
+
createUpdateDetailAction(this.detailsRepository)({ item })
|
|
153
|
+
);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
private listenFormStatusChange() {
|
|
158
|
+
this.form.statusChange
|
|
159
|
+
.pipe(takeUntil(this.destroyed$))
|
|
160
|
+
.subscribe((formState) => {
|
|
161
|
+
this.store.dispatch(
|
|
162
|
+
createUpdateFormStateAction(this.detailsRepository)({ formState })
|
|
163
|
+
);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
private handleValidation = (
|
|
168
|
+
controlName: string,
|
|
169
|
+
errors: any[],
|
|
170
|
+
errorKey: string,
|
|
171
|
+
messageKey: string
|
|
172
|
+
) => {
|
|
173
|
+
if (errors.length > 0) return;
|
|
174
|
+
errors.forEach((error: any) => {
|
|
175
|
+
const control = this.form.formGroup.get(error[controlName]);
|
|
176
|
+
if (control) {
|
|
177
|
+
control.disabled
|
|
178
|
+
? control.disable({ emitEvent: false, onlySelf: true })
|
|
179
|
+
: control.enable({ emitEvent: false, onlySelf: true });
|
|
180
|
+
control.setErrors(
|
|
181
|
+
{ [errorKey]: error[messageKey] },
|
|
182
|
+
{ emitEvent: true }
|
|
183
|
+
);
|
|
184
|
+
control.markAsDirty();
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
private handleBackendValidation(errors: BackendValidationError[]) {
|
|
190
|
+
errors.forEach(({ parameters, code }: BackendValidationError) => {
|
|
191
|
+
const control = this.form.formGroup.get(this.normalizePropertyNames(parameters));
|
|
192
|
+
if (!control) return;
|
|
193
|
+
|
|
194
|
+
control[control.disabled ? "disable" : "enable"]({ emitEvent: false, onlySelf: true });
|
|
195
|
+
control.setErrors({ "validationError": code }, { emitEvent: true });
|
|
196
|
+
control.markAsDirty();
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
private dispatchErrors(item: any, errors: BackendValidationError[]): BackendValidationError[] {
|
|
201
|
+
const error = errors.filter((e: BackendValidationError) => {
|
|
202
|
+
return this.itemCache[this.normalizePropertyNames(e.parameters)] === item[this.normalizePropertyNames(e.parameters)];
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
this.store.dispatch(
|
|
206
|
+
createUpdateDetailSetErrorsAction(this.detailsRepository)({ error })
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
return error;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
private normalizePropertyNames(input: string): string {
|
|
213
|
+
return String(input[0]).toLocaleLowerCase() + String(input).slice(1);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
private isStateChanged(item: any): boolean {
|
|
217
|
+
return item !== this.itemCache;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface BaseFormCore {
|
|
2
|
+
label?: string;
|
|
3
|
+
required: boolean;
|
|
4
|
+
readonly: boolean;
|
|
5
|
+
tooltip: string;
|
|
6
|
+
formDisplay: 'flex' | 'block';
|
|
7
|
+
clearable: boolean;
|
|
8
|
+
placeholder?: string
|
|
9
|
+
testId?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface BaseFormDirectiveCore<T> {
|
|
13
|
+
initialData: T | any;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface FormState {
|
|
17
|
+
dirty: boolean;
|
|
18
|
+
valid: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function isFormStateEqual(current: FormState, other: FormState) {
|
|
22
|
+
if (!current && !other) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (current && other) {
|
|
27
|
+
return current.dirty === other.dirty && current.valid === other.valid;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return false;
|
|
31
|
+
}
|
package/{lib/components/base-form/models/index.d.ts → src/lib/components/base-form/models/index.ts}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './base-form-input.models';
|
|
2
|
-
export * from './base-form.models';
|
|
2
|
+
export * from './base-form.models';
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { InjectionToken } from '@angular/core';
|
|
2
2
|
import { ActivatedRoute } from "@angular/router";
|
|
3
3
|
import { MenuItem } from '../side-menu';
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
export const BREADCRUMB_COMPONENT_TOKEN = new InjectionToken<BreadcrumbCore>(
|
|
6
|
+
'BreadcrumbComponentToken'
|
|
7
|
+
);
|
|
8
|
+
|
|
5
9
|
export interface BreadcrumbCore {
|
|
6
10
|
items: MenuItem[];
|
|
7
11
|
homeRoute: string;
|
|
8
12
|
useHomeRoute: boolean;
|
|
9
13
|
}
|
|
14
|
+
|
|
10
15
|
export interface Breadcrumb {
|
|
11
16
|
label: string;
|
|
12
17
|
routerLink?: string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EventEmitter, Injectable, Output } from '@angular/core';
|
|
2
|
+
import { Breadcrumb } from './breadcrumb.model';
|
|
3
|
+
|
|
4
|
+
@Injectable({
|
|
5
|
+
providedIn: 'root',
|
|
6
|
+
})
|
|
7
|
+
export class BreadcrumbService {
|
|
8
|
+
@Output() routeChange: EventEmitter<Breadcrumb> = new EventEmitter();
|
|
9
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectorRef,
|
|
3
|
+
Directive,
|
|
4
|
+
Input,
|
|
5
|
+
inject,
|
|
6
|
+
OnInit,
|
|
7
|
+
} from '@angular/core';
|
|
8
|
+
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
|
|
9
|
+
import { filter, takeUntil } from 'rxjs';
|
|
10
|
+
import { MenuItem } from '../side-menu';
|
|
11
|
+
import { UnsubscribeComponent } from '../unsubscribe.component';
|
|
12
|
+
import { BreadcrumbCore } from './breadcrumb.model';
|
|
13
|
+
import { BreadcrumbService } from './breadcrumb.service';
|
|
14
|
+
|
|
15
|
+
@Directive({
|
|
16
|
+
|
|
17
|
+
})
|
|
18
|
+
export class BreadcrumbCoreComponent
|
|
19
|
+
extends UnsubscribeComponent
|
|
20
|
+
implements BreadcrumbCore, OnInit
|
|
21
|
+
{
|
|
22
|
+
@Input() items: MenuItem[] = [];
|
|
23
|
+
@Input() homeRoute = '/';
|
|
24
|
+
@Input() useHomeRoute = false;
|
|
25
|
+
|
|
26
|
+
static readonly ROUTE_DATA_BREADCRUMB = 'breadcrumb';
|
|
27
|
+
static readonly ROUTE_DATA_BREADCRUMB_URL = 'breadcrumb_url';
|
|
28
|
+
static readonly ROUTE_DATA_NO_BREADCRUMB_ROUTE = 'breadcrumb_no_route';
|
|
29
|
+
static readonly BREADCRUMB_HIDE = 'breadcrumb_hide';
|
|
30
|
+
readonly home = { icon: 'pi pi-home', routerLink: this.homeRoute };
|
|
31
|
+
|
|
32
|
+
router = inject(Router);
|
|
33
|
+
activatedRoute = inject(ActivatedRoute);
|
|
34
|
+
breadcrumbService = inject(BreadcrumbService);
|
|
35
|
+
cdr = inject(ChangeDetectorRef);
|
|
36
|
+
|
|
37
|
+
ngOnInit(): void {
|
|
38
|
+
this.initBreadcrumbsCreation();
|
|
39
|
+
this.initRouteChangeListen();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private initBreadcrumbsCreation() {
|
|
43
|
+
this.router.events
|
|
44
|
+
.pipe(
|
|
45
|
+
filter((event) => event instanceof NavigationEnd),
|
|
46
|
+
takeUntil(this.destroyed$)
|
|
47
|
+
)
|
|
48
|
+
.subscribe(
|
|
49
|
+
() => (this.items = this.createBreadcrumbs(this.activatedRoute.root))
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private initRouteChangeListen() {
|
|
54
|
+
this.breadcrumbService.routeChange
|
|
55
|
+
.pipe(
|
|
56
|
+
filter((x) => x.label !== 'Undefined'),
|
|
57
|
+
takeUntil(this.destroyed$)
|
|
58
|
+
)
|
|
59
|
+
.subscribe((x) => {
|
|
60
|
+
this.items = [
|
|
61
|
+
...this.items,
|
|
62
|
+
{
|
|
63
|
+
label: x.label,
|
|
64
|
+
routerLink: x.routerLink,
|
|
65
|
+
url: x.url,
|
|
66
|
+
class: 'breadcrumb',
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
this.cdr.detectChanges();
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private createBreadcrumbs(
|
|
74
|
+
route: ActivatedRoute,
|
|
75
|
+
routerLink = '',
|
|
76
|
+
breadcrumbs: MenuItem[] = []
|
|
77
|
+
): any {
|
|
78
|
+
const children: ActivatedRoute[] = route.children;
|
|
79
|
+
|
|
80
|
+
if (children.length === 0) {
|
|
81
|
+
return breadcrumbs;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
for (const child of children) {
|
|
85
|
+
const routeURL: string = child.snapshot.url
|
|
86
|
+
.map((segment) => segment.path)
|
|
87
|
+
.join('/');
|
|
88
|
+
|
|
89
|
+
if (!child.snapshot.data[BreadcrumbCoreComponent.BREADCRUMB_HIDE]) {
|
|
90
|
+
if (BreadcrumbCoreComponent.ROUTE_DATA_BREADCRUMB_URL !== undefined) {
|
|
91
|
+
const route =
|
|
92
|
+
child.snapshot.data[BreadcrumbCoreComponent.ROUTE_DATA_BREADCRUMB_URL];
|
|
93
|
+
routerLink += `/${route}`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (!BreadcrumbCoreComponent.ROUTE_DATA_BREADCRUMB_URL && routeURL !== '') {
|
|
97
|
+
routerLink += `/${routeURL}`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const label = child.snapshot.data[BreadcrumbCoreComponent.ROUTE_DATA_BREADCRUMB];
|
|
101
|
+
if (
|
|
102
|
+
label &&
|
|
103
|
+
BreadcrumbCoreComponent.ROUTE_DATA_NO_BREADCRUMB_ROUTE &&
|
|
104
|
+
child.snapshot.data[
|
|
105
|
+
BreadcrumbCoreComponent.ROUTE_DATA_NO_BREADCRUMB_ROUTE
|
|
106
|
+
]
|
|
107
|
+
) {
|
|
108
|
+
breadcrumbs.push({ label, routerLink: undefined });
|
|
109
|
+
} else if (label && child.snapshot.routeConfig?.path !== '') {
|
|
110
|
+
breadcrumbs.push({ label, routerLink: routerLink });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return this.createBreadcrumbs(child, routerLink, breadcrumbs);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
package/{lib/components/button/button.model.d.ts → src/lib/components/button/button.model.ts}
RENAMED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { InjectionToken } from '@angular/core';
|
|
2
2
|
import { Params } from '@angular/router';
|
|
3
3
|
import { ControlSeverityType, FieldSizeType, IconPositionType } from '../../common';
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
export const BUTTON_COMPONENT_TOKEN = new InjectionToken<ButtonCore>(
|
|
6
|
+
'ButtonComponentToken'
|
|
7
|
+
);
|
|
8
|
+
|
|
5
9
|
export interface ButtonCore {
|
|
6
10
|
label?: string;
|
|
7
11
|
icon?: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './button.model';
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { InjectionToken } from '@angular/core';
|
|
2
2
|
import { BaseFormCore } from '../base-form';
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
export const CALENDAR_COMPONENT_TOKEN = new InjectionToken<CalendarCore>(
|
|
5
|
+
'CalendarComponentToken'
|
|
6
|
+
);
|
|
7
|
+
|
|
4
8
|
export interface CalendarCore extends BaseFormCore {
|
|
5
9
|
maxDate: Date;
|
|
6
10
|
icon: string;
|
|
@@ -9,4 +13,4 @@ export interface CalendarCore extends BaseFormCore {
|
|
|
9
13
|
footer: string;
|
|
10
14
|
floatLabel: string | undefined;
|
|
11
15
|
selectionMode: "single" | "multiple" | "range" | undefined;
|
|
12
|
-
}
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './calendar.model';
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { InjectionToken, InputSignal } from '@angular/core';
|
|
2
2
|
import { BaseFormCore } from '../base-form';
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
export const CHECKBOX_COMPONENT_TOKEN = new InjectionToken<CheckboxCore>(
|
|
5
|
+
'CheckboxComponentToken'
|
|
6
|
+
);
|
|
7
|
+
|
|
4
8
|
export interface CheckboxCore extends BaseFormCore {
|
|
5
9
|
indeterminate: InputSignal<boolean>;
|
|
6
10
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './checkbox.model';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { InjectionToken, Type } from '@angular/core';
|
|
2
|
+
import { SafeHtml } from "@angular/platform-browser";
|
|
3
|
+
import { ControlSeverityType } from '../../common';
|
|
4
|
+
|
|
5
|
+
export const CONFIRM_DIALOG_COMPONENT_TOKEN = new InjectionToken<ConfirmDialogCore>(
|
|
6
|
+
'ConfirmDialogComponentToken'
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
export type ConfirmDialogCore = object
|
|
10
|
+
|
|
11
|
+
export interface DialogData {
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './confirm-dialog.model';
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { InjectionToken } from '@angular/core';
|
|
2
2
|
import { DataSourceComponentModel } from '../../common';
|
|
3
3
|
import { BaseFormCore } from '../base-form';
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
export const DROPDOWN_COMPONENT_TOKEN = new InjectionToken<DropdownCore<any>>(
|
|
6
|
+
'DropdownComponentToken'
|
|
7
|
+
);
|
|
8
|
+
|
|
5
9
|
export interface DropdownCore<T> extends DataSourceComponentModel<T>, BaseFormCore {
|
|
6
10
|
dropdownIcon?: string;
|
|
7
11
|
floatLabel?: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dropdown.model';
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { InjectionToken, InputSignal } from "@angular/core";
|
|
2
|
-
import { ControlSeverityType, FieldSizeType } from "../../common";
|
|
3
|
-
import { MenuItem } from "../side-menu";
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { InjectionToken, InputSignal } from "@angular/core";
|
|
2
|
+
import { ControlSeverityType, FieldSizeType } from "../../common";
|
|
3
|
+
import { MenuItem } from "../side-menu";
|
|
4
|
+
|
|
5
|
+
export const DROPDOWN_BUTTON_COMPONENT_TOKEN = new InjectionToken<DropdownButtonCore>(
|
|
6
|
+
'DropdownButtonComponentToken'
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
export interface DropdownButtonCore {
|
|
10
|
+
label: InputSignal<string | undefined>;
|
|
11
|
+
icon: InputSignal<string | undefined>;
|
|
12
|
+
rounded: InputSignal<boolean | undefined>;
|
|
13
|
+
outlined: InputSignal<boolean | undefined>;
|
|
14
|
+
raised: InputSignal<boolean | undefined>;
|
|
15
|
+
severity: InputSignal<ControlSeverityType | undefined>;
|
|
16
|
+
size: InputSignal<FieldSizeType | undefined>;
|
|
17
|
+
items: InputSignal<MenuItem[] | undefined>;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dropdown-button.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
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './filter.model';
|
|
1
|
+
export * from './filter.model';
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { InjectionToken } from '@angular/core';
|
|
2
2
|
import { NgControl } from '@angular/forms';
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
export const FORM_FIELD_COMPONENT_TOKEN = new InjectionToken<FormFieldCore>(
|
|
5
|
+
'FormFieldComponentToken'
|
|
6
|
+
);
|
|
7
|
+
|
|
4
8
|
export interface FormFieldCore {
|
|
5
9
|
ngControl?: NgControl;
|
|
6
10
|
label?: string;
|
|
@@ -8,4 +12,4 @@ export interface FormFieldCore {
|
|
|
8
12
|
required: boolean;
|
|
9
13
|
testId?: string;
|
|
10
14
|
display: 'flex' | 'block';
|
|
11
|
-
}
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './form-field.model';
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { InjectionToken } from '@angular/core';
|
|
2
2
|
import { DataSourceComponentModel } from '../../common';
|
|
3
3
|
import { BaseFormCore } from '../base-form';
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
export const GENERIC_FIELD_COMPONENT_TOKEN = new InjectionToken<GenericFieldCore<any>>(
|
|
6
|
+
'GenericFieldComponentToken'
|
|
7
|
+
);
|
|
8
|
+
|
|
5
9
|
export interface GenericFieldCore<T> extends DataSourceComponentModel<T>, BaseFormCore {
|
|
6
10
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './generic-field.model';
|
|
@@ -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;
|