@unifylib/ui-lib 1.0.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 (129) hide show
  1. package/README.md +0 -0
  2. package/ng-package.json +7 -0
  3. package/package.json +12 -0
  4. package/src/lib/base-model/SearchStrConfig.ts +12 -0
  5. package/src/lib/base-model/api-response.ts +23 -0
  6. package/src/lib/base-model/audit-log-entry.ts +7 -0
  7. package/src/lib/base-model/button-action-settings.ts +25 -0
  8. package/src/lib/base-model/column-def.model.ts +34 -0
  9. package/src/lib/base-model/do-action-request.ts +11 -0
  10. package/src/lib/base-model/field-action.ts +7 -0
  11. package/src/lib/base-model/field-filter.model.ts +14 -0
  12. package/src/lib/base-model/field-info.ts +98 -0
  13. package/src/lib/base-model/field-predicate.model.ts +7 -0
  14. package/src/lib/base-model/filter-request.ts +27 -0
  15. package/src/lib/base-model/filter.model.ts +49 -0
  16. package/src/lib/base-model/get-items-list.ts +24 -0
  17. package/src/lib/base-model/index.ts +11 -0
  18. package/src/lib/base-model/lookupItem.ts +21 -0
  19. package/src/lib/base-model/null-snackmessage.ts +9 -0
  20. package/src/lib/base-model/page-info.ts +51 -0
  21. package/src/lib/base-model/report-request.model.ts +33 -0
  22. package/src/lib/base-model/response-envelop.model.ts +15 -0
  23. package/src/lib/base-model/snack-message.model.ts +14 -0
  24. package/src/lib/base-model/snackmessage-interface.ts +7 -0
  25. package/src/lib/base-model/table-column.interface.ts +29 -0
  26. package/src/lib/base-model/table-page-user-action.interface.ts +33 -0
  27. package/src/lib/base-model/workflow/workflow-steps.model.ts +9 -0
  28. package/src/lib/base-model/workflow/workflow.model.ts +52 -0
  29. package/src/lib/components/action-confirmation/action-confirmation.component.css +34 -0
  30. package/src/lib/components/action-confirmation/action-confirmation.component.html +18 -0
  31. package/src/lib/components/action-confirmation/action-confirmation.component.spec.ts +23 -0
  32. package/src/lib/components/action-confirmation/action-confirmation.component.ts +58 -0
  33. package/src/lib/components/activity-report-form/activity-report-form.component.html +109 -0
  34. package/src/lib/components/activity-report-form/activity-report-form.component.scss +0 -0
  35. package/src/lib/components/activity-report-form/activity-report-form.component.spec.ts +25 -0
  36. package/src/lib/components/activity-report-form/activity-report-form.component.ts +605 -0
  37. package/src/lib/components/audit-log-details-dialog/audit-log-details-dialog.component.css +51 -0
  38. package/src/lib/components/audit-log-details-dialog/audit-log-details-dialog.component.html +23 -0
  39. package/src/lib/components/audit-log-details-dialog/audit-log-details-dialog.component.spec.ts +23 -0
  40. package/src/lib/components/audit-log-details-dialog/audit-log-details-dialog.component.ts +69 -0
  41. package/src/lib/components/audit-log-list/audit-log.component.html +23 -0
  42. package/src/lib/components/audit-log-list/audit-log.component.scss +0 -0
  43. package/src/lib/components/audit-log-list/audit-log.component.spec.ts +25 -0
  44. package/src/lib/components/audit-log-list/audit-log.component.ts +116 -0
  45. package/src/lib/components/auto-complete/auto-complete.component.css +14 -0
  46. package/src/lib/components/auto-complete/auto-complete.component.html +29 -0
  47. package/src/lib/components/auto-complete/auto-complete.component.spec.ts +23 -0
  48. package/src/lib/components/auto-complete/auto-complete.component.ts +330 -0
  49. package/src/lib/components/base-form/base-form.component.html +58 -0
  50. package/src/lib/components/base-form/base-form.component.scss +0 -0
  51. package/src/lib/components/base-form/base-form.component.spec.ts +25 -0
  52. package/src/lib/components/base-form/base-form.component.ts +305 -0
  53. package/src/lib/components/base-form-canvas/base-form-canvas.component.css +22 -0
  54. package/src/lib/components/base-form-canvas/base-form-canvas.component.html +1006 -0
  55. package/src/lib/components/base-form-canvas/base-form-canvas.component.spec.ts +23 -0
  56. package/src/lib/components/base-form-canvas/base-form-canvas.component.ts +573 -0
  57. package/src/lib/components/base-input-dialog/base-input-dialog.component.css +0 -0
  58. package/src/lib/components/base-input-dialog/base-input-dialog.component.html +42 -0
  59. package/src/lib/components/base-input-dialog/base-input-dialog.component.spec.ts +23 -0
  60. package/src/lib/components/base-input-dialog/base-input-dialog.component.ts +78 -0
  61. package/src/lib/components/base-table/base-table.component.html +242 -0
  62. package/src/lib/components/base-table/base-table.component.scss +31 -0
  63. package/src/lib/components/base-table/base-table.component.spec.ts +25 -0
  64. package/src/lib/components/base-table/base-table.component.ts +568 -0
  65. package/src/lib/components/button-actions/button-actions.component.html +28 -0
  66. package/src/lib/components/button-actions/button-actions.component.scss +6 -0
  67. package/src/lib/components/button-actions/button-actions.component.spec.ts +23 -0
  68. package/src/lib/components/button-actions/button-actions.component.ts +72 -0
  69. package/src/lib/components/editable-base-table/editable-base-table.component.html +372 -0
  70. package/src/lib/components/editable-base-table/editable-base-table.component.scss +44 -0
  71. package/src/lib/components/editable-base-table/editable-base-table.component.spec.ts +25 -0
  72. package/src/lib/components/editable-base-table/editable-base-table.component.ts +570 -0
  73. package/src/lib/components/equation-builder/equation-builder.component.css +0 -0
  74. package/src/lib/components/equation-builder/equation-builder.component.html +31 -0
  75. package/src/lib/components/equation-builder/equation-builder.component.spec.ts +23 -0
  76. package/src/lib/components/equation-builder/equation-builder.component.ts +121 -0
  77. package/src/lib/components/multi-auto-complete/multi-auto-complete.component.css +11 -0
  78. package/src/lib/components/multi-auto-complete/multi-auto-complete.component.html +38 -0
  79. package/src/lib/components/multi-auto-complete/multi-auto-complete.component.spec.ts +23 -0
  80. package/src/lib/components/multi-auto-complete/multi-auto-complete.component.ts +317 -0
  81. package/src/lib/components/paginator/paginator.component.css +25 -0
  82. package/src/lib/components/paginator/paginator.component.html +34 -0
  83. package/src/lib/components/paginator/paginator.component.ts +94 -0
  84. package/src/lib/components/rejection-comment/action-comment.component.css +33 -0
  85. package/src/lib/components/rejection-comment/action-comment.component.html +46 -0
  86. package/src/lib/components/rejection-comment/action-comment.component.spec.ts +23 -0
  87. package/src/lib/components/rejection-comment/action-comment.component.ts +86 -0
  88. package/src/lib/components/report-details-dialog/report-details-dialog.component.css +17 -0
  89. package/src/lib/components/report-details-dialog/report-details-dialog.component.html +16 -0
  90. package/src/lib/components/report-details-dialog/report-details-dialog.component.spec.ts +23 -0
  91. package/src/lib/components/report-details-dialog/report-details-dialog.component.ts +113 -0
  92. package/src/lib/components/report-form/report-form.component.html +94 -0
  93. package/src/lib/components/report-form/report-form.component.scss +0 -0
  94. package/src/lib/components/report-form/report-form.component.spec.ts +25 -0
  95. package/src/lib/components/report-form/report-form.component.ts +588 -0
  96. package/src/lib/components/search-bar/search-bar.component.html +62 -0
  97. package/src/lib/components/search-bar/search-bar.component.scss +8 -0
  98. package/src/lib/components/search-bar/search-bar.component.spec.ts +25 -0
  99. package/src/lib/components/search-bar/search-bar.component.ts +70 -0
  100. package/src/lib/components/shared/attachment-uploader/attachment-uploader.component.css +54 -0
  101. package/src/lib/components/shared/attachment-uploader/attachment-uploader.component.html +22 -0
  102. package/src/lib/components/shared/attachment-uploader/attachment-uploader.component.spec.ts +23 -0
  103. package/src/lib/components/shared/attachment-uploader/attachment-uploader.component.ts +45 -0
  104. package/src/lib/components/shared-list/shared-list.component.css +0 -0
  105. package/src/lib/components/shared-list/shared-list.component.html +17 -0
  106. package/src/lib/components/shared-list/shared-list.component.spec.ts +23 -0
  107. package/src/lib/components/shared-list/shared-list.component.ts +53 -0
  108. package/src/lib/components/title-bar/title-bar.component.css +0 -0
  109. package/src/lib/components/title-bar/title-bar.component.css.map +1 -0
  110. package/src/lib/components/title-bar/title-bar.component.html +31 -0
  111. package/src/lib/components/title-bar/title-bar.component.scss +23 -0
  112. package/src/lib/components/title-bar/title-bar.component.spec.ts +23 -0
  113. package/src/lib/components/title-bar/title-bar.component.ts +119 -0
  114. package/src/lib/services/backend-service.ts +286 -0
  115. package/src/lib/services/index.ts +3 -0
  116. package/src/lib/services/top-panel.ts +17 -0
  117. package/src/lib/services/trigger-form.service.ts +11 -0
  118. package/src/lib/share-module/shared-module.ts +10 -0
  119. package/src/lib/styles/invoiceq-theme.scss +252 -0
  120. package/src/lib/styles/styles.scss +1723 -0
  121. package/src/lib/utils/base-utils.ts +102 -0
  122. package/src/lib/validators/date-range-validator.ts +31 -0
  123. package/src/lib/validators/index.ts +3 -0
  124. package/src/lib/validators/match-list.validator.ts +10 -0
  125. package/src/lib/validators/multi-email-validator.ts +15 -0
  126. package/src/public-api.ts +21 -0
  127. package/tsconfig.lib.json +15 -0
  128. package/tsconfig.lib.prod.json +11 -0
  129. package/tsconfig.spec.json +15 -0
@@ -0,0 +1,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 {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
+ }
@@ -0,0 +1,62 @@
1
+ <div class="mainSearchBar">
2
+ <div
3
+ fxLayout="row"
4
+ fxLayoutAlign="start center"
5
+ fxLayoutGap="16px"
6
+ class="search"
7
+ style="width: 100%; padding: 0 16px; margin-bottom: 16px;"
8
+ >
9
+
10
+ <mat-form-field appearance="outline" class="search__field" fxFlex="50">
11
+ <input
12
+ matInput
13
+ class="search__input"
14
+ placeholder="Search..."
15
+ (keydown.enter)= onSearch()
16
+ [(ngModel)]="searchValue" />
17
+ </mat-form-field>
18
+
19
+ <mat-form-field appearance="outline" class="search__field" fxFlex="15">
20
+ <mat-select
21
+ class="search__toggle"
22
+ [(ngModel)]="searchType"
23
+ placeholder="Type">
24
+ <mat-option value="exact">Exact</mat-option>
25
+ <mat-option value="like">Like</mat-option>
26
+ </mat-select>
27
+ </mat-form-field>
28
+
29
+
30
+ <mat-form-field appearance="outline" class="search__field" fxFlex="15">
31
+ <mat-select
32
+ class="search__toggle"
33
+ [(ngModel)]="selectedSortKey"
34
+ placeholder="Sort By">
35
+ <mat-option *ngFor="let col of getColumns()" [value]="col.property">
36
+ {{ labelKey(col) | translate }}
37
+ </mat-option>
38
+ </mat-select>
39
+ </mat-form-field>
40
+
41
+ <mat-form-field appearance="outline" class="search__field" fxFlex="10">
42
+ <mat-select
43
+ class="search__toggle"
44
+ [(ngModel)]="selectedSortType"
45
+ placeholder="Type">
46
+ <mat-option value="ASC">ASC</mat-option>
47
+ <mat-option value="DESC">DESC</mat-option>
48
+ </mat-select>
49
+ </mat-form-field>
50
+ <div
51
+ class="search__button"
52
+ fxLayout="row"
53
+ fxLayoutAlign="center center"
54
+ style="margin-bottom: 6px "
55
+ >
56
+ <div class="icon-design" (click)="onSearch()">
57
+ <mat-icon style="height: 30px; width: 30px; font-size: 30px; margin-bottom: 15px;cursor: pointer" color="primary">search</mat-icon>
58
+ </div>
59
+ </div>
60
+
61
+ </div>
62
+ </div>
@@ -0,0 +1,8 @@
1
+ ::ng-deep .search__button {
2
+ display: flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ height: 56px;
6
+ margin-top: -6px;
7
+
8
+ }
@@ -0,0 +1,25 @@
1
+ import {async, ComponentFixture, TestBed} from '@angular/core/testing';
2
+
3
+ import {SearchBarComponent} from './search-bar.component';
4
+
5
+ describe('SearchBarComponent', () => {
6
+ let component: SearchBarComponent;
7
+ let fixture: ComponentFixture<SearchBarComponent>;
8
+
9
+ beforeEach(async(() => {
10
+ TestBed.configureTestingModule({
11
+ declarations: [ SearchBarComponent ]
12
+ })
13
+ .compileComponents();
14
+ }));
15
+
16
+ beforeEach(() => {
17
+ fixture = TestBed.createComponent(SearchBarComponent);
18
+ component = fixture.componentInstance;
19
+ fixture.detectChanges();
20
+ });
21
+
22
+ it('should create', () => {
23
+ expect(component).toBeTruthy();
24
+ });
25
+ });