@iapps/ng-dhis2-ui 1.1.12 → 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.
|
@@ -3282,8 +3282,10 @@ const addActionsColumn = (columns, actionOptions) => {
|
|
|
3282
3282
|
class LineListTableComponent extends ReactWrapperModule {
|
|
3283
3283
|
constructor() {
|
|
3284
3284
|
super(...arguments);
|
|
3285
|
+
this.showApprovalButton = false;
|
|
3285
3286
|
this.actionSelected = new EventEmitter();
|
|
3286
3287
|
this.reactStateUpdaters = null;
|
|
3288
|
+
this.approvalSelected = new EventEmitter();
|
|
3287
3289
|
this.setReactStateUpdaters = (updaters) => {
|
|
3288
3290
|
this.reactStateUpdaters = updaters;
|
|
3289
3291
|
};
|
|
@@ -3385,31 +3387,71 @@ class LineListTableComponent extends ReactWrapperModule {
|
|
|
3385
3387
|
},
|
|
3386
3388
|
}));
|
|
3387
3389
|
};
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3390
|
+
const handleApprovalClick = () => {
|
|
3391
|
+
this.lineListService
|
|
3392
|
+
.getLineListData(this.programId, this.orgUnit, this.programStageId, pager.page, pager.pageSize, this.attributeFilters, this.startDate, this.endDate, this.ouMode)
|
|
3393
|
+
.subscribe((response) => {
|
|
3394
|
+
if ('trackedEntityInstances' in response.data) {
|
|
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);
|
|
3412
|
+
}
|
|
3413
|
+
else {
|
|
3414
|
+
console.log('No tracked entity instances found in the response');
|
|
3415
|
+
this.approvalSelected.emit([]); // Emit empty array if no TEIs
|
|
3416
|
+
}
|
|
3417
|
+
});
|
|
3418
|
+
};
|
|
3419
|
+
return (React__default.createElement("div", null,
|
|
3420
|
+
this.showApprovalButton && (React__default.createElement("div", { style: {
|
|
3421
|
+
width: '100%',
|
|
3422
|
+
display: 'flex',
|
|
3423
|
+
justifyContent: 'flex-end',
|
|
3424
|
+
alignItems: 'center',
|
|
3425
|
+
gap: 8,
|
|
3426
|
+
padding: 8,
|
|
3427
|
+
marginBottom: 16,
|
|
3428
|
+
} },
|
|
3429
|
+
React__default.createElement(Button$1, { className: "bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600", onClick: handleApprovalClick, primary: true }, "Approval"))),
|
|
3430
|
+
loading ? (React__default.createElement("div", { style: {
|
|
3431
|
+
display: 'flex',
|
|
3432
|
+
alignItems: 'center',
|
|
3433
|
+
gap: 8,
|
|
3434
|
+
padding: 8,
|
|
3435
|
+
} },
|
|
3436
|
+
React__default.createElement(CircularLoader$1, { small: true }),
|
|
3437
|
+
React__default.createElement("div", { style: {
|
|
3438
|
+
fontSize: 14,
|
|
3439
|
+
} }, "Loading"))) : (React__default.createElement(DataTable, null,
|
|
3440
|
+
React__default.createElement(TableHead, null,
|
|
3441
|
+
React__default.createElement(DataTableRow, null, columns.map((col) => (React__default.createElement(DataTableColumnHeader, { key: col.key }, col.label))))),
|
|
3442
|
+
React__default.createElement(TableBody, null, data.map((row) => (React__default.createElement(DataTableRow, { key: row.index }, columns.map((col) => (React__default.createElement(DataTableCell, { key: col.key }, col.key === 'actions' ? (React__default.createElement(DropdownMenu$1, { dropdownOptions: getDropdownOptions(row), onClick: (option) => option.onClick?.() })) : (row[col.key])))))))),
|
|
3443
|
+
React__default.createElement(TableFoot, null,
|
|
3444
|
+
React__default.createElement(DataTableRow, null,
|
|
3445
|
+
React__default.createElement(DataTableCell, { colSpan: columns.length.toString() },
|
|
3446
|
+
React__default.createElement("div", null,
|
|
3447
|
+
React__default.createElement(Pagination, { page: pager.page, pageCount: pager.pageCount, pageSize: pager.pageSize, total: pager.total, onPageChange: (page) => setPager((prev) => ({ ...prev, page })), onPageSizeChange: (pageSize) => {
|
|
3448
|
+
const newPageSize = Number(pageSize);
|
|
3449
|
+
setPager((prev) => ({
|
|
3450
|
+
...prev,
|
|
3451
|
+
page: 1,
|
|
3452
|
+
pageSize: newPageSize,
|
|
3453
|
+
}));
|
|
3454
|
+
}, pageSizes: ['5', '10', '20', '50'] })))))))));
|
|
3413
3455
|
};
|
|
3414
3456
|
}
|
|
3415
3457
|
ngOnChanges(changes) {
|
|
@@ -3442,7 +3484,7 @@ class LineListTableComponent extends ReactWrapperModule {
|
|
|
3442
3484
|
this.render();
|
|
3443
3485
|
}
|
|
3444
3486
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: LineListTableComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
3445
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.8", type: LineListTableComponent, isStandalone: false, selector: "app-line-list", inputs: { programId: "programId", orgUnit: "orgUnit", programStageId: "programStageId", actionOptions: "actionOptions", attributeFilters: "attributeFilters", startDate: "startDate", endDate: "endDate", filters: "filters", ouMode: "ouMode" }, outputs: { actionSelected: "actionSelected" }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, styles: ["[data-test=dhis2-uiwidgets-pagination]{display:flex!important;flex-direction:row!important;justify-content:space-between!important;align-items:center!important}\n"] }); }
|
|
3487
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.8", type: LineListTableComponent, isStandalone: false, selector: "app-line-list", inputs: { programId: "programId", orgUnit: "orgUnit", programStageId: "programStageId", actionOptions: "actionOptions", attributeFilters: "attributeFilters", startDate: "startDate", endDate: "endDate", filters: "filters", ouMode: "ouMode", showApprovalButton: "showApprovalButton" }, outputs: { actionSelected: "actionSelected", approvalSelected: "approvalSelected" }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, styles: ["[data-test=dhis2-uiwidgets-pagination]{display:flex!important;flex-direction:row!important;justify-content:space-between!important;align-items:center!important}\n"] }); }
|
|
3446
3488
|
}
|
|
3447
3489
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImport: i0, type: LineListTableComponent, decorators: [{
|
|
3448
3490
|
type: Component,
|
|
@@ -3465,8 +3507,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.8", ngImpor
|
|
|
3465
3507
|
type: Input
|
|
3466
3508
|
}], ouMode: [{
|
|
3467
3509
|
type: Input
|
|
3510
|
+
}], showApprovalButton: [{
|
|
3511
|
+
type: Input
|
|
3468
3512
|
}], actionSelected: [{
|
|
3469
3513
|
type: Output
|
|
3514
|
+
}], approvalSelected: [{
|
|
3515
|
+
type: Output
|
|
3470
3516
|
}] } });
|
|
3471
3517
|
|
|
3472
3518
|
class LineListModule {
|