@unifylib/ui-lib 1.0.3 → 1.1.3

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 (155) hide show
  1. package/ng-package.json +7 -7
  2. package/package.json +14 -12
  3. package/src/lib/base-model/SearchStrConfig.ts +12 -12
  4. package/src/lib/base-model/api-response.ts +23 -23
  5. package/src/lib/base-model/audit-log-entry.ts +7 -7
  6. package/src/lib/base-model/button-action-settings.ts +29 -25
  7. package/src/lib/base-model/column-def.model.ts +34 -34
  8. package/src/lib/base-model/do-action-request.ts +11 -11
  9. package/src/lib/base-model/feature-item.ts +9 -0
  10. package/src/lib/base-model/field-action.ts +7 -7
  11. package/src/lib/base-model/field-filter.model.ts +7 -14
  12. package/src/lib/base-model/field-info.ts +102 -98
  13. package/src/lib/base-model/field-predicate.model.ts +7 -7
  14. package/src/lib/base-model/filter-request.ts +27 -27
  15. package/src/lib/base-model/filter.model.ts +49 -49
  16. package/src/lib/base-model/get-items-list.ts +24 -24
  17. package/src/lib/base-model/index.ts +11 -11
  18. package/src/lib/base-model/items-total.model.ts +12 -0
  19. package/src/lib/base-model/line-item.model.ts +18 -0
  20. package/src/lib/base-model/lookupItem.ts +21 -21
  21. package/src/lib/base-model/null-snackmessage.ts +9 -9
  22. package/src/lib/base-model/page-info.ts +54 -51
  23. package/src/lib/base-model/report-request.model.ts +33 -33
  24. package/src/lib/base-model/response-envelop.model.ts +15 -15
  25. package/src/lib/base-model/snack-message.model.ts +14 -14
  26. package/src/lib/base-model/snackmessage-interface.ts +7 -7
  27. package/src/lib/base-model/table-column.interface.ts +29 -29
  28. package/src/lib/base-model/table-page-user-action.interface.ts +33 -33
  29. package/src/lib/base-model/workflow/workflow-steps.model.ts +9 -9
  30. package/src/lib/base-model/workflow/workflow.model.ts +52 -52
  31. package/src/lib/components/action-comment/action-comment.component.css +52 -0
  32. package/src/lib/components/action-comment/action-comment.component.html +47 -0
  33. package/src/lib/components/{rejection-comment → action-comment}/action-comment.component.spec.ts +23 -23
  34. package/src/lib/components/{rejection-comment → action-comment}/action-comment.component.ts +102 -86
  35. package/src/lib/components/action-confirmation/action-confirmation.component.css +46 -34
  36. package/src/lib/components/action-confirmation/action-confirmation.component.html +32 -18
  37. package/src/lib/components/action-confirmation/action-confirmation.component.spec.ts +23 -23
  38. package/src/lib/components/action-confirmation/action-confirmation.component.ts +58 -58
  39. package/src/lib/components/activity-report-form/activity-report-form.component.html +110 -109
  40. package/src/lib/components/activity-report-form/activity-report-form.component.scss +69 -0
  41. package/src/lib/components/activity-report-form/activity-report-form.component.spec.ts +25 -25
  42. package/src/lib/components/activity-report-form/activity-report-form.component.ts +616 -605
  43. package/src/lib/components/advanced-filter/field-filter/field-filter.component.html +8 -0
  44. package/src/lib/components/advanced-filter/field-filter/field-filter.component.scss +0 -0
  45. package/src/lib/components/advanced-filter/field-filter/field-filter.component.spec.ts +25 -0
  46. package/src/lib/components/advanced-filter/field-filter/field-filter.component.ts +55 -0
  47. package/src/lib/components/advanced-filter/filter-builder/filter-builder.component.html +36 -0
  48. package/src/lib/components/advanced-filter/filter-builder/filter-builder.component.scss +130 -0
  49. package/src/lib/components/advanced-filter/filter-builder/filter-builder.component.spec.ts +25 -0
  50. package/src/lib/components/advanced-filter/filter-builder/filter-builder.component.ts +186 -0
  51. package/src/lib/components/audit-log-details-dialog/audit-log-details-dialog.component.css +51 -51
  52. package/src/lib/components/audit-log-details-dialog/audit-log-details-dialog.component.html +23 -23
  53. package/src/lib/components/audit-log-details-dialog/audit-log-details-dialog.component.spec.ts +23 -23
  54. package/src/lib/components/audit-log-details-dialog/audit-log-details-dialog.component.ts +69 -69
  55. package/src/lib/components/audit-log-list/audit-log.component.html +26 -23
  56. package/src/lib/components/audit-log-list/audit-log.component.scss +50 -0
  57. package/src/lib/components/audit-log-list/audit-log.component.spec.ts +25 -25
  58. package/src/lib/components/audit-log-list/audit-log.component.ts +114 -116
  59. package/src/lib/components/auto-complete/auto-complete.component.css +55 -14
  60. package/src/lib/components/auto-complete/auto-complete.component.html +45 -29
  61. package/src/lib/components/auto-complete/auto-complete.component.spec.ts +23 -23
  62. package/src/lib/components/auto-complete/auto-complete.component.ts +331 -330
  63. package/src/lib/components/base-form/base-form.component.html +59 -58
  64. package/src/lib/components/base-form/base-form.component.scss +68 -0
  65. package/src/lib/components/base-form/base-form.component.spec.ts +25 -25
  66. package/src/lib/components/base-form/base-form.component.ts +323 -305
  67. package/src/lib/components/base-form-canvas/base-form-canvas.component.css +196 -22
  68. package/src/lib/components/base-form-canvas/base-form-canvas.component.html +1095 -1006
  69. package/src/lib/components/base-form-canvas/base-form-canvas.component.spec.ts +23 -23
  70. package/src/lib/components/base-form-canvas/base-form-canvas.component.ts +680 -573
  71. package/src/lib/components/base-input-dialog/base-input-dialog.component.css +67 -0
  72. package/src/lib/components/base-input-dialog/base-input-dialog.component.html +47 -42
  73. package/src/lib/components/base-input-dialog/base-input-dialog.component.spec.ts +23 -23
  74. package/src/lib/components/base-input-dialog/base-input-dialog.component.ts +77 -78
  75. package/src/lib/components/base-table/base-table.component.html +268 -242
  76. package/src/lib/components/base-table/base-table.component.scss +140 -31
  77. package/src/lib/components/base-table/base-table.component.spec.ts +25 -25
  78. package/src/lib/components/base-table/base-table.component.ts +621 -568
  79. package/src/lib/components/button-actions/button-actions.component.html +27 -28
  80. package/src/lib/components/button-actions/button-actions.component.scss +101 -6
  81. package/src/lib/components/button-actions/button-actions.component.spec.ts +23 -23
  82. package/src/lib/components/button-actions/button-actions.component.ts +70 -72
  83. package/src/lib/components/editable-base-table/editable-base-table.component.html +337 -372
  84. package/src/lib/components/editable-base-table/editable-base-table.component.scss +126 -44
  85. package/src/lib/components/editable-base-table/editable-base-table.component.spec.ts +25 -25
  86. package/src/lib/components/editable-base-table/editable-base-table.component.ts +579 -570
  87. package/src/lib/components/equation-builder/equation-builder.component.css +39 -0
  88. package/src/lib/components/equation-builder/equation-builder.component.html +31 -31
  89. package/src/lib/components/equation-builder/equation-builder.component.spec.ts +23 -23
  90. package/src/lib/components/equation-builder/equation-builder.component.ts +119 -121
  91. package/src/lib/components/item-line-editor/item-line-editor.component.html +102 -0
  92. package/src/lib/components/item-line-editor/item-line-editor.component.scss +152 -0
  93. package/src/lib/components/item-line-editor/item-line-editor.component.spec.ts +23 -0
  94. package/src/lib/components/item-line-editor/item-line-editor.component.ts +306 -0
  95. package/src/lib/components/multi-auto-complete/multi-auto-complete.component.css +19 -11
  96. package/src/lib/components/multi-auto-complete/multi-auto-complete.component.html +38 -38
  97. package/src/lib/components/multi-auto-complete/multi-auto-complete.component.spec.ts +23 -23
  98. package/src/lib/components/multi-auto-complete/multi-auto-complete.component.ts +315 -317
  99. package/src/lib/components/paginator/paginator.component.css +65 -25
  100. package/src/lib/components/paginator/paginator.component.html +30 -34
  101. package/src/lib/components/paginator/paginator.component.ts +87 -94
  102. package/src/lib/components/report-details-dialog/report-details-dialog.component.css +17 -17
  103. package/src/lib/components/report-details-dialog/report-details-dialog.component.html +16 -16
  104. package/src/lib/components/report-details-dialog/report-details-dialog.component.spec.ts +23 -23
  105. package/src/lib/components/report-details-dialog/report-details-dialog.component.ts +111 -113
  106. package/src/lib/components/report-form/report-form.component.html +92 -94
  107. package/src/lib/components/report-form/report-form.component.scss +51 -0
  108. package/src/lib/components/report-form/report-form.component.spec.ts +25 -25
  109. package/src/lib/components/report-form/report-form.component.ts +599 -588
  110. package/src/lib/components/search-bar/search-bar.component.html +51 -62
  111. package/src/lib/components/search-bar/search-bar.component.scss +63 -8
  112. package/src/lib/components/search-bar/search-bar.component.spec.ts +25 -25
  113. package/src/lib/components/search-bar/search-bar.component.ts +68 -70
  114. package/src/lib/components/section-form-canvas/section-form-canvas.component.html +43 -0
  115. package/src/lib/components/section-form-canvas/section-form-canvas.component.scss +81 -0
  116. package/src/lib/components/section-form-canvas/section-form-canvas.component.spec.ts +23 -0
  117. package/src/lib/components/section-form-canvas/section-form-canvas.component.ts +67 -0
  118. package/src/lib/components/shared/action-button/action-button.component.html +12 -0
  119. package/src/lib/components/shared/action-button/action-button.component.scss +45 -0
  120. package/src/lib/components/shared/action-button/action-button.component.ts +51 -0
  121. package/src/lib/components/shared/action-card/action-card.component.html +78 -0
  122. package/src/lib/components/shared/action-card/action-card.component.scss +238 -0
  123. package/src/lib/components/shared/action-card/action-card.component.ts +56 -0
  124. package/src/lib/components/shared/attachment-uploader/attachment-uploader.component.css +135 -54
  125. package/src/lib/components/shared/attachment-uploader/attachment-uploader.component.html +36 -22
  126. package/src/lib/components/shared/attachment-uploader/attachment-uploader.component.spec.ts +23 -23
  127. package/src/lib/components/shared/attachment-uploader/attachment-uploader.component.ts +71 -45
  128. package/src/lib/components/shared-list/shared-list.component.html +17 -17
  129. package/src/lib/components/shared-list/shared-list.component.spec.ts +23 -23
  130. package/src/lib/components/shared-list/shared-list.component.ts +53 -53
  131. package/src/lib/components/snackbar-static/snackbar-static.component.html +20 -0
  132. package/src/lib/components/snackbar-static/snackbar-static.component.scss +135 -0
  133. package/src/lib/components/snackbar-static/snackbar-static.component.ts +26 -0
  134. package/src/lib/components/title-bar/title-bar.component.html +35 -31
  135. package/src/lib/components/title-bar/title-bar.component.scss +126 -23
  136. package/src/lib/components/title-bar/title-bar.component.spec.ts +23 -23
  137. package/src/lib/components/title-bar/title-bar.component.ts +126 -119
  138. package/src/lib/services/backend-service.ts +287 -286
  139. package/src/lib/services/index.ts +3 -3
  140. package/src/lib/services/top-panel.ts +17 -17
  141. package/src/lib/services/trigger-form.service.ts +11 -11
  142. package/src/lib/share-module/shared-module.ts +10 -10
  143. package/src/lib/utils/base-utils.ts +102 -102
  144. package/src/lib/validators/date-range-validator.ts +31 -31
  145. package/src/lib/validators/index.ts +3 -3
  146. package/src/lib/validators/match-list.validator.ts +10 -10
  147. package/src/lib/validators/multi-email-validator.ts +15 -15
  148. package/src/public-api.ts +29 -21
  149. package/tsconfig.lib.json +15 -15
  150. package/tsconfig.lib.prod.json +11 -11
  151. package/tsconfig.spec.json +15 -15
  152. package/src/lib/components/rejection-comment/action-comment.component.css +0 -33
  153. package/src/lib/components/rejection-comment/action-comment.component.html +0 -46
  154. package/src/lib/styles/invoiceq-theme.scss +0 -252
  155. package/src/lib/styles/styles.scss +0 -1723
@@ -1,568 +1,621 @@
1
- import {
2
- ChangeDetectorRef,
3
- Component,
4
- effect,
5
- EventEmitter,
6
- Inject,
7
- Input,
8
- OnChanges, OnDestroy,
9
- OnInit,
10
- Output,
11
- SimpleChanges
12
- } from "@angular/core";
13
- import {
14
- MatCell,
15
- MatCellDef,
16
- MatColumnDef,
17
- MatHeaderCell,
18
- MatHeaderCellDef,
19
- MatHeaderRow,
20
- MatHeaderRowDef,
21
- MatRow,
22
- MatRowDef,
23
- MatTable,
24
- MatTableDataSource
25
- } from "@angular/material/table";
26
- import {TranslateModule, TranslateService} from "@ngx-translate/core";
27
- import {MatSortModule} from "@angular/material/sort";
28
- import {
29
- CurrencyPipe,
30
- DatePipe, DecimalPipe,
31
- JsonPipe,
32
- NgClass,
33
- NgForOf,
34
- NgIf,
35
- NgStyle,
36
- NgSwitch,
37
- NgSwitchCase,
38
- NgSwitchDefault
39
- } from "@angular/common";
40
- import {MatIcon} from "@angular/material/icon";
41
- import {MatButton, MatButtonModule, MatIconButton} from "@angular/material/button";
42
- import {NgxPaginationModule} from "ngx-pagination";
43
- import {ButtonActionsComponent} from "../button-actions/button-actions.component";
44
- import {ShareDataService} from "../../services/trigger-form.service";
45
- import {BaseUtils} from "../../utils/base-utils";
46
- import {BackendService} from "../../services/backend-service";
47
- import {FlexLayoutModule} from "@angular/flex-layout";
48
- import {Filter} from "../../base-model/filter.model";
49
- import {FilterRequest} from "../../base-model/filter-request";
50
- import {
51
- ADD_NEW_RECORD_ACTION,
52
- ButtonActionSettings,
53
- EMPTY_PAGE_INFO,
54
- FRONT_END_COLUMN_TYPES,
55
- PageInfo,
56
- SELECT_RECORD_ACTION, TABLE_RECORD_ACTION,
57
- TableColumn
58
- } from "../../base-model";
59
- import {ReportRequest} from "../../base-model/report-request.model";
60
- import {TablePageUserAction} from "../../base-model/table-page-user-action.interface";
61
- import {Workflow} from "../../base-model/workflow/workflow.model";
62
- import {ResponseEnvelop} from "../../base-model/response-envelop.model";
63
- import {Router} from "@angular/router";
64
- import {MatLabel} from "@angular/material/form-field";
65
- import {MatChipListbox, MatChipOption} from "@angular/material/chips";
66
- import {MatButtonToggle, MatButtonToggleGroup} from "@angular/material/button-toggle";
67
- import {TitleBarComponent} from "../title-bar/title-bar.component";
68
- import {PaginatorComponent} from "../paginator/paginator.component";
69
- import {MatCheckbox} from "@angular/material/checkbox";
70
-
71
- @Component({
72
- selector: 'app-base-table',
73
- standalone: true,
74
- templateUrl: './base-table.component.html',
75
- styleUrls: ['./base-table.component.scss'],
76
- animations: [],
77
- imports: [
78
- NgStyle,
79
- NgClass,
80
- TranslateModule,
81
- MatIcon,
82
- MatSortModule,
83
- MatColumnDef,
84
- MatHeaderCellDef,
85
- NgIf,
86
- MatTable,
87
- MatHeaderCell,
88
- NgSwitch,
89
- MatButtonModule,
90
- MatCell,
91
- MatCellDef,
92
- DatePipe,
93
- CurrencyPipe,
94
- NgxPaginationModule,
95
- MatRow,
96
- MatRowDef,
97
- MatHeaderRow,
98
- NgSwitchCase,
99
- NgSwitchDefault,
100
- MatHeaderRowDef,
101
- MatIconButton,
102
- NgForOf,
103
- JsonPipe,
104
- FlexLayoutModule,
105
- MatButton,
106
- ButtonActionsComponent,
107
- MatLabel,
108
- MatChipListbox,
109
- MatChipOption,
110
- MatButtonToggleGroup,
111
- MatButtonToggle,
112
- TitleBarComponent,
113
- PaginatorComponent,
114
- DecimalPipe,
115
- MatCheckbox,
116
- ]
117
- })
118
- export class BaseTableComponent extends BaseUtils implements OnInit, OnChanges, OnDestroy {
119
-
120
- collection = {count: 60, data: []};
121
- config = {
122
- itemsPerPage: 15,
123
- currentPage: 1,
124
- totalItems: this.collection.count
125
- };
126
- public maxSize: number = 7;
127
- public directionLinks: boolean = true;
128
- public autoHide: boolean = false;
129
- public responsive: boolean = true;
130
- public labels: any = {
131
- previousLabel: '<',
132
- nextLabel: '>',
133
- screenReaderPaginationLabel: 'Pagination',
134
- screenReaderPageLabel: 'page',
135
- screenReaderCurrentLabel: `You're on page`
136
- };
137
-
138
- totalElements = 0;
139
- pagesCount = 0;
140
- pageIndex = 0;
141
- private selectedStatusFilter: Filter[] = [];
142
- advancedAppliedFilter: any[] = [];
143
- searchStr: string = '';
144
- private filterRequest: FilterRequest = new FilterRequest();
145
- private timer: any;
146
- @Input()
147
- override pageInfo: PageInfo = EMPTY_PAGE_INFO;
148
-
149
- @Input()
150
- enablePagination: boolean = true;
151
-
152
- @Input() data?: MatTableDataSource<any>;
153
- @Input()
154
- listAction: ButtonActionSettings[] = [];
155
-
156
- @Input()
157
- columns: TableColumn<any>[];
158
-
159
- @Input()
160
- filters: Filter[] = [];
161
-
162
- @Input() //@ts-ignore
163
- pathParam: number;
164
-
165
- @Input() //@ts-ignore
166
- extraButton: string;
167
-
168
- @Input() //@ts-ignore
169
- enforceRefresh: boolean = false;
170
-
171
- @Input()
172
- isPending: boolean = false;
173
-
174
- @Input()
175
- trigger: boolean = false;
176
-
177
- @Input()
178
- reportRequest: ReportRequest = new ReportRequest({});
179
-
180
- @Input()
181
- separateEndpointData: any;
182
- @Input()
183
- manageablePages: boolean = false;
184
- @Input()
185
- totalPagesCount: number = 0;
186
- @Input()
187
- currentPageIndex: number = 0;
188
-
189
- @Output()
190
- pageChange: EventEmitter<any> = new EventEmitter();
191
-
192
-
193
- @Output()
194
- userAction: EventEmitter<TablePageUserAction> = new EventEmitter<TablePageUserAction>();
195
- @Output()
196
- hyperLinkAction: EventEmitter<TablePageUserAction> = new EventEmitter<TablePageUserAction>();
197
-
198
- @Output()
199
- extraAction: EventEmitter<TablePageUserAction> = new EventEmitter<TablePageUserAction>();
200
-
201
- @Output()
202
- listActionClicked: EventEmitter<{ action: ButtonActionSettings, row: any }> = new EventEmitter<{
203
- action: ButtonActionSettings,
204
- row: any
205
- }>();
206
-
207
- @Output()
208
- showDialog: EventEmitter<any> = new EventEmitter<any>();
209
-
210
- usedWorkflow!: Workflow;
211
-
212
- mode:any;
213
-
214
- @Input()
215
- customizedData?: MatTableDataSource<any>;
216
- dataSource: MatTableDataSource<any>;
217
- selectedRowIndex = -1;
218
- noDataFound = false;
219
- totalRequiredCountItem = 0;
220
-
221
-
222
-
223
- @Output()
224
- clickRoutePage: EventEmitter<any> = new EventEmitter<any>();
225
-
226
- constructor(
227
- private backendService: BackendService,
228
- public translateService: TranslateService,
229
- public shareDataService: ShareDataService,
230
- @Inject('securityManager') private securityManager: any,
231
- private router: Router,
232
- ) {
233
- super();
234
- this.dataSource = new MatTableDataSource();
235
- this.columns = [];
236
- this.filterRequest = new FilterRequest();
237
-
238
- effect(() => {
239
- if (this.pageInfo.lazyLoadData !== true || this.enforceRefresh === true) {
240
- this.loadData();
241
- }
242
- });
243
-
244
- }
245
-
246
- ngOnDestroy(): void {
247
- console.log('Component Destroyed ');
248
- }
249
-
250
- ngOnInit(): void {
251
- this.backendService.isEmptyItems = this.dataSource.data.length <= 0;
252
- if (this.customizedData) {
253
- this.dataSource = this.customizedData;
254
- }
255
- if(this.manageablePages) {
256
- this.pagesCount = this.totalPagesCount;
257
- this.pageIndex = this.currentPageIndex;
258
- }
259
- console.log(`${this.customizedData?.data},${this.dataSource.data?.length > 0} && ${!this.pageInfo.hidePagination} from Down ***** manage ${this.manageablePages}, page Count ${this.pagesCount}, page Index ${this.pageIndex}, ${this.totalPagesCount},${this.currentPageIndex}`);
260
-
261
- }
262
-
263
- onPageChange(event: number) {
264
- this.getNext(event - 1);
265
- if(this.manageablePages){
266
- this.pageChange.emit(event);
267
- }else {
268
- this.getNext(event - 1);
269
- }
270
- this.config.currentPage = event;
271
- }
272
-
273
- extractFieldName(element: any, property: string) {
274
- if (property.includes('.')) {
275
- return property.split('.').reduce((acc, part) => acc && acc[part], element);
276
- } else {
277
- const c = this.columns.find(c => c.property === property);
278
- if (Array.isArray(element[property]) && c.arraySubProperty ) {
279
- const fieldValues = element[property].map(f => f[c.arraySubProperty]);
280
- return fieldValues.join(', ');
281
- }else {
282
- return element[property];
283
- }
284
- }
285
- }
286
-
287
- get visibleColumns() {
288
- this.buildGroups()
289
- return this.columns.filter(column => column.visible).map(column => column.property);
290
- }
291
-
292
- getNext($event: number) {
293
- this.reportRequest.filterRequest.pageIndex = $event;
294
- this.loadData()
295
- }
296
-
297
- private loadData() {
298
- clearTimeout(this.timer);
299
- if (!this.reportRequest.filterRequest) {
300
- this.reportRequest.filterRequest = new FilterRequest(this.pageInfo.pageSize);
301
- this.reportRequest.filterRequest.filters = [];
302
- }
303
- if (this.separateEndpointData || !this.pageInfo.apiUri || this.pageInfo.apiUri.length === 0) {
304
- this.dataSource.data = this.separateEndpointData;
305
- } else if(this.reportRequest == undefined){
306
- return;
307
- } else if(!this.manageablePages) {
308
- this.timer = setTimeout(() => {
309
- this.reportRequest.filterRequest.columns = this.columns?.filter(c => FRONT_END_COLUMN_TYPES.indexOf(c.type) < 0 ).map(c => c.property) || [];
310
- this.reportRequest.filterRequest.pendingPage = this.isPending;
311
- if (this.filters?.length>0) {
312
- this.reportRequest.filterRequest.filters = this.reportRequest.filterRequest.filters.concat(this.filters);
313
- }
314
- this.backendService.getItemsByFilter(this.reportRequest?.filterRequest, this.pageInfo.apiUri).subscribe(resp => {
315
- const responseEnvelope = new ResponseEnvelop(resp);
316
- if (responseEnvelope.valid) {
317
- this.totalRequiredCountItem = this.reportRequest.filterRequest.pageSize
318
- this.noDataFound = responseEnvelope.body.length < 1;
319
- this.dataSource.data = responseEnvelope.body;
320
- this.backendService.isEmptyItems = this.dataSource.data.length <= 0;
321
- this.totalElements = responseEnvelope.totalSize || 0;
322
- this.pagesCount = responseEnvelope.pagesCount || 1;
323
- this.pageIndex = this.reportRequest.filterRequest.pageIndex + 1;
324
- this.config.totalItems = responseEnvelope.totalSize || 0;
325
- this.config.currentPage = this.pageIndex + 1;
326
- // this.pageSize = this.reportRequest.filterRequest.pageSize;
327
- }
328
- });
329
- }
330
- , 300);
331
- }
332
- }
333
-
334
- getStatusDescription(element: any) {
335
- return this.backendService.getStatusDescription(element, this.usedWorkflow);
336
- }
337
-
338
- getStateType(element: any) {
339
- return element.stateType
340
- }
341
-
342
- ngOnChanges(changes: SimpleChanges): void {
343
- if (changes["customizedData"] && !changes["customizedData"].isFirstChange()) {
344
- this.dataSource.data = changes["customizedData"].currentValue?.data || []; // Update data source with new data
345
- this.pagesCount=this.totalPagesCount;
346
- this.pageIndex=this.currentPageIndex;
347
- }
348
- if (changes["enforceRefresh"] && !changes["enforceRefresh"].isFirstChange()) {
349
- this.loadData();
350
- }
351
- }
352
- getCroppedText(elementValue: any, subWidth: number = 20) {
353
- return elementValue && elementValue.length > subWidth ? elementValue.substring(0, subWidth) + "..." : elementValue;
354
- }
355
-
356
- emitEvent(element: any) {
357
- this.showDialog.emit(element);
358
- }
359
-
360
- extractFormat(column: TableColumn<any>) {
361
- return column?.format || 'd/M/yyyy, h:mm a';
362
- }
363
-
364
- actionListClicked(listAction: ButtonActionSettings, element: any) {
365
- this.listActionClicked.emit({action:listAction, row: element});
366
- }
367
-
368
- hyperLinkClicked(actionName: string, element: any) {
369
- const action = TABLE_RECORD_ACTION;
370
- action.actionKey = actionName;
371
- action.item = element;
372
- action.pageInfo = this.pageInfo;
373
- this.hyperLinkAction.emit(action)
374
- }
375
-
376
-
377
- emitRoutePage(element: any){
378
- this.clickRoutePage.emit(element);
379
- }
380
-
381
- onSelectItem(row: any) {
382
- // console.log('row', row)
383
- if (this.pageInfo.selfRouting) {
384
- const mode = this.isPending ? 'pending' : 'view';
385
- const url = `${this.pageInfo.listRoutePath || this.router.url}/view`;
386
- const encryptedId = this.backendService.encrypt(row.id+"");
387
- const encryptedMode = this.backendService.encrypt(mode);
388
- this.router.navigate([`${url}`],
389
- { queryParams: { token: encryptedId , mode : encryptedMode } });
390
- return;
391
- }
392
- // const action = SELECT_RECORD_ACTION;
393
- // action.id = row?.id;
394
- // action.item = row;
395
- // this.userAction.emit(action)
396
- }
397
-
398
- openNewTab(row) {
399
- if (!this.pageInfo.embededTableOnly) {
400
- const mode = this.isPending ? 'pending' : 'view';
401
- window.open(`${this.pageInfo.listRoutePath}/${mode}` + '/' + row?.id);
402
- }
403
- }
404
-
405
- switchViewMode(b: boolean) {
406
- this.isPending = !this.isPending;
407
- this.loadData();
408
- }
409
-
410
- onAddNewAction($event: any) {
411
- const url = `${this.pageInfo.listRoutePath || this.router.url}/view`;
412
- const encryptedId = this.backendService.encrypt("-1");
413
- const encryptedMode = this.backendService.encrypt("pending");
414
- this.router.navigate([`${url}`],
415
- { queryParams: { token: encryptedId , mode : encryptedMode } });
416
-
417
- // const action = SELECT_RECORD_ACTION;
418
- // action.id = row?.id;
419
- // action.item = row;
420
- // this.userAction.emit(action)
421
- }
422
-
423
- showAddNew() {
424
- return this.pageInfo.hasAddButton ;
425
- }
426
-
427
- onExtraButtionAction($event: any) {
428
- this.extraAction.emit($event);
429
-
430
- }
431
-
432
- hasGroups() {
433
- let b = this.columns.findIndex(p => p.group);
434
- return b >= 0;
435
- }
436
- groupNames: any = []
437
- groupSpans: Map<string, number> = new Map();
438
-
439
- buildGroups(){
440
- let count = 0;
441
- this.groupNames = [];
442
- this.groupSpans.clear();
443
- if(this.hasGroups() === false){
444
- return;
445
- }
446
- this.columns
447
- .filter(column => column.visible === true)
448
- .forEach((column) => {
449
- if (column.group === "-") {
450
- this.groupNames.push(count.toString());
451
- this.insertInMap(count);
452
- count++;
453
- return;
454
- } else if (!this.groupNames.includes(column.group)) {
455
- this.groupNames.push(column.group);
456
- this.insertInMap(column.group);
457
- return;
458
- }
459
- this.insertInMap(column.group);
460
- });
461
- }
462
-
463
- insertInMap(key){
464
- if(this.groupSpans.has(key)){
465
- this.groupSpans.set(key.toString(), this.groupSpans.get(key) + 1);
466
- } else {
467
- this.groupSpans.set(key.toString(), 1);
468
- }
469
- }
470
-
471
- isHumanMade(str){
472
- return isNaN(str);
473
- }
474
-
475
- actionButtonClicked(actionKey: string, item: any): void {
476
- if (actionKey === 'navigate') {
477
- this.handleNavigateAction(item);
478
- return;
479
- }
480
-
481
- this.emitTableAction(actionKey, item);
482
- }
483
-
484
- private handleNavigateAction(item: any): void {
485
- const mode = this.isPending ? 'pending' : 'view';
486
- const basePath = this.pageInfo.listRoutePath || this.router.url;
487
- const url = `${basePath}/view`;
488
-
489
- const encryptedId = this.backendService.encrypt(item.id.toString());
490
- const encryptedMode = this.backendService.encrypt(mode);
491
-
492
- this.router.navigate([url], {
493
- queryParams: { token: encryptedId, mode: encryptedMode }
494
- });
495
- }
496
-
497
- private emitTableAction(actionKey: string, item: any): void {
498
- const action = TABLE_RECORD_ACTION;
499
- action.actionKey = actionKey;
500
- action.item = item;
501
- action.pageInfo = this.pageInfo;
502
- this.userAction.emit(action);
503
- }
504
-
505
- extractReport(reportType: any) {
506
- const myFilters = this.reportRequest.filterRequest;
507
- const reportRequest = this.backendService.buildReportRequest(this.columns, this.pageInfo.labelsSection + '.list_title',
508
- myFilters, reportType, this.pageInfo, this.searchStr, 'LANDSCAPE');
509
- this.backendService.downloadReport(reportRequest, this.pageInfo.apiUri);
510
- }
511
-
512
- getIcon(status: string): string {
513
- switch (status) {
514
- case 'pass': return 'check_circle';
515
- case 'warning': return 'warning';
516
- case 'error': return 'error';
517
- default: return 'help';
518
- }
519
- }
520
-
521
- actionCheckedClicked(property: string, element) {
522
- element[property]= !element[property];
523
- this.actionButtonClicked(property, element);
524
- }
525
-
526
-
527
- isDarkHighlight(row: any): boolean {
528
- const groupByProp = this.pageInfo?.groupByProperty;
529
- const groupByValues = this.pageInfo?.groupByValue;
530
-
531
- if (!groupByProp || !groupByValues || !row[groupByProp]) {
532
- return false;
533
- }
534
-
535
- const cellValue = row[groupByProp].toString();
536
-
537
- return groupByValues.some(val =>
538
- cellValue.includes(val) && cellValue.length > val.length
539
- );
540
- }
541
-
542
- shouldRenderAsHyperLink(element: any): boolean {
543
- const groupByProp = this.pageInfo?.groupByProperty;
544
- const groupByValues = this.pageInfo?.groupByValue;
545
-
546
- if (!groupByProp || !groupByValues || !element[groupByProp]) {
547
- return false;
548
- }
549
-
550
- const value = element[groupByProp].toString();
551
-
552
- return !groupByValues.some(v => value.includes(v) && value.length >= v.length);
553
- }
554
-
555
- shouldShowButton(element: any): boolean {
556
- const groupByProp = this.pageInfo?.groupByProperty;
557
- const groupByValues = this.pageInfo?.groupByValue;
558
-
559
- if (!groupByProp || !groupByValues || !element[groupByProp]) {
560
- return true;
561
- }
562
-
563
- const value = element[groupByProp].toString();
564
-
565
- return !groupByValues.some(v => value.includes(v) && value.length >= v.length);
566
- }
567
-
568
- }
1
+ import {
2
+ ChangeDetectorRef,
3
+ Component,
4
+ effect,
5
+ EventEmitter,
6
+ Inject,
7
+ Input,
8
+ OnChanges, OnDestroy,
9
+ OnInit,
10
+ Output,
11
+ SimpleChanges
12
+ } from "@angular/core";
13
+ import {
14
+ MatCell,
15
+ MatCellDef,
16
+ MatColumnDef,
17
+ MatHeaderCell,
18
+ MatHeaderCellDef,
19
+ MatHeaderRow,
20
+ MatHeaderRowDef,
21
+ MatRow,
22
+ MatRowDef,
23
+ MatTable,
24
+ MatTableDataSource
25
+ } from "@angular/material/table";
26
+ import {TranslateModule, TranslateService} from "@ngx-translate/core";
27
+ import {MatSortModule, Sort} from "@angular/material/sort";
28
+ import {
29
+ CurrencyPipe,
30
+ DatePipe, DecimalPipe,
31
+ JsonPipe,
32
+ NgClass,
33
+ NgForOf,
34
+ NgIf,
35
+ NgStyle,
36
+ NgSwitch,
37
+ NgSwitchCase,
38
+ NgSwitchDefault, UpperCasePipe
39
+ } from "@angular/common";
40
+ import {MatIcon} from "@angular/material/icon";
41
+ import {MatButton, MatButtonModule, MatIconButton} from "@angular/material/button";
42
+ import {NgxPaginationModule} from "ngx-pagination";
43
+ import {ButtonActionsComponent} from "../button-actions/button-actions.component";
44
+ import {ShareDataService} from "../../services/trigger-form.service";
45
+ import {BaseUtils} from "../../utils/base-utils";
46
+ import {BackendService} from "../../services/backend-service";
47
+ import {Filter} from "../../base-model/filter.model";
48
+ import {FilterRequest} from "../../base-model/filter-request";
49
+ import {
50
+ ADD_NEW_RECORD_ACTION,
51
+ ButtonActionSettings,
52
+ EMPTY_PAGE_INFO, FieldInfo,
53
+ FRONT_END_COLUMN_TYPES,
54
+ PageInfo,
55
+ SELECT_RECORD_ACTION, TABLE_RECORD_ACTION,
56
+ TableColumn
57
+ } from "../../base-model";
58
+ import {ReportRequest} from "../../base-model/report-request.model";
59
+ import {TablePageUserAction} from "../../base-model/table-page-user-action.interface";
60
+ import {Workflow} from "../../base-model/workflow/workflow.model";
61
+ import {ResponseEnvelop} from "../../base-model/response-envelop.model";
62
+ import {Router} from "@angular/router";
63
+ import {MatLabel} from "@angular/material/form-field";
64
+ import {MatChipListbox, MatChipOption} from "@angular/material/chips";
65
+ import {MatButtonToggle, MatButtonToggleGroup} from "@angular/material/button-toggle";
66
+ import {TitleBarComponent} from "../title-bar/title-bar.component";
67
+ import {PaginatorComponent} from "../paginator/paginator.component";
68
+ import {MatCheckbox} from "@angular/material/checkbox";
69
+ import {BaseFormCanvasComponent} from "../base-form-canvas/base-form-canvas.component";
70
+ import {FilterBuilderComponent} from "../advanced-filter/filter-builder/filter-builder.component";
71
+ import {FieldFilter} from "../../base-model/field-filter.model";
72
+ import {MatMenu, MatMenuItem, MatMenuTrigger} from "@angular/material/menu";
73
+
74
+ @Component({
75
+ selector: 'app-base-table',
76
+ standalone: true,
77
+ templateUrl: './base-table.component.html',
78
+ styleUrls: ['./base-table.component.scss'],
79
+ animations: [],
80
+ imports: [
81
+ NgStyle,
82
+ NgClass,
83
+ TranslateModule,
84
+ MatIcon,
85
+ MatSortModule,
86
+ MatColumnDef,
87
+ MatHeaderCellDef,
88
+ NgIf,
89
+ MatTable,
90
+ MatHeaderCell,
91
+ NgSwitch,
92
+ MatButtonModule,
93
+ MatCell,
94
+ MatCellDef,
95
+ DatePipe,
96
+ CurrencyPipe,
97
+ NgxPaginationModule,
98
+ MatRow,
99
+ MatRowDef,
100
+ MatHeaderRow,
101
+ NgSwitchCase,
102
+ NgSwitchDefault,
103
+ MatHeaderRowDef,
104
+ MatIconButton,
105
+ NgForOf,
106
+ JsonPipe,
107
+ MatButton,
108
+ ButtonActionsComponent,
109
+ MatLabel,
110
+ MatChipListbox,
111
+ MatChipOption,
112
+ MatButtonToggleGroup,
113
+ MatButtonToggle,
114
+ TitleBarComponent,
115
+ PaginatorComponent,
116
+ DecimalPipe,
117
+ MatCheckbox,
118
+ BaseFormCanvasComponent,
119
+ FilterBuilderComponent,
120
+ MatMenuTrigger,
121
+ MatMenu,
122
+ MatMenuItem,
123
+ UpperCasePipe,
124
+ ]
125
+ })
126
+ export class BaseTableComponent extends BaseUtils implements OnInit, OnChanges, OnDestroy {
127
+ types: string[] = ["pdf", "csv", "xlsx"]
128
+ collection = {count: 60, data: []};
129
+ config = {
130
+ itemsPerPage: 15,
131
+ currentPage: 1,
132
+ totalItems: this.collection.count
133
+ };
134
+ public maxSize: number = 7;
135
+ public directionLinks: boolean = true;
136
+ public autoHide: boolean = false;
137
+ public responsive: boolean = true;
138
+ public labels: any = {
139
+ previousLabel: '<',
140
+ nextLabel: '>',
141
+ screenReaderPaginationLabel: 'Pagination',
142
+ screenReaderPageLabel: 'page',
143
+ screenReaderCurrentLabel: `You're on page`
144
+ };
145
+
146
+ @Input()
147
+ filterFields: FieldInfo[];
148
+ @Input() noDataFoundIcon = 'close';
149
+ @Input() noDataFoundTitle = 'noDataFoundTitle';
150
+ @Input() noDataFoundSubtitle = 'noDataFoundSubtitle';
151
+ totalElements = 0;
152
+ pagesCount = 0;
153
+ pageIndex = 1;
154
+ pageSize = 15;
155
+ private selectedStatusFilter: Filter[] = [];
156
+ advancedAppliedFilter: any[] = [];
157
+ searchStr: string = '';
158
+ private filterRequest: FilterRequest = new FilterRequest();
159
+ private timer: any;
160
+ @Input()
161
+ override pageInfo: PageInfo = EMPTY_PAGE_INFO;
162
+
163
+ @Input()
164
+ enablePagination: boolean = true;
165
+
166
+ @Input() data?: MatTableDataSource<any>;
167
+ @Input()
168
+ listAction: ButtonActionSettings[] = [];
169
+
170
+ @Input()
171
+ columns: TableColumn<any>[];
172
+
173
+ @Input()
174
+ filters: Filter[] = [];
175
+
176
+ @Input() //@ts-ignore
177
+ pathParam: number;
178
+
179
+ @Input() //@ts-ignore
180
+ extraButton: string;
181
+
182
+ @Input() //@ts-ignore
183
+ enforceRefresh: boolean = false;
184
+
185
+ @Input()
186
+ isPending: boolean = false;
187
+
188
+ @Input()
189
+ trigger: boolean = false;
190
+
191
+ @Input()
192
+ reportRequest: ReportRequest = new ReportRequest({});
193
+
194
+ @Input()
195
+ separateEndpointData: any;
196
+ @Input()
197
+ manageablePages: boolean = false;
198
+ @Input()
199
+ totalPagesCount: number = 0;
200
+ @Input()
201
+ currentPageIndex: number = 0;
202
+
203
+ @Output()
204
+ pageChange: EventEmitter<any> = new EventEmitter();
205
+
206
+
207
+ @Output()
208
+ userAction: EventEmitter<TablePageUserAction> = new EventEmitter<TablePageUserAction>();
209
+ @Output()
210
+ hyperLinkAction: EventEmitter<TablePageUserAction> = new EventEmitter<TablePageUserAction>();
211
+
212
+ @Output()
213
+ extraAction: EventEmitter<TablePageUserAction> = new EventEmitter<TablePageUserAction>();
214
+
215
+ @Output()
216
+ selectedColumn: EventEmitter<Sort> = new EventEmitter<Sort>();
217
+
218
+ @Output()
219
+ listActionClicked: EventEmitter<{ action: ButtonActionSettings, row: any }> = new EventEmitter<{
220
+ action: ButtonActionSettings,
221
+ row: any
222
+ }>();
223
+
224
+ @Output()
225
+ showDialog: EventEmitter<any> = new EventEmitter<any>();
226
+
227
+ usedWorkflow!: Workflow;
228
+
229
+ mode:any;
230
+
231
+ @Input()
232
+ customizedData?: MatTableDataSource<any>;
233
+ dataSource: MatTableDataSource<any>;
234
+ selectedRowIndex = -1;
235
+ noDataFound = false;
236
+ totalRequiredCountItem = 0;
237
+
238
+
239
+ @Output()
240
+ clickRoutePage: EventEmitter<any> = new EventEmitter<any>();
241
+
242
+ constructor(
243
+ private backendService: BackendService,
244
+ public translateService: TranslateService,
245
+ public shareDataService: ShareDataService,
246
+ @Inject('securityManager') private securityManager: any,
247
+ private router: Router,
248
+ ) {
249
+ super();
250
+ this.dataSource = new MatTableDataSource();
251
+ this.columns = [];
252
+ this.filterRequest = new FilterRequest();
253
+
254
+ effect(() => {
255
+ if (this.pageInfo.lazyLoadData !== true || this.enforceRefresh === true) {
256
+ this.loadData();
257
+ }
258
+ });
259
+
260
+ }
261
+
262
+ ngOnDestroy(): void {
263
+ }
264
+
265
+ ngOnInit(): void {
266
+ this.backendService.isEmptyItems = this.dataSource.data.length <= 0;
267
+ if (this.customizedData) {
268
+ this.dataSource = this.customizedData;
269
+ }
270
+ if(this.manageablePages) {
271
+ this.pagesCount = this.totalPagesCount;
272
+ this.pageIndex = this.currentPageIndex;
273
+ }
274
+
275
+ }
276
+
277
+ onPageChange(event: number) {
278
+ this.pageIndex = event;
279
+ this.getNext(this.pageIndex - 1);
280
+ if (this.manageablePages) {
281
+ this.pageChange.emit(this.pageIndex);
282
+ }
283
+ }
284
+
285
+
286
+ extractFieldName(element: any, property: string) {
287
+ if (property.includes('.')) {
288
+ return property.split('.').reduce((acc, part) => acc && acc[part], element);
289
+ } else {
290
+ const c = this.columns.find(c => c.property === property);
291
+ if (Array.isArray(element[property]) && c.arraySubProperty ) {
292
+ const fieldValues = element[property].map(f => f[c.arraySubProperty]);
293
+ return fieldValues.join(', ');
294
+ }else {
295
+ return element[property];
296
+ }
297
+ }
298
+ }
299
+
300
+ get visibleColumns() {
301
+ this.buildGroups()
302
+ return this.columns.filter(column => column.visible).map(column => column.property);
303
+ }
304
+
305
+ getNext(pageIndex: number) {
306
+ this.reportRequest.filterRequest.pageIndex = pageIndex;
307
+ this.reportRequest.filterRequest.pageSize = this.pageSize;
308
+ this.loadData();
309
+ }
310
+ onPageSizeChange(event: number) {
311
+ this.pageSize = event;
312
+ this.pageIndex = 1; // reset to first page on page size change
313
+ this.reportRequest.filterRequest.pageSize = this.pageSize;
314
+ this.getNext(0);
315
+ }
316
+
317
+
318
+
319
+ private loadData() {
320
+ clearTimeout(this.timer);
321
+ if (!this.reportRequest.filterRequest) {
322
+ this.reportRequest.filterRequest = new FilterRequest(this.pageInfo.pageSize);
323
+ this.reportRequest.filterRequest.filters = this.advancedAppliedFilter;
324
+ }
325
+ if (this.separateEndpointData || !this.pageInfo.apiUri || this.pageInfo.apiUri.length === 0) {
326
+ this.dataSource.data = this.separateEndpointData;
327
+ } else if(this.reportRequest == undefined){
328
+ return;
329
+ } else if(!this.manageablePages) {
330
+ this.timer = setTimeout(() => {
331
+ this.reportRequest.filterRequest.columns = this.columns?.filter(c => FRONT_END_COLUMN_TYPES.indexOf(c.type) < 0 ).map(c => c.property) || [];
332
+ this.reportRequest.filterRequest.pendingPage = this.isPending;
333
+ this.reportRequest.filterRequest.filters = this.advancedAppliedFilter;
334
+ this.backendService.getItemsByFilter(this.reportRequest?.filterRequest, this.pageInfo.apiUri).subscribe(resp => {
335
+ const responseEnvelope = new ResponseEnvelop(resp);
336
+ if (responseEnvelope.valid) {
337
+ this.totalRequiredCountItem = this.reportRequest.filterRequest.pageSize
338
+ this.noDataFound = responseEnvelope.body.length < 1;
339
+ this.dataSource.data = responseEnvelope.body;
340
+ this.backendService.isEmptyItems = this.dataSource.data.length <= 0;
341
+ this.totalElements = responseEnvelope.totalSize || 0;
342
+ this.pagesCount = Math.ceil(this.totalElements / this.pageSize) || 1;
343
+ this.pageIndex = (this.reportRequest.filterRequest.pageIndex || 0) + 1;
344
+ this.config.totalItems = responseEnvelope.totalSize || 0;
345
+ this.config.currentPage = this.pageIndex + 1;
346
+ // this.pageSize = this.reportRequest.filterRequest.pageSize;
347
+ }
348
+ });
349
+ }
350
+ , 300);
351
+ }
352
+ }
353
+
354
+ getStatusDescription(element: any) {
355
+ return this.backendService.getStatusDescription(element, this.usedWorkflow);
356
+ }
357
+
358
+ getStateType(element: any) {
359
+ return element.stateType
360
+ }
361
+
362
+ ngOnChanges(changes: SimpleChanges): void {
363
+ if (changes["customizedData"] && !changes["customizedData"].isFirstChange()) {
364
+ this.dataSource.data = changes["customizedData"].currentValue?.data || []; // Update data source with new data
365
+ this.pagesCount=this.totalPagesCount;
366
+ this.pageIndex=this.currentPageIndex;
367
+ }
368
+ if (changes["enforceRefresh"] && !changes["enforceRefresh"].isFirstChange()) {
369
+ this.loadData();
370
+ }
371
+ }
372
+ getCroppedText(elementValue: any, subWidth: number = 20) {
373
+ return elementValue && elementValue.length > subWidth ? elementValue.substring(0, subWidth) + "..." : elementValue;
374
+ }
375
+
376
+ emitEvent(element: any) {
377
+ this.showDialog.emit(element);
378
+ }
379
+
380
+ extractFormat(column: TableColumn<any>) {
381
+ return column?.format || 'd/M/yyyy, h:mm a';
382
+ }
383
+
384
+ actionListClicked(listAction: ButtonActionSettings, element: any) {
385
+ this.listActionClicked.emit({action:listAction, row: element});
386
+ }
387
+
388
+ hyperLinkClicked(actionName: string, element: any) {
389
+ const action = TABLE_RECORD_ACTION;
390
+ action.actionKey = actionName;
391
+ action.item = element;
392
+ action.pageInfo = this.pageInfo;
393
+ this.hyperLinkAction.emit(action)
394
+ }
395
+
396
+
397
+ emitRoutePage(element: any){
398
+ this.clickRoutePage.emit(element);
399
+ }
400
+
401
+ onSelectItem(row: any) {
402
+ if (this.pageInfo.selfRouting) {
403
+ const mode = this.isPending ? 'pending' : 'view';
404
+ const url = `${this.pageInfo.listRoutePath || this.router.url}/view`;
405
+
406
+ const encryptedId = this.backendService.encrypt(String(row.id));
407
+ const encryptedMode = this.backendService.encrypt(mode);
408
+
409
+ const encryptedRow = this.backendService.encrypt(JSON.stringify(row));
410
+
411
+ this.router.navigate([url], {
412
+ queryParams: { token: encryptedId, mode: encryptedMode },
413
+ state: { raw: encryptedRow },
414
+ });
415
+ return;
416
+ }
417
+ // const action = SELECT_RECORD_ACTION;
418
+ // action.id = row?.id;
419
+ // action.item = row;
420
+ // this.userAction.emit(action)
421
+ }
422
+
423
+ openNewTab(row) {
424
+ if (!this.pageInfo.embededTableOnly) {
425
+ const mode = this.isPending ? 'pending' : 'view';
426
+ window.open(`${this.pageInfo.listRoutePath}/${mode}` + '/' + row?.id);
427
+ }
428
+ }
429
+
430
+ switchViewMode(b: boolean) {
431
+ this.isPending = !this.isPending;
432
+ this.loadData();
433
+ }
434
+
435
+ onAddNewAction($event: any) {
436
+ const url = `${this.pageInfo.listRoutePath || this.router.url}/view`;
437
+ const encryptedId = this.backendService.encrypt("-1");
438
+ const encryptedMode = this.backendService.encrypt("pending");
439
+ this.router.navigate([`${url}`],
440
+ { queryParams: { token: encryptedId , mode : encryptedMode } });
441
+
442
+ // const action = SELECT_RECORD_ACTION;
443
+ // action.id = row?.id;
444
+ // action.item = row;
445
+ // this.userAction.emit(action)
446
+ }
447
+
448
+ showAddNew() {
449
+ return this.pageInfo.hasAddButton ;
450
+ }
451
+
452
+ onExtraButtionAction($event: any) {
453
+ this.extraAction.emit($event);
454
+
455
+ }
456
+
457
+ hasGroups() {
458
+ let b = this.columns.findIndex(p => p.group);
459
+ return b >= 0;
460
+ }
461
+ groupNames: any = []
462
+ groupSpans: Map<string, number> = new Map();
463
+
464
+ buildGroups(){
465
+ let count = 0;
466
+ this.groupNames = [];
467
+ this.groupSpans.clear();
468
+ if(this.hasGroups() === false){
469
+ return;
470
+ }
471
+ this.columns
472
+ .filter(column => column.visible === true)
473
+ .forEach((column) => {
474
+ if (column.group === "-") {
475
+ this.groupNames.push(count.toString());
476
+ this.insertInMap(count);
477
+ count++;
478
+ return;
479
+ } else if (!this.groupNames.includes(column.group)) {
480
+ this.groupNames.push(column.group);
481
+ this.insertInMap(column.group);
482
+ return;
483
+ }
484
+ this.insertInMap(column.group);
485
+ });
486
+ }
487
+
488
+ insertInMap(key){
489
+ if(this.groupSpans.has(key)){
490
+ this.groupSpans.set(key.toString(), this.groupSpans.get(key) + 1);
491
+ } else {
492
+ this.groupSpans.set(key.toString(), 1);
493
+ }
494
+ }
495
+
496
+ isHumanMade(str){
497
+ return isNaN(str);
498
+ }
499
+
500
+ actionButtonClicked(actionKey: string, item: any): void {
501
+ if (actionKey === 'navigate') {
502
+ this.handleNavigateAction(item);
503
+ return;
504
+ }
505
+
506
+ this.emitTableAction(actionKey, item);
507
+ }
508
+
509
+ private handleNavigateAction(item: any): void {
510
+ const mode = this.isPending ? 'pending' : 'view';
511
+ const basePath = this.pageInfo.listRoutePath || this.router.url;
512
+ const url = `${basePath}/view`;
513
+
514
+ const encryptedId = this.backendService.encrypt(item.id.toString());
515
+ const encryptedMode = this.backendService.encrypt(mode);
516
+
517
+ this.router.navigate([url], {
518
+ queryParams: { token: encryptedId, mode: encryptedMode }
519
+ });
520
+ }
521
+
522
+ private emitTableAction(actionKey: string, item: any): void {
523
+ const action = TABLE_RECORD_ACTION;
524
+ action.actionKey = actionKey;
525
+ action.item = item;
526
+ action.pageInfo = this.pageInfo;
527
+ this.userAction.emit(action);
528
+ }
529
+
530
+ extractReport(reportType: any) {
531
+ const myFilters = this.reportRequest.filterRequest;
532
+ const reportRequest = this.backendService.buildReportRequest(this.columns, this.pageInfo.labelsSection + '.list_title',
533
+ myFilters, reportType, this.pageInfo, this.searchStr, 'LANDSCAPE');
534
+ this.backendService.downloadReport(reportRequest, this.pageInfo.apiUri);
535
+ }
536
+
537
+ getIcon(status: string): string {
538
+ switch (status) {
539
+ case 'pass': return 'check_circle';
540
+ case 'warning': return 'warning';
541
+ case 'error': return 'error';
542
+ default: return 'help';
543
+ }
544
+ }
545
+
546
+ actionCheckedClicked(property: string, element) {
547
+ element[property]= !element[property];
548
+ this.actionButtonClicked(property, element);
549
+ }
550
+
551
+
552
+ isDarkHighlight(row: any): boolean {
553
+ const groupByProp = this.pageInfo?.groupByProperty;
554
+ const groupByValues = this.pageInfo?.groupByValue;
555
+
556
+ if (!groupByProp || !groupByValues || !row[groupByProp]) {
557
+ return false;
558
+ }
559
+
560
+ const cellValue = row[groupByProp].toString();
561
+
562
+ return groupByValues.some(val =>
563
+ cellValue.includes(val) && cellValue.length > val.length
564
+ );
565
+ }
566
+
567
+ shouldRenderAsHyperLink(element: any): boolean {
568
+ const groupByProp = this.pageInfo?.groupByProperty;
569
+ const groupByValues = this.pageInfo?.groupByValue;
570
+
571
+ if (!groupByProp || !groupByValues || !element[groupByProp]) {
572
+ return false;
573
+ }
574
+
575
+ const value = element[groupByProp].toString();
576
+
577
+ return !groupByValues.some(v => value.includes(v) && value.length >= v.length);
578
+ }
579
+
580
+
581
+ onSortAction($event: Sort) {
582
+ this.reportRequest.filterRequest.sortKey = $event.active && $event.direction ?
583
+ this.columns.find(c => c.property === $event.active)?.orderByProperty || $event.active
584
+ : 'id';
585
+ this.reportRequest.filterRequest.sortDirection = $event.direction === 'asc' ? 'ASC' : 'DESC';
586
+ this.reportRequest.filterRequest.pageIndex = 0;
587
+ this.selectedColumn.emit($event);
588
+ this.loadData();
589
+ }
590
+
591
+ shouldShowButton(element: any): boolean {
592
+ const groupByProp = this.pageInfo?.groupByProperty;
593
+ const groupByValues = this.pageInfo?.groupByValue;
594
+
595
+ if (!groupByProp || !groupByValues || !element[groupByProp]) {
596
+ return true;
597
+ }
598
+
599
+ const value = element[groupByProp].toString();
600
+
601
+ return !groupByValues.some(v => value.includes(v) && value.length >= v.length);
602
+ }
603
+ doAdvancedSearch($event: FieldFilter[]) {
604
+ this.advancedAppliedFilter = [];
605
+ if ($event.length === 0) {
606
+ this.advancedAppliedFilter = [];
607
+ this.loadData();
608
+ // this.paginator.firstPage();
609
+ } else {
610
+ this.advancedAppliedFilter = $event;
611
+ this.loadData();
612
+ }
613
+ }
614
+ resetData($event: boolean) {
615
+ if ($event) {
616
+ this.advancedAppliedFilter = [];
617
+ this.loadData();
618
+ // this.paginator.firstPage();
619
+ }
620
+ }
621
+ }