From 9c9015180a60fa0ee39cb3034859f856c4614f00 Mon Sep 17 00:00:00 2001 From: Hallie Swan <26949006+hallieswan@users.noreply.github.com> Date: Mon, 13 May 2024 13:54:35 -0700 Subject: [PATCH] AG-1328: improvements from code review --- .../gene-nominated-targets.component.spec.ts | 17 ++++++++++++++--- .../gene-nominated-targets.component.ts | 14 +++++++++----- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/app/features/genes/components/gene-nominated-targets/gene-nominated-targets.component.spec.ts b/src/app/features/genes/components/gene-nominated-targets/gene-nominated-targets.component.spec.ts index 927e67c1..96d9c5ba 100644 --- a/src/app/features/genes/components/gene-nominated-targets/gene-nominated-targets.component.spec.ts +++ b/src/app/features/genes/components/gene-nominated-targets/gene-nominated-targets.component.spec.ts @@ -126,10 +126,12 @@ describe('Component: Gene Nominated Targets', () => { it('should correctly format display values', () => { setUp([]); - expect(component.formatDisplayValue([])).toEqual(''); + expect( + component.getCommaSeparatedStringOfUniqueSortedValues([]) + ).toEqual(''); expect( - component.formatDisplayValue([ + component.getCommaSeparatedStringOfUniqueSortedValues([ 'ACT', 'BLSA', 'Banner', @@ -140,7 +142,16 @@ describe('Component: Gene Nominated Targets', () => { ).toEqual('ACT, Banner, BLSA'); expect( - component.formatDisplayValue(['Z', 'Y', 'X', 'A', 'B', 'C', 'B', 'C']) + component.getCommaSeparatedStringOfUniqueSortedValues([ + 'Z', + 'Y', + 'X', + 'A', + 'B', + 'C', + 'B', + 'C', + ]) ).toEqual('A, B, C, X, Y, Z'); }); }); diff --git a/src/app/features/genes/components/gene-nominated-targets/gene-nominated-targets.component.ts b/src/app/features/genes/components/gene-nominated-targets/gene-nominated-targets.component.ts index 2106de7c..ce01a7b8 100644 --- a/src/app/features/genes/components/gene-nominated-targets/gene-nominated-targets.component.ts +++ b/src/app/features/genes/components/gene-nominated-targets/gene-nominated-targets.component.ts @@ -120,10 +120,14 @@ export class GeneNominatedTargetsComponent implements OnInit { inputDataArray = this.commaFlattenArray(inputDataArray); // Populate targetNomination display fields - de.teams_display_value = this.formatDisplayValue(teamsArray); - de.study_display_value = this.formatDisplayValue(studyArray); - de.programs_display_value = this.formatDisplayValue(programsArray); - de.input_data_display_value = this.formatDisplayValue(inputDataArray); + de.teams_display_value = + this.getCommaSeparatedStringOfUniqueSortedValues(teamsArray); + de.study_display_value = + this.getCommaSeparatedStringOfUniqueSortedValues(studyArray); + de.programs_display_value = + this.getCommaSeparatedStringOfUniqueSortedValues(programsArray); + de.input_data_display_value = + this.getCommaSeparatedStringOfUniqueSortedValues(inputDataArray); de.initial_nomination_display_value = initialNominationArray.length ? Math.min(...initialNominationArray) @@ -176,7 +180,7 @@ export class GeneNominatedTargetsComponent implements OnInit { return finalArray; } - formatDisplayValue(inputArray: string[]) { + getCommaSeparatedStringOfUniqueSortedValues(inputArray: string[]) { let display_value = ''; if (inputArray.length) { display_value = inputArray