@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,605 +1,616 @@
1
- import {
2
- Component,
3
- EventEmitter,
4
- Injector,
5
- Input,
6
- OnInit,
7
- Output
8
- } from '@angular/core';
9
- import {FieldInfo} from "../../base-model/field-info";
10
- import {EMPTY_PAGE_INFO, PageInfo} from "../../base-model/page-info";
11
- import {TableColumn} from "../../base-model/table-column.interface";
12
- import {FieldMessage} from "../../base-model/api-response";
13
- import {TranslateModule, TranslateService} from "@ngx-translate/core";
14
- import {BackendService} from "../../services/backend-service";
15
- import {ActivatedRoute, Router} from "@angular/router";
16
- import {FormBuilder, FormGroup} from "@angular/forms";
17
- import {formatDate, NgForOf, NgIf} from "@angular/common";
18
- import {FlexLayoutModule} from "@angular/flex-layout";
19
- import {MatMenu, MatMenuItem, MatMenuTrigger} from "@angular/material/menu";
20
- import {MatButton, MatButtonModule} from "@angular/material/button";
21
- import {BaseTableComponent} from "../base-table/base-table.component";
22
- import {MatIconModule} from "@angular/material/icon";
23
- import {FilterRequest} from "../../base-model/filter-request";
24
- import {ReportRequest} from "../../base-model/report-request.model";
25
- import {Filter} from "../../base-model/filter.model";
26
- import {TitleBarComponent} from "../title-bar/title-bar.component";
27
- import {BaseFormCanvasComponent} from "../base-form-canvas/base-form-canvas.component";
28
- import {DRILL_DOWN_ACTION, JUNIOR_DOWN_ACTION, SnackMessage, TablePageUserAction} from "../../base-model";
29
- import {} from "../audit-log-details-dialog/audit-log-details-dialog.component";
30
- import {MatDialog} from "@angular/material/dialog";
31
- import {ReportDetailsDialogComponent} from "../report-details-dialog/report-details-dialog.component";
32
- import { cloneDeep } from 'lodash';
33
- import {Directionality} from "@angular/cdk/bidi";
34
- import {MatTooltip} from "@angular/material/tooltip";
35
-
36
-
37
- const NON_REPORT_COLUMNS = ['listAction', 'button', 'checkbox'];
38
-
39
- @Component({
40
- selector: 'app-report-form',
41
- standalone: true,
42
- imports: [
43
- FlexLayoutModule,
44
- TitleBarComponent,
45
- BaseFormCanvasComponent,
46
- MatMenu,
47
- MatMenuItem,
48
- NgForOf,
49
- MatMenuTrigger,
50
- MatButtonModule,
51
- TranslateModule,
52
- BaseTableComponent,
53
- NgIf,
54
- MatIconModule,
55
- MatButton,
56
- MatTooltip
57
- ],
58
- templateUrl: './activity-report-form.component.html',
59
- styleUrl: './activity-report-form.component.scss'
60
- })
61
- export class ActivityReportFormComponent implements OnInit{
62
- @Input()
63
- showDetails : any = [];
64
-
65
- @Input()
66
- showExtractButton: boolean = true;
67
-
68
- @Input()
69
- columns: TableColumn<any>[] =[];
70
- private originalColumns: any[] = [];
71
-
72
-
73
- @Input() actionRequestCallback!: (actionRequest: TablePageUserAction) => TablePageUserAction;
74
- @Input() enrichDrillDownReportRequest!: (actionRequest: TablePageUserAction, reportRequest: ReportRequest) => TablePageUserAction;
75
- @Input() enrichHyperLinkReportRequest!: (actionRequest: TablePageUserAction, reportRequest: ReportRequest) => TablePageUserAction;
76
- @Input() enrichJuniorReportRequest!: (actionRequest: TablePageUserAction, reportRequest: ReportRequest) => TablePageUserAction;
77
-
78
- @Output()
79
- userAction: EventEmitter<TablePageUserAction> = new EventEmitter<TablePageUserAction>();
80
- activeLevel: number = 1;
81
- items = [4, 5,6,7];
82
- private filterRequest: FilterRequest;
83
- x: any;
84
- isEditable: boolean = true;
85
- fields: FieldInfo[] = [];
86
- pageInfo: PageInfo = EMPTY_PAGE_INFO;
87
- drillDownPageInfo: PageInfo = EMPTY_PAGE_INFO;
88
- drillDownColumns: TableColumn<any>[] = [];
89
- hideDrillDownButton: false;
90
-
91
- juniorPageInfo: PageInfo = EMPTY_PAGE_INFO;
92
- juniorColumns: TableColumn<any>[] = [];
93
-
94
- columnsDefinition: TableColumn<any>[] = [];
95
- types: string[] = ["pdf", "csv", "xlsx"]
96
- searchStr: string = '';
97
-
98
- errors: FieldMessage[] = [];
99
-
100
- reloadData: boolean = false;
101
- drillDownRequestStack: any[] = [];
102
- reportRequest: ReportRequest = new ReportRequest({});
103
- childReportRequest: ReportRequest = new ReportRequest({});
104
- juniorReportRequest: ReportRequest = new ReportRequest({});
105
- public reportForm: FormGroup;
106
- readyToSearch = false;
107
- private pageSize: any;
108
- private dialogReportRequest: any;
109
- currentDirection: 'ltr' | 'rtl';
110
- protected isComparisonReport: boolean = false;
111
- constructor(private translateService: TranslateService,
112
- public backendService: BackendService,
113
- private activatedRoute: ActivatedRoute,
114
- private injector: Injector,
115
- private router: Router,
116
- private route: ActivatedRoute,
117
- public dialog: MatDialog,
118
- private directionality: Directionality,
119
- private fb: FormBuilder) {
120
- }
121
-
122
- ngOnInit(): void {
123
-
124
- this.currentDirection = this.directionality.value;
125
- this.directionality.change.subscribe((value) => {
126
- this.currentDirection = value;
127
- })
128
-
129
- this.activatedRoute.data.subscribe(data => {
130
- this.pageInfo = data['pageInfo'];
131
- this.pageSize = this.pageInfo.pageSize ?? 10;
132
- this.filterRequest= new FilterRequest(this.pageSize);
133
- data['pageInfo'].lazyLoadData = true;
134
- this.drillDownPageInfo = data['drillDownPageInfo'];
135
- this.drillDownColumns = data['drillDownColumns'];
136
- this.originalColumns = [...this.drillDownColumns];
137
- this.hideDrillDownButton = data['hideDrillDownButton'] ?? false;
138
- this.juniorPageInfo = data['juniorPageInfo'];
139
- this.juniorColumns = data['juniorColumns'];
140
- this.columnsDefinition = data['columnsDefinition'].filter(c => (this.drillDownPageInfo && this.drillDownColumns || (!NON_REPORT_COLUMNS.includes(c.type))));
141
- this.fields = data['fields'];
142
- if (data['enrichDrillDownReportRequest']) {
143
- this.enrichDrillDownReportRequest = data['enrichDrillDownReportRequest'](this.injector);
144
- }
145
- if (data['enrichJuniorReportRequest']) {
146
- this.enrichJuniorReportRequest = data['enrichJuniorReportRequest'](this.injector);
147
- }
148
-
149
- if (data['enrichHyperLinkReportRequest']) {
150
- this.enrichHyperLinkReportRequest = data['enrichHyperLinkReportRequest'](this.injector);
151
- }
152
- });
153
-
154
- this.route.queryParamMap.subscribe(params => {
155
- this.isComparisonReport = params.get('comparisonReport') === 'true';
156
- if (!this.isComparisonReport) return;
157
-
158
- const comparisonStr = sessionStorage.getItem('comparisonReportPageInfo');
159
- if (!comparisonStr) return;
160
-
161
- const comparisonData = JSON.parse(comparisonStr);
162
- this.initializeComparisonReport(comparisonData);
163
- });
164
- }
165
-
166
- private initializeComparisonReport(data: any): void {
167
- this.pageInfo.lazyLoadData = data.lazyLoadData ?? false;
168
- this.activeLevel = data.activeLevel ?? 2;
169
- this.isEditable = false;
170
- this.drillDownPageInfo = data.drillDownPageInfo;
171
- this.drillDownColumns = data.drillDownColumns;
172
-
173
- const reportRequest = data.reportRequest;
174
-
175
- this.reportRequest = this.backendService.buildReportRequest(
176
- this.drillDownColumns,
177
- `${this.drillDownPageInfo.labelsSection}.${this.drillDownPageInfo.id}`,
178
- reportRequest,
179
- '',
180
- this.drillDownPageInfo,
181
- 'LANDSCAPE'
182
- );
183
-
184
- this.setupForm(data.form);
185
- this.removeCheckboxFields();
186
- this.setupFilters(data.reportRequest, data.item);
187
- this.setupJuniorReportRequest();
188
- }
189
-
190
- private setupForm(formData: any): void {
191
- this.reportForm = this.fb.group({
192
- directorate: [[]],
193
- fromDate: [''],
194
- toDate: [''],
195
- sector: {},
196
- });
197
-
198
- if (formData) {
199
- this.reportForm.patchValue(formData);
200
- }
201
- }
202
-
203
- private removeCheckboxFields(): void {
204
- this.fields = this.fields.filter(field => field.type !== 'checkbox');
205
- }
206
-
207
- private setupFilters(reportRequest: any, item: any): void {
208
- this.filterRequest.filters = [];
209
-
210
- this.addOrUpdateFilter(reportRequest, {
211
- key: 'iSecLevel',
212
- fieldName: 'iSecLevel',
213
- value: this.activeLevel
214
- });
215
-
216
- this.addOrUpdateFilter(reportRequest, {
217
- id: 'iSecValue',
218
- key: 'iSecValue',
219
- fieldName: 'iSecValue',
220
- value: item?.isec_value
221
- });
222
-
223
- this.addOrUpdateFilter(reportRequest, {
224
- id: 'period',
225
- key: 'period',
226
- fieldName: 'period',
227
- value: item?.period
228
- });
229
-
230
- this.addOrUpdateFilter(reportRequest, {
231
- id: 'year',
232
- key: 'year',
233
- fieldName: 'year',
234
- value: item?.year
235
- });
236
-
237
- this.reportRequest.filterRequest = reportRequest;
238
- }
239
-
240
- private setupJuniorReportRequest(): void {
241
- this.juniorReportRequest = this.backendService.buildReportRequest(
242
- this.juniorColumns,
243
- `${this.juniorPageInfo.labelsSection}.${this.juniorPageInfo.id}`,
244
- this.reportRequest.filterRequest,
245
- '',
246
- this.juniorPageInfo,
247
- 'LANDSCAPE'
248
- );
249
-
250
- this.juniorReportRequest.filterRequest.pageSize = 500;
251
- }
252
-
253
- isMatchHeight() {
254
- return this.pageInfo.pageHeight === 'match';
255
- }
256
-
257
-
258
- doAction(type: string) {
259
- if (this.backendService.parentForm.valid) {
260
- this.reloadData = !this.reloadData;
261
- const filterRequest: FilterRequest = new FilterRequest(this.pageSize);
262
- filterRequest.filters = [];
263
- this.addOrUpdateFilter(filterRequest, {
264
- key: 'iSecLevel',
265
- fieldName: 'iSecLevel',
266
- value: this.activeLevel
267
- });
268
- let paramsString: string[] = [];
269
- this.fields.filter(x => x.type !== 'spacer').forEach(f => {
270
- if (this.getParamValue(f) != null && this.getParamValue(f).toString().trim() !== '')
271
- {
272
- if (f.type === 'multi-select' || f.type === 'lookup') {
273
- // do not filter if this field as cascading for another one and the other one got selected values
274
- const childFieldIdx = this.fields.findIndex(field => field.cascadedBy === f.property);
275
- if (childFieldIdx > -1 && this.backendService.parentForm.get(this.fields[childFieldIdx].property)?.value?.length > 0) {
276
- return;
277
- }
278
- const idz: number[] = [];
279
- const param: string[] = [];
280
- if (this.backendService.parentForm.get(f.property)?.value && Array.isArray(this.backendService.parentForm.get(f.property)?.value)
281
- && this.backendService.parentForm.get(f.property)?.value.length > 0) {
282
- this.backendService.parentForm.get(f.property)?.value.forEach((a: {
283
- channelId: number;
284
- englishName: string;
285
- id: number;
286
- }) => {
287
- if (f.flattenBySubAttribute) {
288
- idz.push(a[f.flattenBySubAttribute]);
289
- param.push(a[f.flattenBySubAttribute]);
290
- } else if (this.fields.find(s => s.property === 'terminalId')) {
291
- idz.push(a.channelId);
292
- param.push(a.englishName);
293
- } else {
294
- idz.push(a.id);
295
- param.push(a.englishName);
296
- }
297
- })
298
- filterRequest.filters?.push(new Filter({
299
- id: f.property, fieldName: f.property, label: this.translateService.instant(f.label),
300
- filterType: 'FILED_FILTER', operator: f.filterOperator,
301
- valueObject: idz
302
- }));
303
- paramsString.push(this.translateService.instant(f.label) + ' : ' + param.join(','));
304
- } else if (this.backendService.parentForm.get(f.property)?.value && f.flattenBySubAttribute) {
305
- filterRequest.filters?.push(new Filter({
306
- id: f.property, fieldName: f.property, label: this.translateService.instant(f.label),
307
- filterType: 'FILED_FILTER', operator: f.filterOperator,
308
- valueObject: this.getParamValue(f)[f.flattenBySubAttribute]
309
- }));
310
- }
311
- } else {
312
- if (this.backendService.parentForm.get(f.property)?.value !== null &&
313
- this.backendService.parentForm.get(f.property)?.value !== undefined &&
314
- this.backendService.parentForm.get(f.property)?.value !== "") {
315
- filterRequest.filters?.push(new Filter({
316
- id: f.property, fieldName: f.property, label: this.translateService.instant(f.label),
317
- filterType: 'FILED_FILTER', operator: f.filterOperator,
318
- valueObject: this.getParamValue(f)
319
- }));
320
- }
321
- paramsString.push(this.translateService.instant(f.label) + ' : ' + this.getParamValueLabel(f));
322
- }
323
- }})
324
- const reportRequest = this.backendService.buildReportRequest(this.columnsDefinition, this.pageInfo.labelsSection + '.' + this.pageInfo.id,
325
- filterRequest, type, this.pageInfo, 'LANDSCAPE');
326
- reportRequest.searchStr = paramsString.join(' , ');
327
- this.reportRequest = reportRequest;
328
- // this.activeLevel = 1;
329
- } else {
330
- this.backendService.topPanelMessage$.next(new SnackMessage('INVALID_REPORT_FORM', true, 'error'));
331
- }
332
- }
333
-
334
- private getParamValue(f: FieldInfo) {
335
- if (f.type === 'date' && this.backendService.parentForm.get(f.property)?.value) {
336
- return formatDate(this.backendService.parentForm.get(f.property)?.value, 'yyyy-MM-dd', 'en_US')
337
- }else if (f.type === 'checkbox') {
338
- return !!this.backendService.parentForm.get(f.property)?.value;
339
- }else {
340
- return this.backendService.parentForm.get(f.property)?.value;
341
- }
342
- }
343
-
344
- private getParamValueLabel(f: FieldInfo) {
345
- if (f.type === 'checkbox') {
346
- return this.backendService.parentForm.get(f.property)?.value ? this.translateService.instant('yes') : this.translateService.instant('no');
347
- }else {
348
- return this.backendService.parentForm.get(f.property)?.value;
349
- }
350
- }
351
-
352
- getTitle() {
353
- const pageInfoMap = {
354
- 1: this.pageInfo,
355
- 2: this.drillDownPageInfo,
356
- 3: this.juniorPageInfo
357
- };
358
-
359
- const currentInfo = pageInfoMap[this.activeLevel] || this.pageInfo;
360
- return `${currentInfo.labelsSection}.${currentInfo.id}`;
361
- }
362
-
363
- updateForm($event: FormGroup) {
364
- this.reportForm = $event;
365
- this.backendService.parentForm = $event;
366
- this.backendService.parentForm.valueChanges.subscribe(x => {
367
- this.readyToSearch = this.backendService.parentForm.valid;
368
- }
369
-
370
- );
371
- }
372
-
373
- isValidForm() {
374
- return this.readyToSearch ;
375
-
376
- }
377
-
378
-
379
-
380
- emitUserAction($event: TablePageUserAction) {
381
- $event.pageInfo = this.pageInfo;
382
- this.doADrillDownAction($event);
383
- }
384
-
385
- emitHyperLinkAction($event: TablePageUserAction) {
386
- if (this.shouldProcessEventItem($event.item)) {
387
- this.dialogReportRequest = cloneDeep(this.reportRequest);
388
- const reportRequest1 = this.backendService.buildReportRequest(
389
- this.juniorColumns,
390
- this.juniorPageInfo.labelsSection + '.' + this.juniorPageInfo.id,
391
- { ...this.dialogReportRequest.filterRequest },
392
- '',
393
- this.juniorPageInfo,
394
- 'LANDSCAPE'
395
- );
396
- reportRequest1.filterRequest.pageIndex = 0
397
- const dialogRef = this.dialog.open(ReportDetailsDialogComponent, {
398
- data: {
399
- pageInfo: this.juniorPageInfo,
400
- request: reportRequest1,
401
- columns: this.juniorColumns,
402
- item :$event.item
403
- },
404
- height: '50vw',
405
- maxWidth: '120vw',
406
- direction: this.currentDirection,
407
- disableClose: false,
408
- });
409
-
410
- dialogRef.afterOpened().subscribe(() => {
411
- this.doHyperLinkAction($event);
412
- });
413
-
414
- dialogRef.afterClosed().subscribe(() => {
415
- });
416
- }
417
- }
418
-
419
-
420
-
421
- emitJuniorAction($event: TablePageUserAction) {
422
- console.log('$event call junior', $event);
423
- const juniorAction = JUNIOR_DOWN_ACTION;
424
- juniorAction.pageInfo = this.drillDownPageInfo;
425
- this.doJuniorAction($event);
426
- }
427
-
428
- drillDown() {
429
- const drilldownaction = DRILL_DOWN_ACTION;
430
- drilldownaction.pageInfo = this.drillDownPageInfo;
431
- this.doADrillDownAction(drilldownaction);
432
- }
433
-
434
- private doJuniorAction($event: TablePageUserAction) {
435
- this.juniorColumns = this.originalColumns
436
- if (this.juniorColumns && this.juniorPageInfo) {
437
- if (this.enrichJuniorReportRequest) {
438
-
439
- this.isEditable = false;
440
- this.juniorReportRequest = this.backendService.buildReportRequest(this.juniorColumns,
441
- this.juniorPageInfo.labelsSection + '.' + this.juniorPageInfo.id,
442
- this.reportRequest.filterRequest, '', this.juniorPageInfo, 'LANDSCAPE');
443
- this.enrichJuniorReportRequest($event, this.juniorReportRequest);
444
- }
445
- this.activeLevel = this.activeLevel +1;
446
- this.addOrUpdateFilter(this.reportRequest.filterRequest, {
447
- key: 'iSecLevel',
448
- fieldName: 'iSecLevel',
449
- value: this.activeLevel
450
- });
451
- }
452
- }
453
- private doADrillDownAction($event: TablePageUserAction) {
454
-
455
- if (this.drillDownColumns && this.drillDownPageInfo) {
456
- this.drillDownRequestStack.push(cloneDeep(this.reportRequest));
457
- if (this.enrichDrillDownReportRequest) {
458
- this.isEditable = false;
459
- this.childReportRequest = this.backendService.buildReportRequest(this.drillDownColumns,
460
- this.drillDownPageInfo.labelsSection + '.' + this.drillDownPageInfo.id,
461
- this.reportRequest.filterRequest, '', this.drillDownPageInfo, 'LANDSCAPE');
462
- this.enrichDrillDownReportRequest($event, this.childReportRequest);
463
-
464
- }
465
- this.childReportRequest.filterRequest.pageSize = 500
466
- this.activeLevel = this.activeLevel +1;
467
- this.addOrUpdateFilter(this.reportRequest.filterRequest, {
468
- key: 'iSecLevel',
469
- fieldName: 'iSecLevel',
470
- value: this.activeLevel
471
- });
472
- if (this.isComparisonReport){
473
- this.addOrUpdateFilter(this.reportRequest.filterRequest, {
474
- id: 'iSecValue',
475
- key: 'iSecValue',
476
- fieldName: 'iSecValue',
477
- value: $event.item.isec_value
478
- });
479
-
480
- }
481
- if (this.activeLevel === 4) {
482
- this.drillDownColumns = this.drillDownColumns.filter(item => item.type !== 'button');
483
- }
484
- this.reloadData = true
485
- }
486
- }
487
-
488
- private addOrUpdateFilter(
489
- filterRequest: FilterRequest,
490
- options: {
491
- id?: string;
492
- key: string;
493
- fieldName: string;
494
- value: any;
495
- }
496
- ): void {
497
- const { id, key, fieldName, value } = options;
498
-
499
- const existingFilterIndex = filterRequest.filters.findIndex((filter: Filter) =>
500
- id ? filter.id === id : filter.key === key
501
- );
502
-
503
- const newFilter = new Filter({
504
- ...(id && { id }),
505
- key,
506
- fieldName,
507
- label: '',
508
- filterType: 'FILED_FILTER',
509
- operator: 'EQUALS',
510
- valueObject: value
511
- });
512
-
513
- if (existingFilterIndex !== -1) {
514
- filterRequest.filters[existingFilterIndex] = newFilter;
515
- } else {
516
- filterRequest.filters.push(newFilter);
517
- }
518
- }
519
-
520
- private doHyperLinkAction($event: TablePageUserAction) {
521
- if (this.enrichHyperLinkReportRequest) {
522
- this.juniorReportRequest = this.backendService.buildReportRequest(this.juniorColumns,
523
- this.juniorPageInfo.labelsSection + '.' + this.juniorPageInfo.id,
524
- this.dialogReportRequest.filterRequest, '', this.juniorPageInfo, 'LANDSCAPE');
525
- this.enrichHyperLinkReportRequest($event, this.juniorReportRequest);
526
- }
527
- }
528
-
529
- extractReport(reportType: any) {
530
- this.reportRequest.reportType = reportType;
531
- this.backendService.downloadReport(this.reportRequest, this.drillDownPageInfo.apiUri );
532
-
533
- }
534
-
535
- goUp() {
536
- Object.keys(this.reportForm.controls).forEach(controlName => {
537
- const control = this.reportForm.get(controlName);
538
- control?.clearValidators();
539
- control?.updateValueAndValidity();
540
- });
541
- this.isEditable = true;
542
- this.activeLevel = this.activeLevel - 1;
543
- if (this.activeLevel > 1 ) {
544
- this.isEditable = false;
545
- }
546
- this.doAction(this.x);
547
- this.reportRequest = this.drillDownRequestStack.pop();
548
- this.addOrUpdateFilter(this.reportRequest.filterRequest, {
549
- key: 'iSecLevel',
550
- fieldName: 'iSecLevel',
551
- value: this.activeLevel
552
- });
553
- this.reloadData = true;
554
- if (this.activeLevel !== 4) {
555
- this.drillDownColumns = [...this.originalColumns];
556
- }
557
- }
558
-
559
-
560
- drillDownEnabled() {
561
- return this.drillDownPageInfo && !this.hideDrillDownButton && !this.getIsEmptyList();
562
- }
563
-
564
- drillDownLabel() {
565
- return `${this.pageInfo.labelsSection}.drillDownLabel` ;
566
- }
567
- getIsEmptyList() {
568
- return this.backendService.isEmptyItems;
569
- }
570
- clear() {
571
- const currentUrl = this.router.url;
572
- this.router.navigateByUrl('/', { skipLocationChange: true }).then(() => {
573
- this.router.navigate([currentUrl]);
574
- });
575
- }
576
-
577
-
578
- isFormEmpty(): boolean {
579
- if (!this.reportForm || !this.reportForm.value) {
580
- return true;
581
- }
582
-
583
- return Object.values(this.reportForm.value).every(value => {
584
- if (value === null || value === undefined || value === '') {
585
- return true;
586
- }
587
- return Array.isArray(value) && value.length === 0;
588
-
589
- });
590
- }
591
-
592
- shouldProcessEventItem(item: any): boolean {
593
- const groupByProp = this.pageInfo?.groupByProperty;
594
- const groupByValues = this.pageInfo?.groupByValue;
595
-
596
- if (!groupByProp || !groupByValues || !item[groupByProp]) {
597
- return true;
598
- }
599
-
600
- const value = item[groupByProp].toString();
601
-
602
- return !groupByValues.some(v => value.includes(v) && value.length >= v.length);
603
- }
604
-
605
- }
1
+ import {
2
+ Component,
3
+ EventEmitter,
4
+ Injector,
5
+ Input,
6
+ OnInit,
7
+ Output
8
+ } from '@angular/core';
9
+ import {FieldInfo} from "../../base-model/field-info";
10
+ import {EMPTY_PAGE_INFO, PageInfo} from "../../base-model/page-info";
11
+ import {TableColumn} from "../../base-model/table-column.interface";
12
+ import {FieldMessage} from "../../base-model/api-response";
13
+ import {TranslateModule, TranslateService} from "@ngx-translate/core";
14
+ import {BackendService} from "../../services/backend-service";
15
+ import {ActivatedRoute, Router} from "@angular/router";
16
+ import {FormBuilder, FormGroup} from "@angular/forms";
17
+ import {formatDate, NgForOf, NgIf} from "@angular/common";
18
+ import {MatMenu, MatMenuItem, MatMenuTrigger} from "@angular/material/menu";
19
+ import {MatButton, MatButtonModule} from "@angular/material/button";
20
+ import {BaseTableComponent} from "../base-table/base-table.component";
21
+ import {MatIconModule} from "@angular/material/icon";
22
+ import {FilterRequest} from "../../base-model/filter-request";
23
+ import {ReportRequest} from "../../base-model/report-request.model";
24
+ import {Filter} from "../../base-model/filter.model";
25
+ import {TitleBarComponent} from "../title-bar/title-bar.component";
26
+ import {BaseFormCanvasComponent} from "../base-form-canvas/base-form-canvas.component";
27
+ import ClassicEditor from "@ckeditor/ckeditor5-build-classic";
28
+ import {DRILL_DOWN_ACTION, JUNIOR_DOWN_ACTION, SnackMessage, TablePageUserAction} from "../../base-model";
29
+ import {} from "../audit-log-details-dialog/audit-log-details-dialog.component";
30
+ import {MatDialog} from "@angular/material/dialog";
31
+ import {ReportDetailsDialogComponent} from "../report-details-dialog/report-details-dialog.component";
32
+ import { cloneDeep } from 'lodash';
33
+ import {Directionality} from "@angular/cdk/bidi";
34
+ import {MatTooltip} from "@angular/material/tooltip";
35
+
36
+
37
+ const NON_REPORT_COLUMNS = ['listAction', 'button', 'checkbox'];
38
+
39
+ @Component({
40
+ selector: 'app-report-form',
41
+ standalone: true,
42
+ imports: [
43
+ TitleBarComponent,
44
+ BaseFormCanvasComponent,
45
+ MatMenu,
46
+ MatMenuItem,
47
+ NgForOf,
48
+ MatMenuTrigger,
49
+ MatButtonModule,
50
+ TranslateModule,
51
+ BaseTableComponent,
52
+ NgIf,
53
+ MatIconModule,
54
+ MatButton,
55
+ MatTooltip
56
+ ],
57
+ templateUrl: './activity-report-form.component.html',
58
+ styleUrl: './activity-report-form.component.scss'
59
+ })
60
+ export class ActivityReportFormComponent implements OnInit{
61
+ @Input()
62
+ showDetails : any = [];
63
+
64
+ @Input()
65
+ showExtractButton: boolean = true;
66
+
67
+ @Input()
68
+ columns: TableColumn<any>[] =[];
69
+ private originalColumns: any[] = [];
70
+
71
+
72
+ @Input() actionRequestCallback!: (actionRequest: TablePageUserAction) => TablePageUserAction;
73
+ @Input() enrichDrillDownReportRequest!: (actionRequest: TablePageUserAction, reportRequest: ReportRequest) => TablePageUserAction;
74
+ @Input() enrichHyperLinkReportRequest!: (actionRequest: TablePageUserAction, reportRequest: ReportRequest) => TablePageUserAction;
75
+ @Input() enrichJuniorReportRequest!: (actionRequest: TablePageUserAction, reportRequest: ReportRequest) => TablePageUserAction;
76
+
77
+ @Output()
78
+ userAction: EventEmitter<TablePageUserAction> = new EventEmitter<TablePageUserAction>();
79
+ activeLevel: number = 1;
80
+ items = [4, 5,6,7];
81
+ private filterRequest: FilterRequest;
82
+ x: any;
83
+ isEditable: boolean = true;
84
+ fields: FieldInfo[] = [];
85
+ pageInfo: PageInfo = EMPTY_PAGE_INFO;
86
+ drillDownPageInfo: PageInfo = EMPTY_PAGE_INFO;
87
+ drillDownColumns: TableColumn<any>[] = [];
88
+ hideDrillDownButton: false;
89
+
90
+ juniorPageInfo: PageInfo = EMPTY_PAGE_INFO;
91
+ juniorColumns: TableColumn<any>[] = [];
92
+
93
+ columnsDefinition: TableColumn<any>[] = [];
94
+ types: string[] = ["pdf", "csv", "xlsx"]
95
+ searchStr: string = '';
96
+
97
+ errors: FieldMessage[] = [];
98
+
99
+ reloadData: boolean = false;
100
+ drillDownRequestStack: any[] = [];
101
+ reportRequest: ReportRequest = new ReportRequest({});
102
+ childReportRequest: ReportRequest = new ReportRequest({});
103
+ juniorReportRequest: ReportRequest = new ReportRequest({});
104
+ public reportForm: FormGroup;
105
+ readyToSearch = false;
106
+ private pageSize: any;
107
+ private dialogReportRequest: any;
108
+ currentDirection: 'ltr' | 'rtl';
109
+ protected isComparisonReport: boolean = false;
110
+ constructor(private translateService: TranslateService,
111
+ public backendService: BackendService,
112
+ private activatedRoute: ActivatedRoute,
113
+ private injector: Injector,
114
+ private router: Router,
115
+ private route: ActivatedRoute,
116
+ public dialog: MatDialog,
117
+ private directionality: Directionality,
118
+ private fb: FormBuilder) {
119
+ ClassicEditor.defaultConfig = {
120
+ toolbar: {
121
+ items: ['heading', '|', 'bold', 'italic', '|', 'bulletedList', 'numberedList']
122
+ },
123
+ image: {
124
+ toolbar: ['imageStyle:side', '|', 'imageTextAlternative']
125
+ },
126
+ table: {
127
+ contentToolbar: [ 'tableColumn', 'tableRow', 'mergeTableCells' ]
128
+ },
129
+ language: 'en'
130
+ };
131
+ }
132
+
133
+ ngOnInit(): void {
134
+
135
+ this.currentDirection = this.directionality.value;
136
+ this.directionality.change.subscribe((value) => {
137
+ this.currentDirection = value;
138
+ })
139
+
140
+ this.activatedRoute.data.subscribe(data => {
141
+ this.pageInfo = data['pageInfo'];
142
+ this.pageSize = this.pageInfo.pageSize ?? 10;
143
+ this.filterRequest= new FilterRequest(this.pageSize);
144
+ data['pageInfo'].lazyLoadData = true;
145
+ this.drillDownPageInfo = data['drillDownPageInfo'];
146
+ this.drillDownColumns = data['drillDownColumns'];
147
+ this.originalColumns = [...this.drillDownColumns];
148
+ this.hideDrillDownButton = data['hideDrillDownButton'] ?? false;
149
+ this.juniorPageInfo = data['juniorPageInfo'];
150
+ this.juniorColumns = data['juniorColumns'];
151
+ this.columnsDefinition = data['columnsDefinition'].filter(c => (this.drillDownPageInfo && this.drillDownColumns || (!NON_REPORT_COLUMNS.includes(c.type))));
152
+ this.fields = data['fields'];
153
+ if (data['enrichDrillDownReportRequest']) {
154
+ this.enrichDrillDownReportRequest = data['enrichDrillDownReportRequest'](this.injector);
155
+ }
156
+ if (data['enrichJuniorReportRequest']) {
157
+ this.enrichJuniorReportRequest = data['enrichJuniorReportRequest'](this.injector);
158
+ }
159
+
160
+ if (data['enrichHyperLinkReportRequest']) {
161
+ this.enrichHyperLinkReportRequest = data['enrichHyperLinkReportRequest'](this.injector);
162
+ }
163
+ });
164
+
165
+ this.route.queryParamMap.subscribe(params => {
166
+ this.isComparisonReport = params.get('comparisonReport') === 'true';
167
+ if (!this.isComparisonReport) return;
168
+
169
+ const comparisonStr = sessionStorage.getItem('comparisonReportPageInfo');
170
+ if (!comparisonStr) return;
171
+
172
+ const comparisonData = JSON.parse(comparisonStr);
173
+ this.initializeComparisonReport(comparisonData);
174
+ });
175
+ }
176
+
177
+ private initializeComparisonReport(data: any): void {
178
+ this.pageInfo.lazyLoadData = data.lazyLoadData ?? false;
179
+ this.activeLevel = data.activeLevel ?? 2;
180
+ this.isEditable = false;
181
+ this.drillDownPageInfo = data.drillDownPageInfo;
182
+ this.drillDownColumns = data.drillDownColumns;
183
+
184
+ const reportRequest = data.reportRequest;
185
+
186
+ this.reportRequest = this.backendService.buildReportRequest(
187
+ this.drillDownColumns,
188
+ `${this.drillDownPageInfo.labelsSection}.${this.drillDownPageInfo.id}`,
189
+ reportRequest,
190
+ '',
191
+ this.drillDownPageInfo,
192
+ 'LANDSCAPE'
193
+ );
194
+
195
+ this.setupForm(data.form);
196
+ this.removeCheckboxFields();
197
+ this.setupFilters(data.reportRequest, data.item);
198
+ this.setupJuniorReportRequest();
199
+ }
200
+
201
+ private setupForm(formData: any): void {
202
+ this.reportForm = this.fb.group({
203
+ directorate: [[]],
204
+ fromDate: [''],
205
+ toDate: [''],
206
+ sector: {},
207
+ });
208
+
209
+ if (formData) {
210
+ this.reportForm.patchValue(formData);
211
+ }
212
+ }
213
+
214
+ private removeCheckboxFields(): void {
215
+ this.fields = this.fields.filter(field => field.type !== 'checkbox');
216
+ }
217
+
218
+ private setupFilters(reportRequest: any, item: any): void {
219
+ this.filterRequest.filters = [];
220
+
221
+ this.addOrUpdateFilter(reportRequest, {
222
+ key: 'iSecLevel',
223
+ fieldName: 'iSecLevel',
224
+ value: this.activeLevel
225
+ });
226
+
227
+ this.addOrUpdateFilter(reportRequest, {
228
+ id: 'iSecValue',
229
+ key: 'iSecValue',
230
+ fieldName: 'iSecValue',
231
+ value: item?.isec_value
232
+ });
233
+
234
+ this.addOrUpdateFilter(reportRequest, {
235
+ id: 'period',
236
+ key: 'period',
237
+ fieldName: 'period',
238
+ value: item?.period
239
+ });
240
+
241
+ this.addOrUpdateFilter(reportRequest, {
242
+ id: 'year',
243
+ key: 'year',
244
+ fieldName: 'year',
245
+ value: item?.year
246
+ });
247
+
248
+ this.reportRequest.filterRequest = reportRequest;
249
+ }
250
+
251
+ private setupJuniorReportRequest(): void {
252
+ this.juniorReportRequest = this.backendService.buildReportRequest(
253
+ this.juniorColumns,
254
+ `${this.juniorPageInfo.labelsSection}.${this.juniorPageInfo.id}`,
255
+ this.reportRequest.filterRequest,
256
+ '',
257
+ this.juniorPageInfo,
258
+ 'LANDSCAPE'
259
+ );
260
+
261
+ this.juniorReportRequest.filterRequest.pageSize = 500;
262
+ }
263
+
264
+ isMatchHeight() {
265
+ return this.pageInfo.pageHeight === 'match';
266
+ }
267
+
268
+
269
+ doAction(type: string) {
270
+ if (this.backendService.parentForm.valid) {
271
+ this.reloadData = !this.reloadData;
272
+ const filterRequest: FilterRequest = new FilterRequest(this.pageSize);
273
+ filterRequest.filters = [];
274
+ this.addOrUpdateFilter(filterRequest, {
275
+ key: 'iSecLevel',
276
+ fieldName: 'iSecLevel',
277
+ value: this.activeLevel
278
+ });
279
+ let paramsString: string[] = [];
280
+ this.fields.filter(x => x.type !== 'spacer').forEach(f => {
281
+ if (this.getParamValue(f) != null && this.getParamValue(f).toString().trim() !== '')
282
+ {
283
+ if (f.type === 'multi-select' || f.type === 'lookup') {
284
+ // do not filter if this field as cascading for another one and the other one got selected values
285
+ const childFieldIdx = this.fields.findIndex(field => field.cascadedBy === f.property);
286
+ if (childFieldIdx > -1 && this.backendService.parentForm.get(this.fields[childFieldIdx].property)?.value?.length > 0) {
287
+ return;
288
+ }
289
+ const idz: number[] = [];
290
+ const param: string[] = [];
291
+ if (this.backendService.parentForm.get(f.property)?.value && Array.isArray(this.backendService.parentForm.get(f.property)?.value)
292
+ && this.backendService.parentForm.get(f.property)?.value.length > 0) {
293
+ this.backendService.parentForm.get(f.property)?.value.forEach((a: {
294
+ channelId: number;
295
+ englishName: string;
296
+ id: number;
297
+ }) => {
298
+ if (f.flattenBySubAttribute) {
299
+ idz.push(a[f.flattenBySubAttribute]);
300
+ param.push(a[f.flattenBySubAttribute]);
301
+ } else if (this.fields.find(s => s.property === 'terminalId')) {
302
+ idz.push(a.channelId);
303
+ param.push(a.englishName);
304
+ } else {
305
+ idz.push(a.id);
306
+ param.push(a.englishName);
307
+ }
308
+ })
309
+ filterRequest.filters?.push(new Filter({
310
+ id: f.property, fieldName: f.property, label: this.translateService.instant(f.label),
311
+ filterType: 'FILED_FILTER', operator: f.filterOperator,
312
+ valueObject: idz
313
+ }));
314
+ paramsString.push(this.translateService.instant(f.label) + ' : ' + param.join(','));
315
+ } else if (this.backendService.parentForm.get(f.property)?.value && f.flattenBySubAttribute) {
316
+ filterRequest.filters?.push(new Filter({
317
+ id: f.property, fieldName: f.property, label: this.translateService.instant(f.label),
318
+ filterType: 'FILED_FILTER', operator: f.filterOperator,
319
+ valueObject: this.getParamValue(f)[f.flattenBySubAttribute]
320
+ }));
321
+ }
322
+ } else {
323
+ if (this.backendService.parentForm.get(f.property)?.value !== null &&
324
+ this.backendService.parentForm.get(f.property)?.value !== undefined &&
325
+ this.backendService.parentForm.get(f.property)?.value !== "") {
326
+ filterRequest.filters?.push(new Filter({
327
+ id: f.property, fieldName: f.property, label: this.translateService.instant(f.label),
328
+ filterType: 'FILED_FILTER', operator: f.filterOperator,
329
+ valueObject: this.getParamValue(f)
330
+ }));
331
+ }
332
+ paramsString.push(this.translateService.instant(f.label) + ' : ' + this.getParamValueLabel(f));
333
+ }
334
+ }})
335
+ const reportRequest = this.backendService.buildReportRequest(this.columnsDefinition, this.pageInfo.labelsSection + '.' + this.pageInfo.id,
336
+ filterRequest, type, this.pageInfo, 'LANDSCAPE');
337
+ reportRequest.searchStr = paramsString.join(' , ');
338
+ this.reportRequest = reportRequest;
339
+ // this.activeLevel = 1;
340
+ } else {
341
+ this.backendService.topPanelMessage$.next(new SnackMessage('INVALID_REPORT_FORM', true, 'error'));
342
+ }
343
+ }
344
+
345
+ private getParamValue(f: FieldInfo) {
346
+ if (f.type === 'date' && this.backendService.parentForm.get(f.property)?.value) {
347
+ return formatDate(this.backendService.parentForm.get(f.property)?.value, 'yyyy-MM-dd', 'en_US')
348
+ }else if (f.type === 'checkbox') {
349
+ return !!this.backendService.parentForm.get(f.property)?.value;
350
+ }else {
351
+ return this.backendService.parentForm.get(f.property)?.value;
352
+ }
353
+ }
354
+
355
+ private getParamValueLabel(f: FieldInfo) {
356
+ if (f.type === 'checkbox') {
357
+ return this.backendService.parentForm.get(f.property)?.value ? this.translateService.instant('yes') : this.translateService.instant('no');
358
+ }else {
359
+ return this.backendService.parentForm.get(f.property)?.value;
360
+ }
361
+ }
362
+
363
+ getTitle() {
364
+ const pageInfoMap = {
365
+ 1: this.pageInfo,
366
+ 2: this.drillDownPageInfo,
367
+ 3: this.juniorPageInfo
368
+ };
369
+
370
+ const currentInfo = pageInfoMap[this.activeLevel] || this.pageInfo;
371
+ return `${currentInfo.labelsSection}.${currentInfo.id}`;
372
+ }
373
+
374
+ updateForm($event: FormGroup) {
375
+ this.reportForm = $event;
376
+ this.backendService.parentForm = $event;
377
+ this.backendService.parentForm.valueChanges.subscribe(x => {
378
+ this.readyToSearch = this.backendService.parentForm.valid;
379
+ }
380
+
381
+ );
382
+ }
383
+
384
+ isValidForm() {
385
+ return this.readyToSearch ;
386
+
387
+ }
388
+
389
+
390
+
391
+ emitUserAction($event: TablePageUserAction) {
392
+ $event.pageInfo = this.pageInfo;
393
+ this.doADrillDownAction($event);
394
+ }
395
+
396
+ emitHyperLinkAction($event: TablePageUserAction) {
397
+ if (this.shouldProcessEventItem($event.item)) {
398
+ this.dialogReportRequest = cloneDeep(this.reportRequest);
399
+ const reportRequest1 = this.backendService.buildReportRequest(
400
+ this.juniorColumns,
401
+ this.juniorPageInfo.labelsSection + '.' + this.juniorPageInfo.id,
402
+ { ...this.dialogReportRequest.filterRequest },
403
+ '',
404
+ this.juniorPageInfo,
405
+ 'LANDSCAPE'
406
+ );
407
+ reportRequest1.filterRequest.pageIndex = 0
408
+ const dialogRef = this.dialog.open(ReportDetailsDialogComponent, {
409
+ data: {
410
+ pageInfo: this.juniorPageInfo,
411
+ request: reportRequest1,
412
+ columns: this.juniorColumns,
413
+ item :$event.item
414
+ },
415
+ height: '50vw',
416
+ maxWidth: '120vw',
417
+ direction: this.currentDirection,
418
+ disableClose: false,
419
+ });
420
+
421
+ dialogRef.afterOpened().subscribe(() => {
422
+ this.doHyperLinkAction($event);
423
+ });
424
+
425
+ dialogRef.afterClosed().subscribe(() => {
426
+ });
427
+ }
428
+ }
429
+
430
+
431
+
432
+ emitJuniorAction($event: TablePageUserAction) {
433
+ console.log('$event call junior', $event);
434
+ const juniorAction = JUNIOR_DOWN_ACTION;
435
+ juniorAction.pageInfo = this.drillDownPageInfo;
436
+ this.doJuniorAction($event);
437
+ }
438
+
439
+ drillDown() {
440
+ const drilldownaction = DRILL_DOWN_ACTION;
441
+ drilldownaction.pageInfo = this.drillDownPageInfo;
442
+ this.doADrillDownAction(drilldownaction);
443
+ }
444
+
445
+ private doJuniorAction($event: TablePageUserAction) {
446
+ this.juniorColumns = this.originalColumns
447
+ if (this.juniorColumns && this.juniorPageInfo) {
448
+ if (this.enrichJuniorReportRequest) {
449
+
450
+ this.isEditable = false;
451
+ this.juniorReportRequest = this.backendService.buildReportRequest(this.juniorColumns,
452
+ this.juniorPageInfo.labelsSection + '.' + this.juniorPageInfo.id,
453
+ this.reportRequest.filterRequest, '', this.juniorPageInfo, 'LANDSCAPE');
454
+ this.enrichJuniorReportRequest($event, this.juniorReportRequest);
455
+ }
456
+ this.activeLevel = this.activeLevel +1;
457
+ this.addOrUpdateFilter(this.reportRequest.filterRequest, {
458
+ key: 'iSecLevel',
459
+ fieldName: 'iSecLevel',
460
+ value: this.activeLevel
461
+ });
462
+ }
463
+ }
464
+ private doADrillDownAction($event: TablePageUserAction) {
465
+
466
+ if (this.drillDownColumns && this.drillDownPageInfo) {
467
+ this.drillDownRequestStack.push(cloneDeep(this.reportRequest));
468
+ if (this.enrichDrillDownReportRequest) {
469
+ this.isEditable = false;
470
+ this.childReportRequest = this.backendService.buildReportRequest(this.drillDownColumns,
471
+ this.drillDownPageInfo.labelsSection + '.' + this.drillDownPageInfo.id,
472
+ this.reportRequest.filterRequest, '', this.drillDownPageInfo, 'LANDSCAPE');
473
+ this.enrichDrillDownReportRequest($event, this.childReportRequest);
474
+
475
+ }
476
+ this.childReportRequest.filterRequest.pageSize = 500
477
+ this.activeLevel = this.activeLevel +1;
478
+ this.addOrUpdateFilter(this.reportRequest.filterRequest, {
479
+ key: 'iSecLevel',
480
+ fieldName: 'iSecLevel',
481
+ value: this.activeLevel
482
+ });
483
+ if (this.isComparisonReport){
484
+ this.addOrUpdateFilter(this.reportRequest.filterRequest, {
485
+ id: 'iSecValue',
486
+ key: 'iSecValue',
487
+ fieldName: 'iSecValue',
488
+ value: $event.item.isec_value
489
+ });
490
+
491
+ }
492
+ if (this.activeLevel === 4) {
493
+ this.drillDownColumns = this.drillDownColumns.filter(item => item.type !== 'button');
494
+ }
495
+ this.reloadData = true
496
+ }
497
+ }
498
+
499
+ private addOrUpdateFilter(
500
+ filterRequest: FilterRequest,
501
+ options: {
502
+ id?: string;
503
+ key: string;
504
+ fieldName: string;
505
+ value: any;
506
+ }
507
+ ): void {
508
+ const { id, key, fieldName, value } = options;
509
+
510
+ const existingFilterIndex = filterRequest.filters.findIndex((filter: Filter) =>
511
+ id ? filter.id === id : filter.key === key
512
+ );
513
+
514
+ const newFilter = new Filter({
515
+ ...(id && { id }),
516
+ key,
517
+ fieldName,
518
+ label: '',
519
+ filterType: 'FILED_FILTER',
520
+ operator: 'EQUALS',
521
+ valueObject: value
522
+ });
523
+
524
+ if (existingFilterIndex !== -1) {
525
+ filterRequest.filters[existingFilterIndex] = newFilter;
526
+ } else {
527
+ filterRequest.filters.push(newFilter);
528
+ }
529
+ }
530
+
531
+ private doHyperLinkAction($event: TablePageUserAction) {
532
+ if (this.enrichHyperLinkReportRequest) {
533
+ this.juniorReportRequest = this.backendService.buildReportRequest(this.juniorColumns,
534
+ this.juniorPageInfo.labelsSection + '.' + this.juniorPageInfo.id,
535
+ this.dialogReportRequest.filterRequest, '', this.juniorPageInfo, 'LANDSCAPE');
536
+ this.enrichHyperLinkReportRequest($event, this.juniorReportRequest);
537
+ }
538
+ }
539
+
540
+ extractReport(reportType: any) {
541
+ this.reportRequest.reportType = reportType;
542
+ this.backendService.downloadReport(this.reportRequest, this.drillDownPageInfo.apiUri );
543
+
544
+ }
545
+
546
+ goUp() {
547
+ Object.keys(this.reportForm.controls).forEach(controlName => {
548
+ const control = this.reportForm.get(controlName);
549
+ control?.clearValidators();
550
+ control?.updateValueAndValidity();
551
+ });
552
+ this.isEditable = true;
553
+ this.activeLevel = this.activeLevel - 1;
554
+ if (this.activeLevel > 1 ) {
555
+ this.isEditable = false;
556
+ }
557
+ this.doAction(this.x);
558
+ this.reportRequest = this.drillDownRequestStack.pop();
559
+ this.addOrUpdateFilter(this.reportRequest.filterRequest, {
560
+ key: 'iSecLevel',
561
+ fieldName: 'iSecLevel',
562
+ value: this.activeLevel
563
+ });
564
+ this.reloadData = true;
565
+ if (this.activeLevel !== 4) {
566
+ this.drillDownColumns = [...this.originalColumns];
567
+ }
568
+ }
569
+
570
+
571
+ drillDownEnabled() {
572
+ return this.drillDownPageInfo && !this.hideDrillDownButton && !this.getIsEmptyList();
573
+ }
574
+
575
+ drillDownLabel() {
576
+ return `${this.pageInfo.labelsSection}.drillDownLabel` ;
577
+ }
578
+ getIsEmptyList() {
579
+ return this.backendService.isEmptyItems;
580
+ }
581
+ clear() {
582
+ const currentUrl = this.router.url;
583
+ this.router.navigateByUrl('/', { skipLocationChange: true }).then(() => {
584
+ this.router.navigate([currentUrl]);
585
+ });
586
+ }
587
+
588
+
589
+ isFormEmpty(): boolean {
590
+ if (!this.reportForm || !this.reportForm.value) {
591
+ return true;
592
+ }
593
+
594
+ return Object.values(this.reportForm.value).every(value => {
595
+ if (value === null || value === undefined || value === '') {
596
+ return true;
597
+ }
598
+ return Array.isArray(value) && value.length === 0;
599
+
600
+ });
601
+ }
602
+
603
+ shouldProcessEventItem(item: any): boolean {
604
+ const groupByProp = this.pageInfo?.groupByProperty;
605
+ const groupByValues = this.pageInfo?.groupByValue;
606
+
607
+ if (!groupByProp || !groupByValues || !item[groupByProp]) {
608
+ return true;
609
+ }
610
+
611
+ const value = item[groupByProp].toString();
612
+
613
+ return !groupByValues.some(v => value.includes(v) && value.length >= v.length);
614
+ }
615
+
616
+ }