From cfea38caad76bcdf9439b600d86db4282ed2e2d9 Mon Sep 17 00:00:00 2001 From: Anshuman rai Date: Thu, 12 Dec 2024 23:58:48 +0530 Subject: [PATCH 1/2] custom-selection-added --- .../CustomCaseSelection.tsx | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/pages/studyView/addChartButton/customCaseSelection/CustomCaseSelection.tsx b/src/pages/studyView/addChartButton/customCaseSelection/CustomCaseSelection.tsx index f8ffd71185b..0f499eeb35d 100644 --- a/src/pages/studyView/addChartButton/customCaseSelection/CustomCaseSelection.tsx +++ b/src/pages/studyView/addChartButton/customCaseSelection/CustomCaseSelection.tsx @@ -158,7 +158,16 @@ export default class CustomCaseSelection extends React.Component< @action.bound onChange(newContent: string) { - this.validContent = newContent; + // Preprocess content to allow spaces, tabs, and commas as valid delimiters + const normalizedContent = newContent + .split(/[, ]+/) // Split the content by either commas or spaces + .map(line => line.trim()) // Remove extra spaces around each line + .filter(line => line.length > 0) // Remove empty lines + .join('\n'); // Use newline as the final delimiter + + // Assign normalized content and trigger validation + this.validContent = normalizedContent; + // this.validContent = newContent; this.validateContent = true; } @@ -207,11 +216,26 @@ export default class CustomCaseSelection extends React.Component< this.caseIdsMode === ClinicalDataTypeEnum.SAMPLE ? 'sample_id' : 'patient_id'; - return `Example:\nstudy_id:${caseIdentifier}1${ + + // Creating example strings for each delimiter type + const newLineExample = `study_id:${caseIdentifier}1${ this.props.disableGrouping ? '' : ' value1' }\nstudy_id:${caseIdentifier}2${ this.props.disableGrouping ? '' : ' value2' }`; + const commaExample = `study_id:${caseIdentifier}1${ + this.props.disableGrouping ? '' : ' value1' + }, study_id:${caseIdentifier}2${ + this.props.disableGrouping ? '' : ' value2' + }`; + const spaceExample = `study_id:${caseIdentifier}1${ + this.props.disableGrouping ? '' : ' value1' + } study_id:${caseIdentifier}2${ + this.props.disableGrouping ? '' : ' value2' + }`; + + // Combining all three cases into one string + return `Example with newline:\n${newLineExample}\n\nExample with comma:\n${commaExample}\n\nExample with space:\n${spaceExample}`; } @computed From c039542673506902073b963ac9781f304fbe84e6 Mon Sep 17 00:00:00 2001 From: Ino de Bruijn Date: Mon, 30 Dec 2024 09:54:44 -0500 Subject: [PATCH 2/2] remove old comment line --- .../addChartButton/customCaseSelection/CustomCaseSelection.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/studyView/addChartButton/customCaseSelection/CustomCaseSelection.tsx b/src/pages/studyView/addChartButton/customCaseSelection/CustomCaseSelection.tsx index 0f499eeb35d..6d0ec65ea0b 100644 --- a/src/pages/studyView/addChartButton/customCaseSelection/CustomCaseSelection.tsx +++ b/src/pages/studyView/addChartButton/customCaseSelection/CustomCaseSelection.tsx @@ -167,7 +167,6 @@ export default class CustomCaseSelection extends React.Component< // Assign normalized content and trigger validation this.validContent = normalizedContent; - // this.validContent = newContent; this.validateContent = true; }