@verisoft/ui-govcz 20.0.0 → 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 +60 -0
- package/assets/i18n/cs.json +2 -0
- package/assets/i18n/en.json +2 -0
- package/jest.config.ts +21 -0
- package/ng-package.json +28 -0
- package/package.json +9 -19
- package/project.json +49 -0
- package/src/config.d.ts +10 -0
- package/src/index.ts +1 -0
- package/src/lib/components/breadcrumb/breadcrumb.component.html +25 -0
- package/src/lib/components/breadcrumb/breadcrumb.component.scss +0 -0
- package/src/lib/components/breadcrumb/breadcrumb.component.spec.ts +21 -0
- package/src/lib/components/breadcrumb/breadcrumb.component.ts +28 -0
- package/src/lib/components/breadcrumb/index.ts +1 -0
- package/src/lib/components/button/button.component.html +28 -0
- package/src/lib/components/button/button.component.scss +21 -0
- package/src/lib/components/button/button.component.ts +77 -0
- package/src/lib/components/button/index.ts +1 -0
- package/src/lib/components/calendar/calendar.component.html +28 -0
- package/src/lib/components/calendar/calendar.component.scss +0 -0
- package/src/lib/components/calendar/calendar.component.ts +77 -0
- package/src/lib/components/calendar/index.ts +1 -0
- package/src/lib/components/checkbox/checkbox.component.html +23 -0
- package/src/lib/components/checkbox/checkbox.component.scss +0 -0
- package/src/lib/components/checkbox/checkbox.component.ts +61 -0
- package/src/lib/components/checkbox/index.ts +1 -0
- package/src/lib/components/confirm-dialog/confirm-dialog.component.html +50 -0
- package/src/lib/components/confirm-dialog/confirm-dialog.component.scss +4 -0
- package/src/lib/components/confirm-dialog/confirm-dialog.component.ts +79 -0
- package/src/lib/components/confirm-dialog/index.ts +1 -0
- package/src/lib/components/dropdown/dropdown-item.component.html +8 -0
- package/src/lib/components/dropdown/dropdown-item.component.ts +18 -0
- package/src/lib/components/dropdown/dropdown.component.html +91 -0
- package/src/lib/components/dropdown/dropdown.component.scss +108 -0
- package/src/lib/components/dropdown/dropdown.component.spec.ts +21 -0
- package/src/lib/components/dropdown/dropdown.component.ts +296 -0
- package/src/lib/components/dropdown/dropdown.model.ts +6 -0
- package/src/lib/components/dropdown/index.ts +1 -0
- package/src/lib/components/dropdown-button/dropdown-button.component.html +31 -0
- package/src/lib/components/dropdown-button/dropdown-button.component.ts +34 -0
- package/src/lib/components/dropdown-button/index.ts +1 -0
- package/src/lib/components/errors/error.component.html +11 -0
- package/src/lib/components/errors/error.component.scss +0 -0
- package/src/lib/components/errors/error.component.spec.ts +19 -0
- package/src/lib/components/errors/error.component.ts +29 -0
- package/src/lib/components/errors/index.ts +1 -0
- package/src/lib/components/feature-list/directives/feature-list-column.directive.ts +32 -0
- package/src/lib/components/feature-list/directives/feature-list-filter-field.directive.ts +8 -0
- package/src/lib/components/feature-list/feature-list-filter.pipe.ts +20 -0
- package/src/lib/components/feature-list/feature-list-page.component.ts +30 -0
- package/src/lib/components/feature-list/feature-list-page.model.ts +42 -0
- package/src/lib/components/feature-list/feature-list.component.html +67 -0
- package/src/lib/components/feature-list/feature-list.component.scss +10 -0
- package/src/lib/components/feature-list/feature-list.component.ts +360 -0
- package/src/lib/components/feature-list/index.ts +5 -0
- package/src/lib/components/filter/directives/filter-field.directive.ts +35 -0
- package/src/lib/components/filter/filter.component.html +78 -0
- package/src/lib/components/filter/filter.component.scss +32 -0
- package/src/lib/components/filter/filter.component.spec.ts +21 -0
- package/src/lib/components/filter/filter.component.stories.ts +23 -0
- package/src/lib/components/filter/filter.component.ts +286 -0
- package/src/lib/components/filter/filter.model.ts +18 -0
- package/src/lib/components/filter/index.ts +2 -0
- package/src/lib/components/form-field/form-field.component.html +14 -0
- package/src/lib/components/form-field/form-field.component.scss +0 -0
- package/src/lib/components/form-field/form-field.component.spec.ts +21 -0
- package/src/lib/components/form-field/form-field.component.ts +76 -0
- package/src/lib/components/form-field/index.ts +1 -0
- package/src/lib/components/header/header.component.html +122 -0
- package/src/lib/components/header/header.component.scss +0 -0
- package/src/lib/components/header/header.component.ts +90 -0
- package/src/lib/components/header/index.ts +1 -0
- package/src/lib/components/icon/icon.component.html +11 -0
- package/src/lib/components/icon/icon.component.scss +20 -0
- package/src/lib/components/icon/icon.component.ts +110 -0
- package/src/lib/components/icon/index.ts +2 -0
- package/src/lib/components/index.ts +37 -0
- package/src/lib/components/input-group/index.ts +1 -0
- package/src/lib/components/input-group/input-group.component.html +41 -0
- package/src/lib/components/input-group/input-group.component.scss +0 -0
- package/src/lib/components/input-group/input-group.component.ts +75 -0
- package/src/lib/components/loader/index.ts +1 -0
- package/src/lib/components/loader/loader.component.html +7 -0
- package/src/lib/components/loader/loader.component.scss +0 -0
- package/src/lib/components/loader/loader.component.spec.ts +21 -0
- package/src/lib/components/loader/loader.component.ts +33 -0
- package/src/lib/components/multiselect/index.ts +1 -0
- package/src/lib/components/multiselect/multiselect.component.html +21 -0
- package/src/lib/components/multiselect/multiselect.component.scss +0 -0
- package/src/lib/components/multiselect/multiselect.component.spec.ts +21 -0
- package/src/lib/components/multiselect/multiselect.component.ts +117 -0
- package/src/lib/components/number-input/index.ts +1 -0
- package/src/lib/components/number-input/number-input.component.html +48 -0
- package/src/lib/components/number-input/number-input.component.scss +0 -0
- package/src/lib/components/number-input/number-input.component.ts +80 -0
- package/src/lib/components/page-header/index.ts +1 -0
- package/src/lib/components/page-header/page-header.component.html +3 -0
- package/src/lib/components/page-header/page-header.component.scss +11 -0
- package/src/lib/components/page-header/page-header.component.spec.ts +21 -0
- package/src/lib/components/page-header/page-header.component.ts +27 -0
- package/src/lib/components/password/index.ts +1 -0
- package/src/lib/components/password/password.component.html +31 -0
- package/src/lib/components/password/password.component.scss +0 -0
- package/src/lib/components/password/password.component.spec.ts +21 -0
- package/src/lib/components/password/password.component.ts +83 -0
- package/src/lib/components/radiobutton/index.ts +1 -0
- package/src/lib/components/radiobutton/radiobutton.component.html +23 -0
- package/src/lib/components/radiobutton/radiobutton.component.scss +0 -0
- package/src/lib/components/radiobutton/radiobutton.component.ts +61 -0
- package/src/lib/components/search/index.ts +1 -0
- package/src/lib/components/search/search.component.html +23 -0
- package/src/lib/components/search/search.component.scss +0 -0
- package/src/lib/components/search/search.component.ts +45 -0
- package/src/lib/components/section/index.ts +1 -0
- package/src/lib/components/section/section.component.html +26 -0
- package/src/lib/components/section/section.component.scss +0 -0
- package/src/lib/components/section/section.component.ts +55 -0
- package/src/lib/components/side-menu/index.ts +2 -0
- package/src/lib/components/side-menu/side-menu.component.html +22 -0
- package/src/lib/components/side-menu/side-menu.component.scss +17 -0
- package/src/lib/components/side-menu/side-menu.component.ts +42 -0
- package/src/lib/components/side-menu/side-menu.module.ts +56 -0
- package/src/lib/components/snackbar/index.ts +2 -0
- package/src/lib/components/snackbar/services/snackbar.service.ts +73 -0
- package/src/lib/components/snackbar/snackbar.component.html +14 -0
- package/src/lib/components/snackbar/snackbar.component.scss +0 -0
- package/src/lib/components/snackbar/snackbar.component.spec.ts +21 -0
- package/src/lib/components/snackbar/snackbar.component.ts +44 -0
- package/src/lib/components/snackbar/snackbar.model.ts +10 -0
- package/src/lib/components/stepper/index.ts +1 -0
- package/src/lib/components/stepper/stepper.component.html +35 -0
- package/src/lib/components/stepper/stepper.component.scss +9 -0
- package/src/lib/components/stepper/stepper.component.ts +60 -0
- package/src/lib/components/switch/index.ts +1 -0
- package/src/lib/components/switch/switch.component.html +16 -0
- package/src/lib/components/switch/switch.component.scss +0 -0
- package/src/lib/components/switch/switch.component.ts +39 -0
- package/src/lib/components/tab-view/index.ts +2 -0
- package/src/lib/components/tab-view/tab-view-item.component.ts +23 -0
- package/src/lib/components/tab-view/tab-view.component.html +51 -0
- package/src/lib/components/tab-view/tab-view.component.scss +43 -0
- package/src/lib/components/tab-view/tab-view.component.ts +64 -0
- package/src/lib/components/tab-view/tab-view.module.ts +25 -0
- package/src/lib/components/table/index.ts +1 -0
- package/src/lib/components/table/table-pagination-info.component.html +9 -0
- package/src/lib/components/table/table-pagination-info.component.ts +22 -0
- package/src/lib/components/table/table.component.html +199 -0
- package/src/lib/components/table/table.component.scss +192 -0
- package/src/lib/components/table/table.component.ts +390 -0
- package/src/lib/components/table/table.model.ts +17 -0
- package/src/lib/components/table/table.models.ts +12 -0
- package/src/lib/components/tag/index.ts +3 -0
- package/src/lib/components/tag/tag.component.html +12 -0
- package/src/lib/components/tag/tag.component.scss +4 -0
- package/src/lib/components/tag/tag.component.ts +44 -0
- package/src/lib/components/tag/tag.model.ts +7 -0
- package/src/lib/components/textarea/index.ts +1 -0
- package/src/lib/components/textarea/textarea.component.html +50 -0
- package/src/lib/components/textarea/textarea.component.scss +0 -0
- package/src/lib/components/textarea/textarea.component.ts +77 -0
- package/src/lib/components/textfield/index.ts +1 -0
- package/src/lib/components/textfield/textfield.component.html +34 -0
- package/src/lib/components/textfield/textfield.component.scss +0 -0
- package/src/lib/components/textfield/textfield.component.ts +112 -0
- package/src/lib/components/tooltip/index.ts +1 -0
- package/src/lib/components/tooltip/tooltip.component.html +9 -0
- package/src/lib/components/tooltip/tooltip.component.ts +19 -0
- package/src/lib/icons.ts +36 -0
- package/src/lib/index.ts +5 -0
- package/src/lib/init.service.ts +11 -0
- package/src/lib/interceptors/http-error-message.interceptor.ts +45 -0
- package/src/lib/pages/bad-request-page/bad-request-page.component.html +5 -0
- package/src/lib/pages/bad-request-page/bad-request-page.component.scss +0 -0
- package/src/lib/pages/bad-request-page/bad-request-page.component.ts +14 -0
- package/src/lib/pages/error-page/error-page.component.html +5 -0
- package/src/lib/pages/error-page/error-page.component.scss +0 -0
- package/src/lib/pages/error-page/error-page.component.ts +31 -0
- package/src/lib/pages/error-page/error-page.constants.ts +19 -0
- package/src/lib/pages/index.ts +3 -0
- package/src/lib/pages/internal-server-error-page/internal-server-error-page.component.html +5 -0
- package/src/lib/pages/internal-server-error-page/internal-server-error-page.component.scss +0 -0
- package/src/lib/pages/internal-server-error-page/internal-server-error-page.component.ts +15 -0
- package/src/lib/pages/not-authenticated/index.ts +1 -0
- package/src/lib/pages/not-authenticated/not-authenticated.component.html +5 -0
- package/src/lib/pages/not-authenticated/not-authenticated.component.ts +13 -0
- package/src/lib/pages/not-authorized/index.ts +1 -0
- package/src/lib/pages/not-authorized/not-authorized.component.html +5 -0
- package/src/lib/pages/not-authorized/not-authorized.component.ts +17 -0
- package/src/lib/pages/not-found/index.ts +1 -0
- package/src/lib/pages/not-found/not-found.component.html +5 -0
- package/src/lib/pages/not-found/not-found.component.ts +17 -0
- package/src/lib/pages/not-found-page/not-found-page.component.html +6 -0
- package/src/lib/pages/not-found-page/not-found-page.component.scss +0 -0
- package/src/lib/pages/not-found-page/not-found-page.component.ts +15 -0
- package/src/lib/pipes/color/color.pipe.ts +24 -0
- package/src/lib/pipes/index.ts +3 -0
- package/src/lib/pipes/multiselect/multiselect-options.pipe.ts +61 -0
- package/src/lib/pipes/size/size.pipe.ts +24 -0
- package/src/sass/foundations/_colors.scss +4 -0
- package/src/sass/foundations/index.scss +1 -0
- package/src/sass/integrations/_bootstrap.scss +4 -0
- package/src/sass/integrations/index.scss +1 -0
- package/src/sass/main.scss +12 -0
- package/src/sass/overrides/_gov.scss +4 -0
- package/src/sass/overrides/index.scss +1 -0
- package/src/sass/tokens/_theme-dark.scss +18 -0
- package/src/sass/tokens/_theme-light.scss +9 -0
- package/src/sass/tokens/index.scss +3 -0
- package/src/sass/utils/_table_filter.scss +4 -0
- package/src/sass/utils/index.scss +2 -0
- package/{styles → src}/sass/vendors/_bootstrap.scss +1 -0
- package/src/test-setup.ts +8 -0
- package/tsconfig.json +30 -0
- package/tsconfig.lib.json +17 -0
- package/tsconfig.lib.prod.json +9 -0
- package/tsconfig.spec.json +16 -0
- package/fesm2022/verisoft-ui-govcz.mjs +0 -3582
- package/fesm2022/verisoft-ui-govcz.mjs.map +0 -1
- package/index.d.ts +0 -955
- package/styles/dist/main.css +0 -9
- package/styles/dist/main.css.map +0 -1
- package/styles/sass/main.scss +0 -10
- package/styles/sass/utils/_variables.scss +0 -3
- package/styles/sass/utils/index.scss +0 -2
- /package/{styles → src}/sass/header.css +0 -0
- /package/{styles → src}/sass/header.scss +0 -0
- /package/{styles → src}/sass/scrollbar.scss +0 -0
- /package/{styles → src}/sass/utils/_utils.scss +0 -0
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
import { CommonModule, NgTemplateOutlet } from '@angular/common';
|
|
2
|
+
import {
|
|
3
|
+
AfterViewInit,
|
|
4
|
+
ChangeDetectionStrategy,
|
|
5
|
+
ChangeDetectorRef,
|
|
6
|
+
Component,
|
|
7
|
+
ContentChild,
|
|
8
|
+
ContentChildren,
|
|
9
|
+
effect,
|
|
10
|
+
EventEmitter,
|
|
11
|
+
inject,
|
|
12
|
+
Input,
|
|
13
|
+
OnChanges,
|
|
14
|
+
Output,
|
|
15
|
+
QueryList,
|
|
16
|
+
SimpleChanges,
|
|
17
|
+
TemplateRef,
|
|
18
|
+
} from '@angular/core';
|
|
19
|
+
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
|
|
20
|
+
import { GovDesignSystemModule } from '@gov-design-system-ce/angular';
|
|
21
|
+
import {
|
|
22
|
+
FormCheckboxEvent,
|
|
23
|
+
FormSelectEvent,
|
|
24
|
+
} from '@gov-design-system-ce/components';
|
|
25
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
26
|
+
import {
|
|
27
|
+
DEFAULT_SEARCH_LIMIT,
|
|
28
|
+
LazyLoadEvent,
|
|
29
|
+
multiSort,
|
|
30
|
+
Sort,
|
|
31
|
+
SortDirectionType,
|
|
32
|
+
} from '@verisoft/core';
|
|
33
|
+
import {
|
|
34
|
+
ColumnDefinition,
|
|
35
|
+
ColumnModel,
|
|
36
|
+
ColumnProvider,
|
|
37
|
+
DEFAULT_PAGINATION,
|
|
38
|
+
FieldSize,
|
|
39
|
+
FieldSizeType,
|
|
40
|
+
MAX_COLUMN_CHAR_COUNT,
|
|
41
|
+
RowModel,
|
|
42
|
+
TABLE_COLUMN_PROVIDER,
|
|
43
|
+
TABLE_COMPONENT_TOKEN,
|
|
44
|
+
TableCore,
|
|
45
|
+
TableSelectionMode,
|
|
46
|
+
TableService,
|
|
47
|
+
} from '@verisoft/ui-core';
|
|
48
|
+
import { Icons } from '../../icons';
|
|
49
|
+
import { GovSizePipe } from '../../pipes';
|
|
50
|
+
import { LoaderComponent } from '../loader';
|
|
51
|
+
import { TablePaginationInfoComponent } from './table-pagination-info.component';
|
|
52
|
+
import { getNextSortDirection } from './table.model';
|
|
53
|
+
|
|
54
|
+
@Component({
|
|
55
|
+
selector: 'v-table',
|
|
56
|
+
imports: [
|
|
57
|
+
CommonModule,
|
|
58
|
+
RouterModule,
|
|
59
|
+
GovDesignSystemModule,
|
|
60
|
+
NgTemplateOutlet,
|
|
61
|
+
TranslateModule,
|
|
62
|
+
GovSizePipe,
|
|
63
|
+
LoaderComponent,
|
|
64
|
+
TablePaginationInfoComponent,
|
|
65
|
+
],
|
|
66
|
+
templateUrl: './table.component.html',
|
|
67
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
68
|
+
styleUrl: './table.component.scss',
|
|
69
|
+
providers: [
|
|
70
|
+
{
|
|
71
|
+
provide: TABLE_COMPONENT_TOKEN,
|
|
72
|
+
useExisting: TableComponent,
|
|
73
|
+
},
|
|
74
|
+
]
|
|
75
|
+
})
|
|
76
|
+
export class TableComponent<T>
|
|
77
|
+
implements OnChanges, AfterViewInit, TableCore<T>
|
|
78
|
+
{
|
|
79
|
+
@ContentChildren(TABLE_COLUMN_PROVIDER)
|
|
80
|
+
viewColumns!: QueryList<ColumnProvider<T>>;
|
|
81
|
+
|
|
82
|
+
@ContentChild('rowDetail', { static: false })
|
|
83
|
+
rowDetailTemplate!: TemplateRef<{ $implicit: T }>;
|
|
84
|
+
|
|
85
|
+
@ContentChild('rowDetailButton', { static: false })
|
|
86
|
+
rowDetailButtonTemplate!: TemplateRef<{ $implicit: T }>;
|
|
87
|
+
|
|
88
|
+
@Input() sorters!: Sort[];
|
|
89
|
+
@Input() data!: T[];
|
|
90
|
+
@Input() total = 0;
|
|
91
|
+
@Input() filter: Partial<T> | undefined;
|
|
92
|
+
@Input() extraFilter: Partial<T> | undefined;
|
|
93
|
+
@Input() loading = false;
|
|
94
|
+
@Input() scrollable = true;
|
|
95
|
+
@Input() pageSize = DEFAULT_SEARCH_LIMIT;
|
|
96
|
+
@Input() currentPage = 1;
|
|
97
|
+
@Input() showPaginator = true;
|
|
98
|
+
@Input() userTableWrapper = true;
|
|
99
|
+
@Input() sortMultiple = false;
|
|
100
|
+
@Input() lazy = false;
|
|
101
|
+
@Input() selectionMode: 'single' | 'multiple' | undefined;
|
|
102
|
+
@Input() selection: T[] = [];
|
|
103
|
+
@Input() showPageSizePicker = true;
|
|
104
|
+
@Input() entityKey: string | undefined;
|
|
105
|
+
@Input() customRoute: string | undefined;
|
|
106
|
+
@Input() disableCustomClicks = false;
|
|
107
|
+
@Input() tableName?: string;
|
|
108
|
+
@Input() size: FieldSizeType = FieldSize.medium;
|
|
109
|
+
@Input() showActionButtons = false;
|
|
110
|
+
@Input() maximumColumnLength = MAX_COLUMN_CHAR_COUNT;
|
|
111
|
+
|
|
112
|
+
@Input()
|
|
113
|
+
set columns(value: ColumnDefinition<T>[]) {
|
|
114
|
+
this._columns = value;
|
|
115
|
+
this.updateColumnModels();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
get columns(): ColumnDefinition<T>[] {
|
|
119
|
+
return this._columns;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@Output() selectionChange = new EventEmitter<T[]>();
|
|
123
|
+
@Output() lazyLoad = new EventEmitter<LazyLoadEvent>();
|
|
124
|
+
@Output() download = new EventEmitter<RowModel<T>[]>();
|
|
125
|
+
@Output() delete = new EventEmitter<RowModel<T>[]>();
|
|
126
|
+
@Output() save = new EventEmitter<RowModel<T>[]>();
|
|
127
|
+
|
|
128
|
+
private readonly cdRef = inject(ChangeDetectorRef);
|
|
129
|
+
private readonly router = inject(Router);
|
|
130
|
+
private readonly route = inject(ActivatedRoute);
|
|
131
|
+
private readonly service = inject(TableService);
|
|
132
|
+
private _columns: ColumnDefinition<T, keyof T>[] = [];
|
|
133
|
+
|
|
134
|
+
tableColumns: ColumnModel<T>[] = [];
|
|
135
|
+
tableRows: RowModel<T>[] = [];
|
|
136
|
+
pageSizeOptions = DEFAULT_PAGINATION.map((x: number) => ({ value: x.toString() }));
|
|
137
|
+
allSelected = false;
|
|
138
|
+
icons = Icons;
|
|
139
|
+
|
|
140
|
+
get govPageSize() {
|
|
141
|
+
return this.pageSize.toString();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
get tableRowView(): RowModel<T>[] {
|
|
145
|
+
if (this.lazy) {
|
|
146
|
+
return this.tableRows;
|
|
147
|
+
} else {
|
|
148
|
+
const start = (this.currentPage - 1) * this.pageSize;
|
|
149
|
+
const end = start + this.pageSize;
|
|
150
|
+
return this.tableRows.slice(start, end);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
get selected(): RowModel<T>[] {
|
|
155
|
+
return this.tableRows.filter(r => r.selected);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
get selectedCount(): number {
|
|
159
|
+
return this.selected.length;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
constructor() {
|
|
163
|
+
effect(() => {
|
|
164
|
+
this.reactToSignals();
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
ngOnChanges(changes: SimpleChanges): void {
|
|
169
|
+
if (changes['data']) {
|
|
170
|
+
this.updateRowModels();
|
|
171
|
+
if (!this.lazy && this.data) {
|
|
172
|
+
this.total = this.data.length;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (changes['total']) {
|
|
177
|
+
this.cdRef.markForCheck();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (changes['selection']) {
|
|
181
|
+
this.selectSelected();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (changes['filter']) {
|
|
185
|
+
this.updateFilter();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
ngAfterViewInit(): void {
|
|
190
|
+
if (this.viewColumns?.length) {
|
|
191
|
+
this.updateColumnModels();
|
|
192
|
+
this.cdRef.detectChanges();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
protected sortColumn(column: ColumnModel<T>) {
|
|
197
|
+
if (column.sortable) {
|
|
198
|
+
column.sortDirection = getNextSortDirection(
|
|
199
|
+
column.sortDirection,
|
|
200
|
+
this.sortMultiple
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
if (!this.sortMultiple) {
|
|
204
|
+
this.tableColumns
|
|
205
|
+
.filter((x) => x !== column)
|
|
206
|
+
.forEach((x) => {
|
|
207
|
+
x.sortDirection = undefined;
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const sorts: Sort[] = this.getSorts().map((x) => ({
|
|
212
|
+
field: 'row.' + x.field,
|
|
213
|
+
direction: x.direction,
|
|
214
|
+
}));
|
|
215
|
+
|
|
216
|
+
if (!this.lazy) {
|
|
217
|
+
this.tableRows = multiSort(this.tableRows, sorts);
|
|
218
|
+
} else {
|
|
219
|
+
this.fireLazyLoad();
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
protected changePage(event: { detail: { pagination: { currentPage: number } } }) {
|
|
225
|
+
this.currentPage = event.detail.pagination.currentPage;
|
|
226
|
+
this.fireLazyLoad();
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
protected changePageSize(event: CustomEvent<FormSelectEvent>) {
|
|
230
|
+
this.pageSize = parseInt(event.detail.value);
|
|
231
|
+
this.currentPage = 1;
|
|
232
|
+
this.fireLazyLoad();
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
protected selectRow(row: RowModel<T>, event: MouseEvent) {
|
|
236
|
+
if (event.ctrlKey || event.metaKey) {
|
|
237
|
+
this.navigate(row, event);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (this.selectionMode === 'single') {
|
|
242
|
+
row.selected = !row.selected;
|
|
243
|
+
this.tableRows.forEach((x) => (x !== row ? (x.selected = false) : null));
|
|
244
|
+
this.fireSelectionChange();
|
|
245
|
+
} else if (this.selectionMode === 'multiple') {
|
|
246
|
+
row.selected = !row.selected;
|
|
247
|
+
this.fireSelectionChange();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
protected navigate(row: RowModel<T>, event: MouseEvent) {
|
|
252
|
+
if (this.disableCustomClicks) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
event.preventDefault();
|
|
257
|
+
const targetUrl = this.createUrl(row);
|
|
258
|
+
|
|
259
|
+
if (event.ctrlKey || event.metaKey) {
|
|
260
|
+
setTimeout(() => {
|
|
261
|
+
window.open(
|
|
262
|
+
this.router.serializeUrl(this.router.createUrlTree([targetUrl], { relativeTo: this.route })),
|
|
263
|
+
'_blank'
|
|
264
|
+
);
|
|
265
|
+
}, 0);
|
|
266
|
+
} else {
|
|
267
|
+
this.router.navigate([targetUrl], { relativeTo: this.route });
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
protected navigateNewWindow(row: RowModel<T>, event: MouseEvent) {
|
|
272
|
+
if (this.disableCustomClicks || event.button !== 1) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
event.preventDefault();
|
|
277
|
+
const targetUrl = this.createUrl(row);
|
|
278
|
+
|
|
279
|
+
window.open(this.router.serializeUrl(this.router.createUrlTree([targetUrl], { relativeTo: this.route })), '_blank');
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
protected toggleAll(event: CustomEvent<FormCheckboxEvent>) {
|
|
283
|
+
this.allSelected = event.detail.checked;
|
|
284
|
+
this.tableRows.forEach((x) => (x.selected = this.allSelected));
|
|
285
|
+
this.fireSelectionChange();
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
protected toggleDetail(row: RowModel<T>) {
|
|
289
|
+
row.expanded = !row.expanded;
|
|
290
|
+
this.cdRef.detectChanges();
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
protected selectRowCheckbox(row: RowModel<T>, event: CustomEvent<FormCheckboxEvent>) {
|
|
294
|
+
row.selected = event.detail.checked;
|
|
295
|
+
this.allSelected = this.tableRows.every((x) => x.selected);
|
|
296
|
+
this.fireSelectionChange();
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
protected truncate(text: string): string {
|
|
300
|
+
return text.length > this.maximumColumnLength
|
|
301
|
+
? text.slice(0, this.maximumColumnLength) + '...'
|
|
302
|
+
: text;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
protected deselectAll() {
|
|
306
|
+
this.allSelected = false;
|
|
307
|
+
this.tableRows.forEach(x => (x.selected = this.allSelected));
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
private createUrl(row: RowModel<T>): string {
|
|
311
|
+
if (row.customRoute) {
|
|
312
|
+
return row.customRoute;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return row.id.toString();
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
private reactToSignals(): void {
|
|
319
|
+
const reload = this.service.reload();
|
|
320
|
+
|
|
321
|
+
if (typeof reload === 'symbol') {
|
|
322
|
+
this.fireLazyLoad();
|
|
323
|
+
} else if (reload.name === this.tableName) {
|
|
324
|
+
this.fireLazyLoad()
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
this.deselectAll();
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
private updateColumnModels() {
|
|
331
|
+
const viewColumns = this.viewColumns
|
|
332
|
+
?.toArray()
|
|
333
|
+
.map((x) => x.getDefinition());
|
|
334
|
+
this.tableColumns = [...(this._columns ?? []), ...(viewColumns ?? [])].map(
|
|
335
|
+
(x) => new ColumnModel(x)
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
private updateRowModels(): void {
|
|
340
|
+
this.tableRows = (this.data ?? []).map(
|
|
341
|
+
(x) => new RowModel(x, false, false, undefined, undefined, undefined, this.customRoute, this.entityKey)
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
private fireSelectionChange() {
|
|
346
|
+
const selectedRows = this.tableRows
|
|
347
|
+
.filter((x) => x.selected)
|
|
348
|
+
.map((x) => x.row);
|
|
349
|
+
this.selectionChange.emit(selectedRows);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
private selectSelected() {
|
|
353
|
+
if (this.selection?.length && this.selectionMode) {
|
|
354
|
+
const selection =
|
|
355
|
+
this.selectionMode === TableSelectionMode.single
|
|
356
|
+
? [this.selection[0]]
|
|
357
|
+
: this.selection;
|
|
358
|
+
const selectionSet = new Set(selection);
|
|
359
|
+
this.tableRows.forEach((item) => {
|
|
360
|
+
item.selected = selectionSet.has(item.row);
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
this.allSelected = this.tableRows.every((x) => x.selected);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
private fireLazyLoad() {
|
|
368
|
+
const lazyLoadEvent: LazyLoadEvent = {
|
|
369
|
+
sort: this.getSorts(),
|
|
370
|
+
offset: (this.currentPage - 1) * this.pageSize,
|
|
371
|
+
limit: this.pageSize,
|
|
372
|
+
filter: this.filter,
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
this.lazyLoad.emit(lazyLoadEvent);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
private updateFilter() {
|
|
379
|
+
this.fireLazyLoad();
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
private getSorts(): Sort[] {
|
|
383
|
+
return this.tableColumns
|
|
384
|
+
.filter((x) => x.sortable && x.sortDirection)
|
|
385
|
+
.map((x) => ({
|
|
386
|
+
field: x.id,
|
|
387
|
+
direction: <SortDirectionType>x.sortDirection,
|
|
388
|
+
}));
|
|
389
|
+
}
|
|
390
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SortDirection, SortDirectionType } from '@verisoft/core';
|
|
2
|
+
|
|
3
|
+
export function getNextSortDirection(
|
|
4
|
+
sortDirection: SortDirectionType | undefined,
|
|
5
|
+
isNullable = false
|
|
6
|
+
): SortDirectionType | undefined {
|
|
7
|
+
return isNullable && sortDirection === SortDirection.desc
|
|
8
|
+
? undefined
|
|
9
|
+
: !sortDirection || sortDirection === SortDirection.desc
|
|
10
|
+
? SortDirection.asc
|
|
11
|
+
: SortDirection.desc;
|
|
12
|
+
}
|
|
13
|
+
export function createCustomRoute<T>(row: T, entityKey?: string, customRoute?: string) {
|
|
14
|
+
return customRoute && entityKey
|
|
15
|
+
? customRoute + (row as { [key: string]: string })[entityKey]
|
|
16
|
+
: undefined;
|
|
17
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SortDirection, SortDirectionType } from '@verisoft/core';
|
|
2
|
+
|
|
3
|
+
export function getNextSortDirection(
|
|
4
|
+
sortDirection: SortDirectionType | undefined,
|
|
5
|
+
isNullable = false
|
|
6
|
+
): SortDirectionType | undefined {
|
|
7
|
+
return isNullable && sortDirection === SortDirection.desc
|
|
8
|
+
? undefined
|
|
9
|
+
: !sortDirection || sortDirection === SortDirection.desc
|
|
10
|
+
? SortDirection.asc
|
|
11
|
+
: SortDirection.desc;
|
|
12
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
input,
|
|
5
|
+
} from "@angular/core";
|
|
6
|
+
import { GovDesignSystemModule } from "@gov-design-system-ce/angular";
|
|
7
|
+
import { TranslateModule } from "@ngx-translate/core";
|
|
8
|
+
import {
|
|
9
|
+
ControlSeverity,
|
|
10
|
+
ControlSeverityType,
|
|
11
|
+
FieldSize,
|
|
12
|
+
FieldSizeType,
|
|
13
|
+
TagCore,
|
|
14
|
+
TAG_COMPONENT_TOKEN,
|
|
15
|
+
TagVariant,
|
|
16
|
+
} from "@verisoft/ui-core";
|
|
17
|
+
import { GovColorPipe, GovSizePipe } from "../../pipes";
|
|
18
|
+
import { GovTagType } from "./tag.model";
|
|
19
|
+
|
|
20
|
+
@Component({
|
|
21
|
+
selector: "v-tag",
|
|
22
|
+
styleUrl: "./tag.component.scss",
|
|
23
|
+
templateUrl: './tag.component.html',
|
|
24
|
+
imports: [
|
|
25
|
+
GovDesignSystemModule,
|
|
26
|
+
GovSizePipe,
|
|
27
|
+
GovColorPipe,
|
|
28
|
+
TranslateModule
|
|
29
|
+
],
|
|
30
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
31
|
+
providers: [
|
|
32
|
+
{
|
|
33
|
+
provide: TAG_COMPONENT_TOKEN,
|
|
34
|
+
useExisting: TagComponent,
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
})
|
|
38
|
+
export class TagComponent implements TagCore {
|
|
39
|
+
label = input<string | undefined>();
|
|
40
|
+
severity = input<ControlSeverityType | undefined>(ControlSeverity.primary);
|
|
41
|
+
variant = input<TagVariant>(GovTagType.bold);
|
|
42
|
+
size = input<FieldSizeType>(FieldSize.medium);
|
|
43
|
+
}
|
|
44
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './textarea.component';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<gov-form-control class="mb-3">
|
|
2
|
+
@if (label) {
|
|
3
|
+
<gov-form-label
|
|
4
|
+
[slot]="labelSlot"
|
|
5
|
+
[size]="size | govSize"
|
|
6
|
+
>
|
|
7
|
+
{{ label | translate }}
|
|
8
|
+
</gov-form-label>
|
|
9
|
+
}
|
|
10
|
+
<gov-form-group>
|
|
11
|
+
<gov-form-input [type]="type"
|
|
12
|
+
[formControl]="formControl"
|
|
13
|
+
[minlength]="minlength"
|
|
14
|
+
[maxlength]="maxlength"
|
|
15
|
+
[size]='size | govSize'
|
|
16
|
+
[name]='name'
|
|
17
|
+
[role]='role'
|
|
18
|
+
[required]="required"
|
|
19
|
+
[readonly]="readonly"
|
|
20
|
+
[invalid]="ngControl?.errors ? true : false"
|
|
21
|
+
[multiline]="true"
|
|
22
|
+
[rows]="rows"
|
|
23
|
+
[cols]="cols"
|
|
24
|
+
>
|
|
25
|
+
@if (icon) {
|
|
26
|
+
<gov-icon
|
|
27
|
+
[name]="icon"
|
|
28
|
+
[slot]="iconPos === 'left' ? 'icon-start' : 'icon-end'"
|
|
29
|
+
/>
|
|
30
|
+
} @if (prefix) {
|
|
31
|
+
<p slot="prefix">
|
|
32
|
+
{{ prefix }}
|
|
33
|
+
</p>
|
|
34
|
+
} @if (sufix) {
|
|
35
|
+
<p slot="sufix">
|
|
36
|
+
{{ sufix }}
|
|
37
|
+
</p>
|
|
38
|
+
}
|
|
39
|
+
</gov-form-input>
|
|
40
|
+
</gov-form-group>
|
|
41
|
+
<v-validation-message [ngControl]="ngControl"></v-validation-message>
|
|
42
|
+
@if (message) {
|
|
43
|
+
<gov-form-message
|
|
44
|
+
[slot]="messageSlot"
|
|
45
|
+
color="neutral"
|
|
46
|
+
>
|
|
47
|
+
{{ message | translate }}
|
|
48
|
+
</gov-form-message>
|
|
49
|
+
}
|
|
50
|
+
</gov-form-control>
|
|
File without changes
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
|
|
2
|
+
import {
|
|
3
|
+
ChangeDetectionStrategy,
|
|
4
|
+
Component,
|
|
5
|
+
Input,
|
|
6
|
+
Optional,
|
|
7
|
+
Self,
|
|
8
|
+
} from '@angular/core';
|
|
9
|
+
import {
|
|
10
|
+
ControlValueAccessor,
|
|
11
|
+
NgControl,
|
|
12
|
+
ReactiveFormsModule,
|
|
13
|
+
} from '@angular/forms';
|
|
14
|
+
import { GovDesignSystemModule } from '@gov-design-system-ce/angular';
|
|
15
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
16
|
+
import {
|
|
17
|
+
TextfieldCore,
|
|
18
|
+
FieldType,
|
|
19
|
+
BaseFormInputComponent,
|
|
20
|
+
FieldSizeType,
|
|
21
|
+
FieldSize,
|
|
22
|
+
IconPositionType,
|
|
23
|
+
IconPosition,
|
|
24
|
+
SlotPositionType,
|
|
25
|
+
SlotPosition,
|
|
26
|
+
TEXTAREA_COMPONENT_TOKEN,
|
|
27
|
+
TextareaCore,
|
|
28
|
+
} from '@verisoft/ui-core';
|
|
29
|
+
import { Icons } from '../../icons';
|
|
30
|
+
import { GovSizePipe } from '../../pipes';
|
|
31
|
+
import { ErrorComponent } from '../errors';
|
|
32
|
+
@Component({
|
|
33
|
+
selector: 'v-textarea',
|
|
34
|
+
imports: [
|
|
35
|
+
ReactiveFormsModule,
|
|
36
|
+
GovDesignSystemModule,
|
|
37
|
+
GovSizePipe,
|
|
38
|
+
ErrorComponent,
|
|
39
|
+
TranslateModule
|
|
40
|
+
],
|
|
41
|
+
templateUrl: './textarea.component.html',
|
|
42
|
+
styleUrl: './textarea.component.scss',
|
|
43
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
44
|
+
providers: [
|
|
45
|
+
{
|
|
46
|
+
provide: TEXTAREA_COMPONENT_TOKEN,
|
|
47
|
+
useExisting: TextareaComponent,
|
|
48
|
+
},
|
|
49
|
+
]
|
|
50
|
+
})
|
|
51
|
+
export class TextareaComponent
|
|
52
|
+
extends BaseFormInputComponent
|
|
53
|
+
implements ControlValueAccessor, TextareaCore {
|
|
54
|
+
@Input() floatLabel!: string | undefined;
|
|
55
|
+
@Input() type = FieldType.text;
|
|
56
|
+
@Input() minlength = 0;
|
|
57
|
+
@Input() maxlength = 524288;
|
|
58
|
+
@Input() prefix!: string;
|
|
59
|
+
@Input() sufix!: string;
|
|
60
|
+
@Input() message!: string;
|
|
61
|
+
@Input() name!: string;
|
|
62
|
+
@Input() role!: string;
|
|
63
|
+
@Input() size: FieldSizeType = FieldSize.medium;
|
|
64
|
+
@Input() icon!: string;
|
|
65
|
+
@Input() iconPos: IconPositionType = IconPosition.right;
|
|
66
|
+
@Input() labelSlot: SlotPositionType = SlotPosition.top;
|
|
67
|
+
@Input() messageSlot: SlotPositionType = SlotPosition.bottom;
|
|
68
|
+
@Input() rows = 0;
|
|
69
|
+
@Input() cols = 0;
|
|
70
|
+
@Input() autoResize = false;
|
|
71
|
+
|
|
72
|
+
icons = Icons;
|
|
73
|
+
|
|
74
|
+
constructor(@Optional() @Self() ngControl: NgControl) {
|
|
75
|
+
super(ngControl);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './textfield.component';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<gov-form-control>
|
|
2
|
+
@if (label) {
|
|
3
|
+
<gov-form-label [slot]="labelSlot" [size]="size | govSize">
|
|
4
|
+
{{ label | translate }}
|
|
5
|
+
@if (tooltip) {
|
|
6
|
+
<v-tooltip [tooltipText]="tooltip | translate" />
|
|
7
|
+
}
|
|
8
|
+
</gov-form-label>
|
|
9
|
+
}
|
|
10
|
+
<gov-form-group>
|
|
11
|
+
<gov-form-input [inputType]="type" [formControl]="formControl" [minlength]="minlength" [maxlength]="maxlength"
|
|
12
|
+
[min]="min" [max]="max" [size]='size | govSize' [name]='name' [role]='role' [required]="required"
|
|
13
|
+
[attr.disabled]="disabled ? 'true' : 'false'" [invalid]="ngControl?.errors ? true : false"
|
|
14
|
+
[placeholder]="placeholder">
|
|
15
|
+
@if (icon) {
|
|
16
|
+
<gov-icon [name]="icon" [slot]="iconPos === 'left' ? 'icon-start' : 'icon-end'" />
|
|
17
|
+
} @if (prefix) {
|
|
18
|
+
<p slot="prefix">
|
|
19
|
+
{{ prefix }}
|
|
20
|
+
</p>
|
|
21
|
+
} @if (sufix) {
|
|
22
|
+
<p slot="sufix">
|
|
23
|
+
{{ sufix }}
|
|
24
|
+
</p>
|
|
25
|
+
}
|
|
26
|
+
</gov-form-input>
|
|
27
|
+
<v-validation-message [ngControl]="ngControl" />
|
|
28
|
+
@if (message) {
|
|
29
|
+
<gov-form-message [slot]="messageSlot" color="neutral">
|
|
30
|
+
{{ message }}
|
|
31
|
+
</gov-form-message>
|
|
32
|
+
}
|
|
33
|
+
</gov-form-group>
|
|
34
|
+
</gov-form-control>
|
|
File without changes
|