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