diff --git a/src/globalStyles/global.scss b/src/globalStyles/global.scss index 81f33b14a2d..7b1839b6d60 100755 --- a/src/globalStyles/global.scss +++ b/src/globalStyles/global.scss @@ -47,6 +47,14 @@ div:active { } } +.form-group-inline { + @extend .form-group; + + label { + margin-right: 6px; + } +} + .posRelative { position: relative; } diff --git a/src/pages/studyView/StudyViewUtils.tsx b/src/pages/studyView/StudyViewUtils.tsx index e2e8b78bc78..06c56f02131 100644 --- a/src/pages/studyView/StudyViewUtils.tsx +++ b/src/pages/studyView/StudyViewUtils.tsx @@ -903,7 +903,8 @@ export function getVirtualStudyDescription( attributeNamesSet: { [id: string]: string }, molecularProfileNameSet: { [id: string]: string }, caseListNameSet: { [key: string]: string }, - user?: string + user?: string, + hideSampleCounts: boolean = false ) { let descriptionLines: string[] = []; const createdOnStr = 'Created on'; @@ -917,18 +918,24 @@ export function getVirtualStudyDescription( _.flatMap(studyWithSamples, study => study.uniqueSampleKeys) ); descriptionLines.push( - `${uniqueSampleKeys.length} sample${ - uniqueSampleKeys.length > 1 ? 's' : '' - } from ${studyWithSamples.length} ${ - studyWithSamples.length > 1 ? 'studies:' : 'study:' - }` + (hideSampleCounts + ? 'Samples' + : `${uniqueSampleKeys.length} sample${ + uniqueSampleKeys.length > 1 ? 's' : '' + }`) + + ` from ${studyWithSamples.length} ${ + studyWithSamples.length > 1 ? 'studies:' : 'study:' + }` ); //add individual studies sample count studyWithSamples.forEach(studyObj => { descriptionLines.push( - `- ${studyObj.name} (${ - studyObj.uniqueSampleKeys.length - } sample${uniqueSampleKeys.length > 1 ? 's' : ''})` + `- ${studyObj.name}` + + (hideSampleCounts + ? '' + : ` (${studyObj.uniqueSampleKeys.length} sample${ + uniqueSampleKeys.length > 1 ? 's' : '' + })`) ); }); //add filters diff --git a/src/pages/studyView/virtualStudy/VirtualStudy.tsx b/src/pages/studyView/virtualStudy/VirtualStudy.tsx index 4a492d847c4..bd5898cd8ae 100644 --- a/src/pages/studyView/virtualStudy/VirtualStudy.tsx +++ b/src/pages/studyView/virtualStudy/VirtualStudy.tsx @@ -97,7 +97,8 @@ export default class VirtualStudy extends React.Component< {} > { @observable.ref private name: string; - @observable.ref private description: string; + @observable.ref private description: string = ''; + @observable.ref private dynamic: boolean = false; @observable private saving = false; @observable private sharing = false; @@ -107,17 +108,7 @@ export default class VirtualStudy extends React.Component< super(props); makeObservable(this); this.name = props.name || ''; - this.description = - props.description || - getVirtualStudyDescription( - this.props.description, - this.props.studyWithSamples, - this.props.filter, - this.attributeNamesSet, - this.props.molecularProfileNameSet, - this.props.caseListNameSet, - this.props.user - ); + this.setDynamicTypeTo(false); } @computed get namePlaceHolder() { @@ -167,6 +158,7 @@ export default class VirtualStudy extends React.Component< study => study.studyId ), studies: studies, + dynamic: this.dynamic, }; return await sessionServiceClient.saveVirtualStudy( parameters, @@ -231,6 +223,35 @@ export default class VirtualStudy extends React.Component< ); } + updateDescriptionIfBlankOrDefault(hideSampleCounts: boolean) { + const getVirtualStudyDescriptionWithCounts = getVirtualStudyDescription.bind( + null, + this.props.description, + this.props.studyWithSamples, + this.props.filter, + this.attributeNamesSet, + this.props.molecularProfileNameSet, + this.props.caseListNameSet, + this.props.user + ); + const blankOrDefaultDescription = + !this.description || + !this.description.trim() || + this.description === + getVirtualStudyDescriptionWithCounts(!hideSampleCounts); + if (blankOrDefaultDescription) { + this.description = getVirtualStudyDescriptionWithCounts( + hideSampleCounts + ); + } + } + + setDynamicTypeTo(dynamic: boolean) { + this.dynamic = dynamic; + + this.updateDescriptionIfBlankOrDefault(dynamic); + } + render() { return (
+
+ + + + +

+ + Type of Virtual + Study: + +

+

+ This Virtual Study + will contain the set + of sample IDs + currently selected. + Furthermore, you can + define this Virtual + Study either static + or dynamic: +

+ +
+ } + > + + + +
{this.showSaveButton && (