From 939a1f5fbf46c34361d1e1d336a02c096bc05838 Mon Sep 17 00:00:00 2001 From: Hongxin Zhang Date: Mon, 16 Dec 2019 17:29:29 -0500 Subject: [PATCH] Give option to list unselected cases in the Custom Selection component --- .../CustomCaseSelection.tsx | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/src/pages/studyView/addChartButton/customCaseSelection/CustomCaseSelection.tsx b/src/pages/studyView/addChartButton/customCaseSelection/CustomCaseSelection.tsx index 472db2d8f5b..9c090819c98 100644 --- a/src/pages/studyView/addChartButton/customCaseSelection/CustomCaseSelection.tsx +++ b/src/pages/studyView/addChartButton/customCaseSelection/CustomCaseSelection.tsx @@ -35,6 +35,9 @@ const GroupByOptions: { value: ClinicalDataType, label: string; }[] = [ {value: ClinicalDataTypeEnum.PATIENT, label: 'By patient ID'} ]; +enum SelectMode { + SELECTED, UNSELECTED +} @observer export default class CustomCaseSelection extends React.Component { private validateContent: boolean = false; @@ -76,14 +79,23 @@ export default class CustomCaseSelection extends React.Component { + onClick(selectMode: SelectMode) { + let selectedCases; + if (selectMode === SelectMode.SELECTED) { + selectedCases = this.props.selectedSamples; + } else { + const _selectedCaseIds = this.props.selectedSamples.map(sample => sample.sampleId); + selectedCases = this.props.allSamples.filter(sample => { + return !_selectedCaseIds.includes(sample.sampleId); + }); + } + let cases = selectedCases.map(sample => { return `${sample.studyId}:${(this.caseIdsMode === ClinicalDataTypeEnum.SAMPLE) ? sample.sampleId : sample.patientId}${this.props.disableGrouping ? '' : ` ${DEFAULT_GROUP_NAME_WITHOUT_USER_INPUT}`}` }); if (this.caseIdsMode === ClinicalDataTypeEnum.PATIENT) { cases = _.uniq(cases); } - this.content = cases.join("\n") + this.content = cases.join("\n"); this.validateContent = false; this.validContent = this.content; } @@ -94,7 +106,7 @@ export default class CustomCaseSelection extends React.Component - Use currently selected samples/patients + onClick={() => { + this.onClick(SelectMode.SELECTED); + }}> + currently selected + + { + this.onClick(SelectMode.UNSELECTED); + }}> + unselected
@@ -177,7 +198,7 @@ export default class CustomCaseSelection extends React.Component
- +
{this.dataFormatContent}
@@ -232,4 +253,4 @@ export default class CustomCaseSelection extends React.Component