From 19b7380c8ea8e1b05ddd338055de1e8fbd5b88e8 Mon Sep 17 00:00:00 2001 From: Saningo Lekalantula Date: Wed, 15 Nov 2023 15:37:21 +0300 Subject: [PATCH] POC-558 (#1678) * Change the Male/Female gender disaagregation to start with Female then Male * Change the Male/Female gender disaagregation to start with Female then Male --------- Co-authored-by: kantush Co-authored-by: Drizzentic --- .../prep-monthly-report-view.component.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/app/hiv-care-lib/prep-report/monthly/prep-monthly-report-view/prep-monthly-report-view.component.ts b/src/app/hiv-care-lib/prep-report/monthly/prep-monthly-report-view/prep-monthly-report-view.component.ts index 50c8a85d7..eb08b6854 100644 --- a/src/app/hiv-care-lib/prep-report/monthly/prep-monthly-report-view/prep-monthly-report-view.component.ts +++ b/src/app/hiv-care-lib/prep-report/monthly/prep-monthly-report-view/prep-monthly-report-view.component.ts @@ -55,6 +55,12 @@ export class PrepMonthlyReportViewComponent implements OnInit, OnChanges { this.indicatorSelected.emit(payload); } + swapIndices(arr: any[]) { + for (let i = 0; i < arr.length - 1; i += 2) { + [arr[i], arr[i + 1]] = [arr[i + 1], arr[i]]; + } + } + public buildTableBody() { this.tableSectionData = this.SummaryData; this.tableSectionIndicators = this.sectionDefs; @@ -88,6 +94,13 @@ export class PrepMonthlyReportViewComponent implements OnInit, OnChanges { } ); + // Find the first occurrence of 'F' in the original array + const firstFIndex = this.genderGroups.indexOf('F'); + + this.genderGroups = this.genderGroups + .slice(firstFIndex) + .concat(this.genderGroups.slice(0, firstFIndex)); + // Table data // Remove the first two sections const allData = this.tableSectionIndicators.slice(2); @@ -96,6 +109,7 @@ export class PrepMonthlyReportViewComponent implements OnInit, OnChanges { this.tableData.push({ sectionTitle: section.sectionTitle, sectionData: section.indicators.map((sect) => { + this.swapIndices(sect.indicators); return { rowTitle: sect.label, rowData: sect.indicators.map((val) => {