diff --git a/src/pages/studyView/virtualStudy/VirtualStudy.tsx b/src/pages/studyView/virtualStudy/VirtualStudy.tsx index 71f4fbdf578..429a77de628 100644 --- a/src/pages/studyView/virtualStudy/VirtualStudy.tsx +++ b/src/pages/studyView/virtualStudy/VirtualStudy.tsx @@ -97,7 +97,7 @@ export default class VirtualStudy extends React.Component< {} > { @observable.ref private name: string; - @observable.ref private description: string = ''; + @observable.ref private userProvidedDescription: string = ''; @observable.ref private dynamic: boolean = false; @observable private saving = false; @@ -108,7 +108,7 @@ export default class VirtualStudy extends React.Component< super(props); makeObservable(this); this.name = props.name || ''; - this.setDynamicTypeTo(false); + this.userProvidedDescription = this.description; } @computed get namePlaceHolder() { @@ -223,33 +223,29 @@ export default class VirtualStudy extends React.Component< ); } - updateDescriptionIfBlankOrDefault(hideSampleCounts: boolean) { - const getVirtualStudyDescriptionWithCounts = getVirtualStudyDescription.bind( - null, + getDefuaultDescriptionByType(dynamic: boolean) { + return getVirtualStudyDescription( this.props.description, this.props.studyWithSamples, this.props.filter, this.attributeNamesSet, this.props.molecularProfileNameSet, this.props.caseListNameSet, - this.props.user + this.props.user, + dynamic ); + } + + @computed get description() { const blankOrDefaultDescription = - !this.description || - !this.description.trim() || - this.description === - getVirtualStudyDescriptionWithCounts(!hideSampleCounts); + !this.userProvidedDescription || + !this.userProvidedDescription.trim() || + this.userProvidedDescription === + this.getDefuaultDescriptionByType(!this.dynamic); if (blankOrDefaultDescription) { - this.description = getVirtualStudyDescriptionWithCounts( - hideSampleCounts - ); + return this.getDefuaultDescriptionByType(this.dynamic); } - } - - setDynamicTypeTo(dynamic: boolean) { - this.dynamic = dynamic; - - this.updateDescriptionIfBlankOrDefault(dynamic); + return this.userProvidedDescription; } render() { @@ -313,7 +309,7 @@ export default class VirtualStudy extends React.Component< placeholder="Virtual study description (Optional)" value={this.description} onChange={event => - (this.description = + (this.userProvidedDescription = event.currentTarget.value) } /> @@ -328,9 +324,7 @@ export default class VirtualStudy extends React.Component< value="static" checked={!this.dynamic} onChange={_ => - this.setDynamicTypeTo( - false - ) + (this.dynamic = false) } />{' '} Static @@ -342,9 +336,7 @@ export default class VirtualStudy extends React.Component< value="dynamic" checked={this.dynamic} onChange={_ => - this.setDynamicTypeTo( - true - ) + (this.dynamic = true) } />{' '} Dynamic