Skip to content
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

Implement RFC85 Dynamic Virtual Study #5016

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/globalStyles/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ div:active {
}
}

.form-group-inline {
@extend .form-group;

label {
margin-right: 6px;
}
}

.posRelative {
position: relative;
}
Expand Down
25 changes: 16 additions & 9 deletions src/pages/studyView/StudyViewUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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
Expand Down
143 changes: 131 additions & 12 deletions src/pages/studyView/virtualStudy/VirtualStudy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {
Expand Down Expand Up @@ -167,6 +158,7 @@ export default class VirtualStudy extends React.Component<
study => study.studyId
),
studies: studies,
dynamic: this.dynamic,
};
return await sessionServiceClient.saveVirtualStudy(
parameters,
Expand Down Expand Up @@ -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 (
<div
Expand Down Expand Up @@ -298,6 +319,104 @@ export default class VirtualStudy extends React.Component<
/>
</div>

<div className="form-group-inline">
<label>Type:</label>
<label>
<input
type="radio"
name="option"
value="static"
checked={!this.dynamic}
onChange={_ =>
this.setDynamicTypeTo(
false
)
}
/>{' '}
Static
</label>
<label>
<input
type="radio"
name="option"
value="dynamic"
checked={this.dynamic}
onChange={_ =>
this.setDynamicTypeTo(
true
)
}
/>{' '}
Dynamic
</label>
<DefaultTooltip
mouseEnterDelay={0}
placement="right"
overlay={
<div>
<p>
<strong>
Type of Virtual
Study:
</strong>
</p>
<p>
This Virtual Study
will contain the set
of sample IDs
currently selected.
Furthermore, you can
define this Virtual
Study either static
or dynamic:
</p>
<ul>
<li>
<strong>
Static
</strong>{' '}
– Sample IDs are
the ones
currently
selected and no
new samples are
added to this
Virtual Study
set, even if the
database gets
updated with new
samples that
match the same
filtering/selection
criteria as the
samples in the
current set.
</li>
<li>
<strong>
Dynamic
</strong>{' '}
– Unlike the
Static option,
any new samples
added to the
database that
match the
criteria of this
Virtual Study
will
automatically be
included in its
sample set.
</li>
</ul>
</div>
}
>
<FontAwesome name="question-circle" />
</DefaultTooltip>
</div>

<div>
{this.showSaveButton && (
<button
Expand Down
Loading