@iapps/ng-dhis2-ui 1.1.13 → 1.1.14
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.
|
@@ -3387,24 +3387,28 @@ class LineListTableComponent extends ReactWrapperModule {
|
|
|
3387
3387
|
},
|
|
3388
3388
|
}));
|
|
3389
3389
|
};
|
|
3390
|
-
// // Add this handler for the Approval button
|
|
3391
|
-
// const handleApprovalClick = () => {
|
|
3392
|
-
// console.log('Approval button clicked');
|
|
3393
|
-
// // Optionally emit an event to Angular parent component
|
|
3394
|
-
// // this.actionSelected.emit({ action: 'Approval', row: null });
|
|
3395
|
-
// };
|
|
3396
|
-
// Updated handler using the new approvalSelected emitter
|
|
3397
3390
|
const handleApprovalClick = () => {
|
|
3398
3391
|
this.lineListService
|
|
3399
3392
|
.getLineListData(this.programId, this.orgUnit, this.programStageId, pager.page, pager.pageSize, this.attributeFilters, this.startDate, this.endDate, this.ouMode)
|
|
3400
3393
|
.subscribe((response) => {
|
|
3401
3394
|
if ('trackedEntityInstances' in response.data) {
|
|
3402
|
-
const trackedEntityInstances = response.data
|
|
3403
|
-
|
|
3404
|
-
const
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3395
|
+
const trackedEntityInstances = response.data.trackedEntityInstances;
|
|
3396
|
+
// Map TEIs to objects with teiId and enrollmentId
|
|
3397
|
+
const teiEnrollmentList = trackedEntityInstances
|
|
3398
|
+
.map((tei) => {
|
|
3399
|
+
// Find the enrollment where program matches this.programId
|
|
3400
|
+
const matchingEnrollment = tei.enrollments?.find((enrollment) => enrollment.program === this.programId);
|
|
3401
|
+
// Return object with teiId and enrollmentId (if found)
|
|
3402
|
+
return matchingEnrollment
|
|
3403
|
+
? {
|
|
3404
|
+
teiId: tei.trackedEntityInstance,
|
|
3405
|
+
enrollmentId: matchingEnrollment.enrollment,
|
|
3406
|
+
}
|
|
3407
|
+
: null;
|
|
3408
|
+
})
|
|
3409
|
+
.filter((item) => item !== null); // Remove null entries (no matching enrollment)
|
|
3410
|
+
console.log('TEI and Enrollment IDs emitted:', teiEnrollmentList);
|
|
3411
|
+
this.approvalSelected.emit(teiEnrollmentList);
|
|
3408
3412
|
}
|
|
3409
3413
|
else {
|
|
3410
3414
|
console.log('No tracked entity instances found in the response');
|