Skip to content

Commit

Permalink
POC-558 (AMPATH#1678)
Browse files Browse the repository at this point in the history
* 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 <sainingo>
Co-authored-by: Drizzentic <derrickrono@gmail.com>
  • Loading branch information
sainingo and drizzentic authored Nov 15, 2023
1 parent cff94f4 commit ea324fd
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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) => {
Expand Down

0 comments on commit ea324fd

Please sign in to comment.