@verisoft/ui-primeng 20.0.0 → 20.1.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.
Files changed (219) hide show
  1. package/.eslintrc.json +43 -0
  2. package/assets/.gitkeep +0 -0
  3. package/jest.config.ts +22 -0
  4. package/ng-package.json +14 -0
  5. package/package.json +6 -18
  6. package/project.json +36 -0
  7. package/src/index.ts +34 -0
  8. package/src/lib/components/breadcrumb/breadcrumb.component.html +11 -0
  9. package/src/lib/components/breadcrumb/breadcrumb.component.scss +18 -0
  10. package/src/lib/components/breadcrumb/breadcrumb.component.spec.ts +21 -0
  11. package/src/lib/components/breadcrumb/breadcrumb.component.stories.ts +36 -0
  12. package/src/lib/components/breadcrumb/breadcrumb.component.ts +27 -0
  13. package/src/lib/components/breadcrumb/breadcrumb.pipe.ts +13 -0
  14. package/src/lib/components/breadcrumb/index.ts +1 -0
  15. package/src/lib/components/button/button-severity.pipe.ts +20 -0
  16. package/src/lib/components/button/button.component.html +20 -0
  17. package/src/lib/components/button/button.component.scss +0 -0
  18. package/src/lib/components/button/button.component.spec.ts +21 -0
  19. package/src/lib/components/button/button.component.ts +49 -0
  20. package/src/lib/components/button/index.ts +1 -0
  21. package/src/lib/components/calendar/calendar.component.html +53 -0
  22. package/src/lib/components/calendar/calendar.component.scss +0 -0
  23. package/src/lib/components/calendar/calendar.component.spec.ts +21 -0
  24. package/src/lib/components/calendar/calendar.component.ts +70 -0
  25. package/src/lib/components/calendar/index.ts +1 -0
  26. package/src/lib/components/checkbox/checkbox.component.html +20 -0
  27. package/src/lib/components/checkbox/checkbox.component.scss +15 -0
  28. package/src/lib/components/checkbox/checkbox.component.spec.ts +21 -0
  29. package/src/lib/components/checkbox/checkbox.component.stories.ts +72 -0
  30. package/src/lib/components/checkbox/checkbox.component.ts +46 -0
  31. package/src/lib/components/checkbox/index.ts +1 -0
  32. package/src/lib/components/confirm-dialog/confirm-dialog.component.html +51 -0
  33. package/src/lib/components/confirm-dialog/confirm-dialog.component.scss +3 -0
  34. package/src/lib/components/confirm-dialog/confirm-dialog.component.spec.ts +21 -0
  35. package/src/lib/components/confirm-dialog/confirm-dialog.component.stories.ts +74 -0
  36. package/src/lib/components/confirm-dialog/confirm-dialog.component.ts +73 -0
  37. package/src/lib/components/confirm-dialog/index.ts +1 -0
  38. package/src/lib/components/dropdown/dropdown.component.html +93 -0
  39. package/src/lib/components/dropdown/dropdown.component.scss +16 -0
  40. package/src/lib/components/dropdown/dropdown.component.spec.ts +21 -0
  41. package/src/lib/components/dropdown/dropdown.component.ts +139 -0
  42. package/src/lib/components/dropdown/index.ts +1 -0
  43. package/src/lib/components/dropdown-button/dropdown-button.component.html +1 -0
  44. package/src/lib/components/dropdown-button/dropdown-button.component.ts +20 -0
  45. package/src/lib/components/dropdown-button/index.ts +1 -0
  46. package/src/lib/components/errors/error.component.html +7 -0
  47. package/src/lib/components/errors/error.component.scss +3 -0
  48. package/src/lib/components/errors/error.component.ts +34 -0
  49. package/src/lib/components/errors/index.ts +1 -0
  50. package/src/lib/components/feature-list/directives/feature-list-column.directive.ts +32 -0
  51. package/src/lib/components/feature-list/directives/feature-list-filter-field.directive.ts +8 -0
  52. package/src/lib/components/feature-list/feature-list-filter.pipe.ts +21 -0
  53. package/src/lib/components/feature-list/feature-list-page.component.ts +32 -0
  54. package/src/lib/components/feature-list/feature-list-page.model.ts +42 -0
  55. package/src/lib/components/feature-list/feature-list.component.html +59 -0
  56. package/src/lib/components/feature-list/feature-list.component.scss +10 -0
  57. package/src/lib/components/feature-list/feature-list.component.ts +341 -0
  58. package/src/lib/components/feature-list/index.ts +5 -0
  59. package/src/lib/components/filter/directives/filter-field.directive.ts +34 -0
  60. package/src/lib/components/filter/filter.component.html +68 -0
  61. package/src/lib/components/filter/filter.component.scss +0 -0
  62. package/src/lib/components/filter/filter.component.spec.ts +21 -0
  63. package/src/lib/components/filter/filter.component.stories.ts +23 -0
  64. package/src/lib/components/filter/filter.component.ts +281 -0
  65. package/src/lib/components/filter/filter.model.ts +18 -0
  66. package/src/lib/components/filter/index.ts +2 -0
  67. package/src/lib/components/form-field/form-field.component.html +42 -0
  68. package/src/lib/components/form-field/form-field.component.scss +0 -0
  69. package/src/lib/components/form-field/form-field.component.spec.ts +21 -0
  70. package/src/lib/components/form-field/form-field.component.stories.ts +69 -0
  71. package/src/lib/components/form-field/form-field.component.ts +37 -0
  72. package/src/lib/components/form-field/index.ts +1 -0
  73. package/src/lib/components/header/header.component.html +84 -0
  74. package/src/lib/components/header/header.component.scss +0 -0
  75. package/src/lib/components/header/header.component.spec.ts +21 -0
  76. package/src/lib/components/header/header.component.stories.ts +24 -0
  77. package/src/lib/components/header/header.component.ts +65 -0
  78. package/src/lib/components/header/index.ts +2 -0
  79. package/src/lib/components/header/services/header-provider.service.ts +15 -0
  80. package/src/lib/components/icon/icon.component.html +2 -0
  81. package/src/lib/components/icon/icon.component.scss +51 -0
  82. package/src/lib/components/icon/icon.component.ts +86 -0
  83. package/src/lib/components/icon/index.ts +2 -0
  84. package/src/lib/components/input-group/index.ts +1 -0
  85. package/src/lib/components/input-group/input-group.component.html +34 -0
  86. package/src/lib/components/input-group/input-group.component.spec.ts +21 -0
  87. package/src/lib/components/input-group/input-group.component.ts +58 -0
  88. package/src/lib/components/loader/index.ts +1 -0
  89. package/src/lib/components/loader/loader.component.html +5 -0
  90. package/src/lib/components/loader/loader.component.scss +0 -0
  91. package/src/lib/components/loader/loader.component.spec.ts +21 -0
  92. package/src/lib/components/loader/loader.component.ts +16 -0
  93. package/src/lib/components/multiselect/index.ts +1 -0
  94. package/src/lib/components/multiselect/multiselect.component.html +67 -0
  95. package/src/lib/components/multiselect/multiselect.component.scss +0 -0
  96. package/src/lib/components/multiselect/multiselect.component.spec.ts +21 -0
  97. package/src/lib/components/multiselect/multiselect.component.ts +120 -0
  98. package/src/lib/components/number-input/index.ts +1 -0
  99. package/src/lib/components/number-input/number-input.component.html +22 -0
  100. package/src/lib/components/number-input/number-input.component.spec.ts +21 -0
  101. package/src/lib/components/number-input/number-input.component.ts +55 -0
  102. package/src/lib/components/page-header/index.ts +1 -0
  103. package/src/lib/components/page-header/page-header.component.html +35 -0
  104. package/src/lib/components/page-header/page-header.component.scss +0 -0
  105. package/src/lib/components/page-header/page-header.component.spec.ts +21 -0
  106. package/src/lib/components/page-header/page-header.component.ts +31 -0
  107. package/src/lib/components/password/index.ts +1 -0
  108. package/src/lib/components/password/password.component.html +24 -0
  109. package/src/lib/components/password/password.component.scss +0 -0
  110. package/src/lib/components/password/password.component.spec.ts +21 -0
  111. package/src/lib/components/password/password.component.ts +56 -0
  112. package/src/lib/components/radiobutton/index.ts +1 -0
  113. package/src/lib/components/radiobutton/radiobutton.component.html +34 -0
  114. package/src/lib/components/radiobutton/radiobutton.component.scss +6 -0
  115. package/src/lib/components/radiobutton/radiobutton.component.spec.ts +21 -0
  116. package/src/lib/components/radiobutton/radiobutton.component.stories.ts +71 -0
  117. package/src/lib/components/radiobutton/radiobutton.component.ts +61 -0
  118. package/src/lib/components/section/index.ts +1 -0
  119. package/src/lib/components/section/section.component.html +25 -0
  120. package/src/lib/components/section/section.component.scss +0 -0
  121. package/src/lib/components/section/section.component.spec.ts +21 -0
  122. package/src/lib/components/section/section.component.ts +31 -0
  123. package/src/lib/components/shared-components/.eslintrc.json +42 -0
  124. package/src/lib/components/shared-components/action-button-group/action-button-group.component.html +25 -0
  125. package/src/lib/components/shared-components/action-button-group/action-button-group.component.scss +0 -0
  126. package/src/lib/components/shared-components/action-button-group/action-button-group.component.spec.ts +21 -0
  127. package/src/lib/components/shared-components/action-button-group/action-button-group.component.ts +111 -0
  128. package/src/lib/components/shared-components/action-button-group/components/action-button/action-button.component.html +10 -0
  129. package/src/lib/components/shared-components/action-button-group/components/action-button/action-button.component.scss +0 -0
  130. package/src/lib/components/shared-components/action-button-group/components/action-button/action-button.component.spec.ts +21 -0
  131. package/src/lib/components/shared-components/action-button-group/components/action-button/action-button.component.ts +69 -0
  132. package/src/lib/components/shared-components/action-button-group/index.ts +2 -0
  133. package/src/lib/components/shared-components/dynamic-component/dynamic-component-factory.service.ts +142 -0
  134. package/src/lib/components/shared-components/dynamic-component/dynamic-component.component.ts +56 -0
  135. package/src/lib/components/shared-components/dynamic-component/index.ts +2 -0
  136. package/src/lib/components/shared-components/generic-field/generic-field.component.html +98 -0
  137. package/src/lib/components/shared-components/generic-field/generic-field.component.spec.ts +21 -0
  138. package/src/lib/components/shared-components/generic-field/generic-field.component.ts +90 -0
  139. package/src/lib/components/shared-components/generic-field/index.ts +1 -0
  140. package/src/lib/components/shared-components/generic-form/generic-form.component.html +46 -0
  141. package/src/lib/components/shared-components/generic-form/generic-form.component.spec.ts +21 -0
  142. package/src/lib/components/shared-components/generic-form/generic-form.component.ts +56 -0
  143. package/src/lib/components/shared-components/generic-form/generic-form.model.spec.ts +82 -0
  144. package/src/lib/components/shared-components/generic-form/generic-form.model.ts +68 -0
  145. package/src/lib/components/shared-components/generic-form/index.ts +2 -0
  146. package/src/lib/components/shared-components/index.ts +4 -0
  147. package/src/lib/components/side-menu/index.ts +2 -0
  148. package/src/lib/components/side-menu/side-menu.component.html +53 -0
  149. package/src/lib/components/side-menu/side-menu.component.scss +0 -0
  150. package/src/lib/components/side-menu/side-menu.component.spec.ts +21 -0
  151. package/src/lib/components/side-menu/side-menu.component.ts +96 -0
  152. package/src/lib/components/side-menu/side-menu.module.ts +66 -0
  153. package/src/lib/components/slider/index.ts +1 -0
  154. package/src/lib/components/slider/slider.component.html +19 -0
  155. package/src/lib/components/slider/slider.component.spec.ts +21 -0
  156. package/src/lib/components/slider/slider.component.ts +56 -0
  157. package/src/lib/components/snackbar/index.ts +2 -0
  158. package/src/lib/components/snackbar/services/snackbar.service.ts +45 -0
  159. package/src/lib/components/snackbar/snackbar.component.html +3 -0
  160. package/src/lib/components/snackbar/snackbar.component.scss +0 -0
  161. package/src/lib/components/snackbar/snackbar.component.spec.ts +21 -0
  162. package/src/lib/components/snackbar/snackbar.component.stories.ts +70 -0
  163. package/src/lib/components/snackbar/snackbar.component.ts +25 -0
  164. package/src/lib/components/stepper/index.ts +1 -0
  165. package/src/lib/components/stepper/stepper.component.html +35 -0
  166. package/src/lib/components/stepper/stepper.component.spec.ts +21 -0
  167. package/src/lib/components/stepper/stepper.component.ts +39 -0
  168. package/src/lib/components/switch/index.ts +1 -0
  169. package/src/lib/components/switch/switch.component.html +18 -0
  170. package/src/lib/components/switch/switch.component.scss +0 -0
  171. package/src/lib/components/switch/switch.component.spec.ts +21 -0
  172. package/src/lib/components/switch/switch.component.stories.ts +65 -0
  173. package/src/lib/components/switch/switch.component.ts +52 -0
  174. package/src/lib/components/tab-view/index.ts +2 -0
  175. package/src/lib/components/tab-view/tab-view-item.component.ts +22 -0
  176. package/src/lib/components/tab-view/tab-view.component.html +41 -0
  177. package/src/lib/components/tab-view/tab-view.component.ts +55 -0
  178. package/src/lib/components/table/index.ts +1 -0
  179. package/src/lib/components/table/table-filter.pipe.ts +59 -0
  180. package/src/lib/components/table/table.component.html +127 -0
  181. package/src/lib/components/table/table.component.scss +11 -0
  182. package/src/lib/components/table/table.component.spec.ts +21 -0
  183. package/src/lib/components/table/table.component.stories.ts +55 -0
  184. package/src/lib/components/table/table.component.ts +288 -0
  185. package/src/lib/components/table/table.models.ts +26 -0
  186. package/src/lib/components/tag/index.ts +2 -0
  187. package/src/lib/components/tag/tag.component.html +12 -0
  188. package/src/lib/components/tag/tag.component.scss +33 -0
  189. package/src/lib/components/tag/tag.component.ts +83 -0
  190. package/src/lib/components/textarea/index.ts +1 -0
  191. package/src/lib/components/textarea/textarea.component.html +40 -0
  192. package/src/lib/components/textarea/textarea.component.scss +5 -0
  193. package/src/lib/components/textarea/textarea.component.spec.ts +21 -0
  194. package/src/lib/components/textarea/textarea.component.stories.ts +98 -0
  195. package/src/lib/components/textarea/textarea.component.ts +62 -0
  196. package/src/lib/components/textfield/index.ts +1 -0
  197. package/src/lib/components/textfield/textfield.component.html +82 -0
  198. package/src/lib/components/textfield/textfield.component.scss +23 -0
  199. package/src/lib/components/textfield/textfield.component.spec.ts +21 -0
  200. package/src/lib/components/textfield/textfield.component.stories.ts +85 -0
  201. package/src/lib/components/textfield/textfield.component.ts +68 -0
  202. package/src/lib/components/tooltip/index.ts +1 -0
  203. package/src/lib/components/tooltip/tooltip.component.html +3 -0
  204. package/src/lib/components/tooltip/tooltip.component.ts +17 -0
  205. package/src/lib/icons.ts +36 -0
  206. package/src/lib/interceptors/http-error-message.interceptor.ts +35 -0
  207. package/src/lib/pages/not-found-page/not-found-page.component.html +26 -0
  208. package/src/lib/pages/not-found-page/not-found-page.component.scss +0 -0
  209. package/src/lib/pages/not-found-page/not-found-page.component.spec.ts +21 -0
  210. package/src/lib/pages/not-found-page/not-found-page.component.ts +16 -0
  211. package/src/tab-view.ts +1 -0
  212. package/src/test-setup.ts +8 -0
  213. package/tsconfig.json +29 -0
  214. package/tsconfig.lib.json +18 -0
  215. package/tsconfig.lib.prod.json +9 -0
  216. package/tsconfig.spec.json +16 -0
  217. package/fesm2022/verisoft-ui-primeng.mjs +0 -2866
  218. package/fesm2022/verisoft-ui-primeng.mjs.map +0 -1
  219. package/index.d.ts +0 -729
@@ -0,0 +1,34 @@
1
+ import { CommonModule } from "@angular/common";
2
+ import { Component, inject, Input, } from "@angular/core";
3
+ import { NgControl, ValidationErrors } from "@angular/forms";
4
+ import { ERROR_PROVIDER_TOKEN } from "@verisoft/core";
5
+ import { SlotPosition, SlotPositionType } from "@verisoft/ui-core";
6
+ import { MessageModule } from "primeng/message";
7
+ import { Observable } from "rxjs";
8
+ import { Icons } from "../../icons";
9
+
10
+ @Component({
11
+ selector: "v-validation-message",
12
+ templateUrl: "./error.component.html",
13
+ styleUrl: "./error.component.scss",
14
+ imports: [CommonModule, MessageModule]
15
+ })
16
+ export class ErrorComponent {
17
+ @Input({ required: true }) ngControl?: NgControl;
18
+
19
+ @Input() errorSlot: SlotPositionType = SlotPosition.bottom
20
+
21
+ @Input() messageSlot: SlotPositionType = SlotPosition.bottom
22
+
23
+ @Input() variant = 'simple';
24
+
25
+ @Input() severity = 'error';
26
+
27
+ readonly errorService = inject(ERROR_PROVIDER_TOKEN);
28
+
29
+ icons = Icons
30
+
31
+ getErrorMessage(errors: ValidationErrors): Observable<string | undefined> {
32
+ return this.errorService.mapError(errors);
33
+ }
34
+ }
@@ -0,0 +1 @@
1
+ export * from './error.component';
@@ -0,0 +1,32 @@
1
+ import { Directive, Input } from '@angular/core';
2
+ import { GenericFieldType, GenericFieldTypeType, TableColumnDirective } from '@verisoft/ui-core';
3
+ import { FEATURE_LIST_COLUMN_PROVIDER, FeatureListColumnDefinition, FeatureListColumnProvider } from '../feature-list-page.model';
4
+
5
+ @Directive({
6
+ // eslint-disable-next-line @angular-eslint/directive-selector
7
+ selector: 'v-feature-list-column',
8
+ standalone: true,
9
+ providers: [
10
+ {
11
+ provide: FEATURE_LIST_COLUMN_PROVIDER,
12
+ useExisting: FeatureListColumnDirective,
13
+ multi: true,
14
+ },
15
+ ],
16
+ })
17
+ export class FeatureListColumnDirective<T>
18
+ extends TableColumnDirective<T>
19
+ implements FeatureListColumnProvider<T>
20
+ {
21
+ @Input() filter = false;
22
+
23
+ @Input() type: GenericFieldTypeType = GenericFieldType.text;
24
+
25
+ override getDefinition(): FeatureListColumnDefinition<T> {
26
+ const definition = super.getDefinition() as FeatureListColumnDefinition<T>;
27
+ definition.filter = this.filter;
28
+ definition.type = this.type;
29
+ definition.format = this.format;
30
+ return definition;
31
+ }
32
+ }
@@ -0,0 +1,8 @@
1
+ import { Directive } from '@angular/core';
2
+ import { FilterFieldDirective } from '../../filter';
3
+ @Directive({
4
+ // eslint-disable-next-line @angular-eslint/directive-selector
5
+ selector: 'v-feature-list-filter-field',
6
+ standalone: true,
7
+ })
8
+ export class FeatureListFilterFieldDirective extends FilterFieldDirective {}
@@ -0,0 +1,21 @@
1
+ import { Pipe, PipeTransform } from "@angular/core";
2
+ import { GenericFieldDefinition, GenericFieldType } from "@verisoft/ui-core";
3
+ import { FeatureListColumnDefinition } from "./feature-list-page.model";
4
+
5
+ @Pipe({
6
+ name: 'featureListColumn',
7
+ standalone: true,
8
+ })
9
+ export class FeatureListFilterPipe<T> implements PipeTransform {
10
+ transform(value: FeatureListColumnDefinition<T>[] | undefined): GenericFieldDefinition[] | undefined {
11
+ if (!value){
12
+ return undefined;
13
+ }
14
+
15
+ return value.filter(x => x.filter).map((x, index) => ({
16
+ name: x.id,
17
+ label: typeof x.headerName === 'function'? x.headerName(x.id, index) : x.headerName ?? '',
18
+ type: x.type as GenericFieldType,
19
+ }));
20
+ }
21
+ }
@@ -0,0 +1,32 @@
1
+ import { Component, inject } from '@angular/core';
2
+ import { ActivatedRoute } from '@angular/router';
3
+ import {
4
+ FEATURE_LIST_PAGE_CONFIG_PROPERTY,
5
+ FeatureListPageConfig,
6
+ } from './feature-list-page.model';
7
+ import { FeatureListComponent } from './feature-list.component';
8
+
9
+ @Component({
10
+ selector: 'v-feature-list-page',
11
+ imports: [FeatureListComponent],
12
+ template: `
13
+ <v-feature-list
14
+ [title]="config.title"
15
+ [tableName]="config.tableName"
16
+ [showAdd]="config.showAdd ?? true"
17
+ [showDownload]="config.showDownload ?? true"
18
+ [showDelete]="config.showDelete ?? true"
19
+ >
20
+ </v-feature-list>
21
+ `
22
+ })
23
+ export class FeatureListPageComponent {
24
+ config!: FeatureListPageConfig;
25
+
26
+ private readonly activatedRoute = inject(ActivatedRoute);
27
+
28
+ constructor() {
29
+ this.config =
30
+ this.activatedRoute.snapshot.data[FEATURE_LIST_PAGE_CONFIG_PROPERTY];
31
+ }
32
+ }
@@ -0,0 +1,42 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { Route } from '@angular/router';
3
+ import { ColumnDefinition, GenericFieldTypeType } from '@verisoft/ui-core';
4
+ import { FeatureListPageComponent } from './feature-list-page.component';
5
+
6
+ export interface FeatureListPageConfig {
7
+ title: string;
8
+ datasource: string;
9
+ tableName: string;
10
+ showAdd?: boolean;
11
+ showDownload?: boolean;
12
+ showDelete?: boolean;
13
+ }
14
+
15
+ export const FEATURE_LIST_PAGE_CONFIG_PROPERTY = 'feature_list_config';
16
+
17
+ export function addFeatureListPage(
18
+ value: Partial<Route> & { config: FeatureListPageConfig }
19
+ ): Route {
20
+ const { config, ...route } = value;
21
+ return {
22
+ component: FeatureListPageComponent,
23
+ ...route,
24
+ data: {
25
+ [FEATURE_LIST_PAGE_CONFIG_PROPERTY]: config,
26
+ ...(route.data ?? {}),
27
+ },
28
+ };
29
+ }
30
+
31
+ export interface FeatureListColumnDefinition<T> extends ColumnDefinition<T> {
32
+ filter?: boolean;
33
+ type?: GenericFieldTypeType;
34
+ }
35
+
36
+ export const FEATURE_LIST_COLUMN_PROVIDER = new InjectionToken(
37
+ 'FEATURE_LIST_COLUMN_PROVIDER'
38
+ );
39
+
40
+ export interface FeatureListColumnProvider<T> {
41
+ getDefinition: () => FeatureListColumnDefinition<T>;
42
+ }
@@ -0,0 +1,59 @@
1
+ <div class="feature-list__container full-height-container">
2
+ <v-filter
3
+ #filter
4
+ [title]="title"
5
+ [fields]="columns | featureListColumn"
6
+ [filters]="filters"
7
+ [fulltextFieldName]="fulltextFieldName"
8
+ [showFulltext]="showFulltext"
9
+ [showFilters]="showExtendedFilter"
10
+ >
11
+ <v-action-button-group
12
+ [maxItems]="maxVisibleActions"
13
+ [maxItemsMobile]="maxVisibleMobileActions"
14
+ >
15
+ @if (showAdd) {
16
+ <v-action-button
17
+ [icon]="icons.add"
18
+ label="Add"
19
+ [disabled]="!canAdd"
20
+ (click)="addClick.emit()"
21
+ ></v-action-button>
22
+ } @if (showDelete){
23
+ <v-action-button
24
+ [icon]="icons.delete"
25
+ label="Delete"
26
+ [disabled]="!canDelete || !selection.length"
27
+ (click)="startDeleteItems()"
28
+ ></v-action-button>
29
+ } @if (showDownload){
30
+ <v-action-button
31
+ [icon]="icons.download"
32
+ label="Download"
33
+ [disabled]="!canDownload"
34
+ (click)="startDownload()"
35
+ ></v-action-button>
36
+ }
37
+ </v-action-button-group>
38
+ </v-filter>
39
+ <div class="feature-list__table-container full-height-container">
40
+ <div class="full-height-container">
41
+ <v-table
42
+ useDatasource
43
+ useFilter
44
+ [filterComponent]="filter"
45
+ class="full-height-container"
46
+ [selectionMode]="selectionMode"
47
+ [tableName]="tableName"
48
+ [autoBind]="true"
49
+ [datasource]="datasource"
50
+ [columns]="columns"
51
+ [extraFilter]="extraFilter"
52
+ [maximumColumnLength]="maximumColumnLength"
53
+ [disableCustomClicks]="disableCustomClicks"
54
+ (selectionChange)="selectItems($event)"
55
+ >
56
+ </v-table>
57
+ </div>
58
+ </div>
59
+ </div>
@@ -0,0 +1,10 @@
1
+ .full-height-container {
2
+ display: flex;
3
+ flex-direction: column;
4
+ flex-grow: 1;
5
+ height: 100%;
6
+ }
7
+
8
+ :host {
9
+ @extend .full-height-container;
10
+ }
@@ -0,0 +1,341 @@
1
+ import { HttpClient } from '@angular/common/http';
2
+ import {
3
+ AfterViewInit,
4
+ ChangeDetectionStrategy,
5
+ ChangeDetectorRef,
6
+ Component,
7
+ ContentChildren,
8
+ EventEmitter,
9
+ inject,
10
+ Input,
11
+ Output,
12
+ QueryList,
13
+ ViewChild,
14
+ } from '@angular/core';
15
+ import {
16
+ AllDataRequestParams,
17
+ BASE_URL_PATH,
18
+ BaseHttpService,
19
+ convertDatasource,
20
+ DatasourceType,
21
+ DEFAULT_PAGE_SIZE,
22
+ } from '@verisoft/core';
23
+ import {
24
+ ColumnModel,
25
+ DialogService,
26
+ downloadFile,
27
+ GenericFieldDefinition,
28
+ MAX_COLUMN_CHAR_COUNT,
29
+ TableDatasourceDirective,
30
+ TableFilterDirective,
31
+ TableSelectionMode,
32
+ TableSelectionModeType,
33
+ } from '@verisoft/ui-core';
34
+ import { take, switchMap, forkJoin, Observable, of } from 'rxjs';
35
+ import { Icons } from '../../icons';
36
+ import { FilterComponent } from '../filter';
37
+ import {
38
+ ActionButtonComponent,
39
+ ActionButtonGroupComponent,
40
+ } from '../shared-components/action-button-group';
41
+ import { TableComponent } from '../table';
42
+ import { FeatureListFilterFieldDirective } from './directives/feature-list-filter-field.directive';
43
+ import { FeatureListFilterPipe } from './feature-list-filter.pipe';
44
+ import {
45
+ FEATURE_LIST_COLUMN_PROVIDER,
46
+ FeatureListColumnDefinition,
47
+ FeatureListColumnProvider,
48
+ } from './feature-list-page.model';
49
+
50
+ @Component({
51
+ selector: 'v-feature-list',
52
+ imports: [
53
+ TableComponent,
54
+ TableDatasourceDirective,
55
+ FilterComponent,
56
+ TableFilterDirective,
57
+ ActionButtonGroupComponent,
58
+ ActionButtonComponent,
59
+ FeatureListFilterPipe,
60
+ ],
61
+ templateUrl: './feature-list.component.html',
62
+ styleUrls: ['./feature-list.component.scss'],
63
+ changeDetection: ChangeDetectionStrategy.OnPush
64
+ })
65
+ export class FeatureListComponent<T> implements AfterViewInit {
66
+ @ContentChildren(FEATURE_LIST_COLUMN_PROVIDER) viewColumns!: QueryList<
67
+ FeatureListColumnProvider<T>
68
+ >;
69
+
70
+ @ContentChildren(FeatureListFilterFieldDirective)
71
+ fieldDeclarations!: QueryList<FeatureListFilterFieldDirective>;
72
+
73
+ @ViewChild(TableDatasourceDirective)
74
+ tableDatasourceDirective!: TableDatasourceDirective<T>;
75
+
76
+ @Input() autoBind = true;
77
+
78
+ @Input() title!: string;
79
+
80
+ @Input() columns!: FeatureListColumnDefinition<T>[];
81
+
82
+ @Input() filters!: GenericFieldDefinition[];
83
+
84
+ @Input() maxVisibleActions = 2;
85
+
86
+ @Input({ required: true }) tableName!: string;
87
+
88
+ @Input() ngrxFeatureKey?: string;
89
+
90
+ @Input() maxVisibleMobileActions = 0;
91
+
92
+ @Input() showExtendedFilter = false;
93
+
94
+ @Input() showDownload = false;
95
+
96
+ @Input() showDelete = false;
97
+
98
+ @Input() showAdd = false;
99
+
100
+ @Input() canDownload = true;
101
+
102
+ @Input() canDelete = true;
103
+
104
+ @Input() canAdd = true;
105
+
106
+ @Input() useRouterFilter = true;
107
+
108
+ @Input() fulltextFieldName = 'searchField';
109
+
110
+ @Input() showFulltext = true;
111
+
112
+ @Input() deleteConfirmMessage: string | undefined;
113
+
114
+ @Input() autoDeleteEnabled = true;
115
+
116
+ @Input() autoDownloadEnabled = true;
117
+
118
+ @Input() downloadFileName = 'export.csv';
119
+
120
+ @Input() datasource!: DatasourceType<T>;
121
+
122
+ @Input() extraFilter: Partial<T> | undefined;
123
+
124
+ @Input() disableCustomClicks = false;
125
+
126
+ @Input() maximumColumnLength = MAX_COLUMN_CHAR_COUNT;
127
+
128
+ @Output() addClick = new EventEmitter();
129
+
130
+ @Output() downloadClick = new EventEmitter();
131
+
132
+ @Output() deleteClick = new EventEmitter<T[]>();
133
+
134
+ @Output() selectionChange = new EventEmitter();
135
+
136
+ @Input() set selectionMode(mode: TableSelectionModeType | undefined) {
137
+ this._selectionMode = mode;
138
+ }
139
+
140
+ get selectionMode(): TableSelectionModeType | undefined {
141
+ return this.canDelete
142
+ ? TableSelectionMode.single
143
+ : this._selectionMode;
144
+ }
145
+
146
+ icons = Icons;
147
+
148
+ private httpClient = inject(HttpClient);
149
+
150
+ private baseUrl: string = inject(BASE_URL_PATH);
151
+
152
+ private _selectionMode: TableSelectionModeType | undefined;
153
+
154
+ private cdRef = inject(ChangeDetectorRef);
155
+
156
+ private dialogService = inject(DialogService);
157
+
158
+ selection: T[] = [];
159
+
160
+ ngAfterViewInit(): void {
161
+ if (this.viewColumns?.length) {
162
+ const vewColumns = this.viewColumns
163
+ ?.toArray()
164
+ .map((x) => x.getDefinition());
165
+ this.columns = [...(this.columns ?? []), ...(vewColumns ?? [])];
166
+ this.cdRef.detectChanges();
167
+ }
168
+
169
+ if (this.fieldDeclarations?.length) {
170
+ this.filters = this.fieldDeclarations?.toArray();
171
+ }
172
+
173
+ this.cdRef.detectChanges();
174
+ }
175
+
176
+ selectItems(items: T[]) {
177
+ this.selection = items ?? [];
178
+
179
+ if (this.selectionMode !== undefined) {
180
+ this.selectionChange.emit(
181
+ this.selectionMode === 'multiple'
182
+ ? this.selection
183
+ : this.selection[0]
184
+ );
185
+ }
186
+ }
187
+
188
+ startDeleteItems() {
189
+ if (!this.selection.length) {
190
+ return;
191
+ }
192
+
193
+ if (this.deleteConfirmMessage) {
194
+ const message = this.deleteConfirmMessage;
195
+ this.dialogService.showDialog({
196
+ innerHTML: message,
197
+ confirmButtonFn: () => this.deleteItems(this.selection),
198
+ });
199
+ } else {
200
+ this.deleteItems(this.selection);
201
+ }
202
+ }
203
+
204
+ startDownload() {
205
+ this.downloadClick.emit();
206
+ if (!this.autoDownloadEnabled) {
207
+ return;
208
+ }
209
+
210
+ const dowloadFn = this.createDownloadFn(this.datasource);
211
+ if (dowloadFn) {
212
+ this.tableDatasourceDirective.params$
213
+ .pipe(
214
+ take(1),
215
+ switchMap((params) => dowloadFn(params))
216
+ )
217
+ .subscribe((blob) => {
218
+ downloadFile(this.downloadFileName, blob);
219
+ });
220
+ }
221
+ }
222
+
223
+ private deleteItems(items: T[]) {
224
+ if (!this.autoDeleteEnabled) {
225
+ this.deleteClick.emit(items);
226
+ } else {
227
+ this.forceDelete(items);
228
+ }
229
+ }
230
+
231
+ private forceDelete(items: T[]) {
232
+ const deleteFn = this.createDeleteFn(this.datasource);
233
+ if (deleteFn) {
234
+ const deleteMethods = items.map((x) => deleteFn(x));
235
+ forkJoin(deleteMethods)
236
+ .pipe(take(1))
237
+ .subscribe(() => this.finishDeletion(items));
238
+ } else {
239
+ this.finishDeletion(items);
240
+ }
241
+ }
242
+
243
+ private createDeleteFn(
244
+ datasource: DatasourceType<T>
245
+ ): ((item: T) => Observable<unknown>) | undefined {
246
+ if (!datasource) {
247
+ return undefined;
248
+ }
249
+
250
+ if (typeof datasource === 'string') {
251
+ const service = new BaseHttpService<T>(
252
+ this.httpClient,
253
+ this.baseUrl,
254
+ datasource
255
+ );
256
+
257
+ return (item: T) => service.delete((item as { id: string }).id);
258
+ }
259
+
260
+ if (datasource instanceof BaseHttpService) {
261
+ return (item: T) => datasource.delete((item as { id: string }).id);
262
+ }
263
+
264
+ return undefined;
265
+ }
266
+
267
+ private createDownloadFn(
268
+ datasource: DatasourceType<T>
269
+ ): ((request: AllDataRequestParams<T>) => Observable<Blob>) | undefined {
270
+ if (!datasource) {
271
+ return undefined;
272
+ }
273
+
274
+ if (typeof datasource === 'string') {
275
+ const service = new BaseHttpService<T>(
276
+ this.httpClient,
277
+ this.baseUrl,
278
+ datasource
279
+ );
280
+
281
+ return (request: AllDataRequestParams<T>) => service.export(request);
282
+ }
283
+
284
+ if (datasource instanceof BaseHttpService) {
285
+ return (request: AllDataRequestParams<T>) => datasource.export(request);
286
+ }
287
+
288
+ const fetchFunction = convertDatasource(
289
+ datasource,
290
+ this.baseUrl,
291
+ this.httpClient
292
+ );
293
+
294
+ return (request: AllDataRequestParams<T>) => {
295
+ const allData: T[] = [];
296
+ let offset = 0;
297
+ const fetchAllData = (): Observable<Blob> => {
298
+ return fetchFunction({
299
+ ...request,
300
+ offset,
301
+ limit: DEFAULT_PAGE_SIZE,
302
+ }).pipe(
303
+ take(1),
304
+ switchMap((response) => {
305
+ allData.push(...response.data);
306
+ if (allData.length < response.total) {
307
+ offset = offset + DEFAULT_PAGE_SIZE;
308
+ return fetchAllData();
309
+ } else {
310
+ return of(this.convertToBlob(allData));
311
+ }
312
+ })
313
+ );
314
+ };
315
+
316
+ return fetchAllData();
317
+ };
318
+ }
319
+
320
+ private finishDeletion(items: T[]) {
321
+ if (this.datasource && Array.isArray(this.datasource)) {
322
+ this.datasource = this.datasource.filter((x) => !items.includes(x));
323
+ } else {
324
+ this.tableDatasourceDirective.reload();
325
+ }
326
+
327
+ this.deleteClick.emit(items);
328
+ }
329
+
330
+ private convertToBlob(data: T[]): Blob {
331
+ const columnModel = this.columns.map((x) => new ColumnModel(x));
332
+ const headers = columnModel.map((x, index) => x.headerGetter(x.id, index));
333
+ const dataValues = data.map((row, rowIndex) =>
334
+ columnModel.map((column) => column.valueGetter(row, rowIndex))
335
+ );
336
+ const csvData = [headers, ...dataValues]
337
+ .map((row) => row.join(','))
338
+ .join('\n');
339
+ return new Blob([csvData], { type: 'text/csv' });
340
+ }
341
+ }
@@ -0,0 +1,5 @@
1
+ export * from './feature-list.component';
2
+ export * from './feature-list-page.model';
3
+ export * from './directives/feature-list-column.directive';
4
+ export * from './directives/feature-list-filter-field.directive';
5
+ export * from './feature-list-filter.pipe';
@@ -0,0 +1,34 @@
1
+ import { Directive, Input } from '@angular/core';
2
+ import { ValidatorFn } from '@angular/forms';
3
+ import { DatasourceType } from '@verisoft/core';
4
+ import { GenericFieldDefinition, GenericFieldType, GenericFieldTypeType } from '@verisoft/ui-core';
5
+
6
+ @Directive({
7
+ // eslint-disable-next-line @angular-eslint/directive-selector
8
+ selector: 'v-filter-field',
9
+ })
10
+ export class FilterFieldDirective implements GenericFieldDefinition {
11
+ @Input({ required: true }) name!: string;
12
+
13
+ @Input() type: GenericFieldTypeType | undefined = GenericFieldType.text;
14
+
15
+ @Input() label: string | undefined;
16
+
17
+ @Input() optionLabel!: string;
18
+
19
+ @Input() optionValue: string | undefined;
20
+
21
+ @Input() options: unknown[] | undefined;
22
+
23
+ @Input() value?: unknown;
24
+
25
+ @Input() validator?: ValidatorFn[];
26
+
27
+ @Input() datasource: DatasourceType<any> | undefined;
28
+
29
+ @Input() filterField?: string;
30
+
31
+ @Input() showFilter?: boolean;
32
+
33
+ @Input() localSearch?: boolean;
34
+ }
@@ -0,0 +1,68 @@
1
+ <div class="v-filter w-100 p-3 bg-primary">
2
+ @if (formGroup$ | async; as formGroup){
3
+ <form [formGroup]="formGroup" class="d-flex align-items-center">
4
+ @if (title) {
5
+ <div class="v-filter_title pe-4">
6
+ <h2 class="text-white m-0">{{ title }}</h2>
7
+ </div>
8
+ }
9
+ <div class="v-filter__fulltext flex-grow-1 pe-4">
10
+ @if (showFulltext){
11
+ <v-textfield
12
+ class="d-none d-lg-block"
13
+ placeholder="Search"
14
+ size="large"
15
+ formControlName="searchField"
16
+ type="search"
17
+ [clearable]="true"
18
+ >
19
+ </v-textfield>
20
+ }
21
+ </div>
22
+ @if (simpleFormFieldDefinitions$ | async; as declaration){
23
+ @if (showFilters)
24
+ {
25
+ <div class="v-filter_filters d-none d-sm-block me-2">
26
+ <v-generic-form
27
+ [fields]="declaration"
28
+ [formGroup]="formGroup"
29
+ ></v-generic-form>
30
+ <v-button label="X" class="mt-3" (click)="clear()" />
31
+ </div>
32
+ }
33
+ <div class="v-filter_action-buttons d-flex">
34
+ @if (declaration.length && !showFilters) {
35
+ <v-button
36
+ class="me-4"
37
+ [icon]="icons.filter"
38
+ [label]="$any(filledFiltersCount$ | async)"
39
+ (click)="openFilter()"
40
+ />
41
+ } @if (!autoBind) {
42
+ <v-button
43
+ useShortCut
44
+ [shortCutFn]="submitValue.bind(this)"
45
+ shortCutKey="Enter"
46
+ class="text-white mx-2"
47
+ [outlined]="true"
48
+ size="small"
49
+ label="Apply"
50
+ (click)="submitValue()"
51
+ ></v-button>
52
+ <v-button
53
+ useShortCut
54
+ [shortCutFn]="clear.bind(this)"
55
+ shortCutKey="Escape"
56
+ class="text-white"
57
+ [outlined]="true"
58
+ size="small"
59
+ label="Clear"
60
+ (click)="clear()"
61
+ ></v-button>
62
+ }
63
+ </div>
64
+ }
65
+ <ng-content select="v-action-button-group"></ng-content>
66
+ </form>
67
+ }
68
+ </div>