-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AG-1328: improve handling of target nominations table display strings #1302
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,9 +97,9 @@ export class GeneNominatedTargetsComponent implements OnInit { | |
// First map all entries nested in the data to a new array | ||
if (de.target_nominations?.length) { | ||
teamsArray = de.target_nominations.map((nt: TargetNomination) => nt.team); | ||
studyArray = de.target_nominations.map( | ||
(nt: TargetNomination) => nt.study | ||
); | ||
studyArray = de.target_nominations | ||
.map((nt: TargetNomination) => nt.study) | ||
.filter((item) => Boolean(item)) as string[]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as a suggestion, perhaps we can create a helper method to remove null/empty values . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in the next commit |
||
programsArray = de.target_nominations.map( | ||
(nt: TargetNomination) => nt.source | ||
); | ||
|
@@ -120,37 +120,10 @@ export class GeneNominatedTargetsComponent implements OnInit { | |
inputDataArray = this.commaFlattenArray(inputDataArray); | ||
|
||
// Populate targetNomination display fields | ||
de.teams_display_value = ''; | ||
if (teamsArray.length) { | ||
de.teams_display_value = teamsArray | ||
.filter(this.getUnique) | ||
.sort((a: string, b: string) => a.localeCompare(b)) | ||
.join(', '); | ||
} | ||
sagely1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
de.study_display_value = ''; | ||
if (teamsArray.length) { | ||
sagely1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
de.study_display_value = studyArray | ||
.filter(this.getUnique) | ||
.sort((a: string, b: string) => a.localeCompare(b)) | ||
.join(', '); | ||
} | ||
|
||
de.programs_display_value = ''; | ||
if (programsArray.length) { | ||
de.programs_display_value = programsArray | ||
.filter(this.getUnique) | ||
.sort((a: string, b: string) => a.localeCompare(b)) | ||
.join(', '); | ||
} | ||
|
||
de.input_data_display_value = ''; | ||
if (inputDataArray.length) { | ||
de.input_data_display_value = inputDataArray | ||
.filter(this.getUnique) | ||
.sort((a: string, b: string) => a.localeCompare(b)) | ||
.join(', '); | ||
} | ||
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.initial_nomination_display_value = initialNominationArray.length | ||
? Math.min(...initialNominationArray) | ||
|
@@ -189,27 +162,29 @@ export class GeneNominatedTargetsComponent implements OnInit { | |
return self.indexOf(value) === index; | ||
} | ||
|
||
commaFlattenArray(array: any[]): any[] { | ||
const finalArray: any[] = []; | ||
if (array.length) { | ||
array.forEach((t) => { | ||
if (t) { | ||
const i = t.indexOf(', '); | ||
if (i > -1) { | ||
const tmpArray = t.split(', '); | ||
finalArray.push(tmpArray[0]); | ||
finalArray.push(tmpArray[1]); | ||
} else { | ||
finalArray.push(t); | ||
} | ||
} else { | ||
finalArray.push(''); | ||
} | ||
}); | ||
array = finalArray; | ||
} | ||
commaFlattenArray(array: string[]): string[] { | ||
sagely1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const finalArray: string[] = []; | ||
array.forEach((t) => { | ||
const i = t.indexOf(', '); | ||
if (i > -1) { | ||
const tmpArray = t.split(', '); | ||
tmpArray.forEach((val) => finalArray.push(val)); | ||
sagely1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} else { | ||
finalArray.push(t); | ||
} | ||
}); | ||
return finalArray; | ||
} | ||
|
||
return array; | ||
formatDisplayValue(inputArray: string[]) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a suggestion, perhaps we can rename this to getCommaSeparatedString() or something similar to be a bit more descriptive. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call, done in next commit! |
||
let display_value = ''; | ||
if (inputArray.length) { | ||
display_value = inputArray | ||
.filter(this.getUnique) | ||
.sort((a: string, b: string) => a.localeCompare(b)) | ||
.join(', '); | ||
} | ||
return display_value; | ||
} | ||
|
||
onSearch(event: any) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create
setUp
method so that each test can specify which genes should be returned by the mock API service