import * as React from 'react'; import { observer } from 'mobx-react'; import { caseCounts, getNumPatients, getNumSamples, MissingSamplesMessage, StudyViewComparisonGroup, } from '../GroupComparisonUtils'; import { StudyViewPageStore } from '../../studyView/StudyViewPageStore'; import autobind from 'autobind-decorator'; import { action, computed, makeObservable, observable } from 'mobx'; import ErrorIcon from '../../../shared/components/ErrorIcon'; import styles from '../styles.module.scss'; import { CirclePicker, CirclePickerProps } from 'react-color'; import { OverlayTrigger, Popover } from 'react-bootstrap'; import { COLORS } from '../../studyView/StudyViewUtils'; import { CLI_FEMALE_COLOR, CLI_NO_COLOR, CLI_YES_COLOR, DARK_GREY, } from '../../../shared/lib/Colors'; import { DefaultTooltip, TruncatedText } from 'cbioportal-frontend-commons'; import classnames from 'classnames'; import { ColorPickerIcon } from 'pages/groupComparison/comparisonGroupManager/ColorPickerIcon'; import { getBrowserWindow } from 'cbioportal-frontend-commons'; export interface IGroupCheckboxProps { group: StudyViewComparisonGroup; store: StudyViewPageStore; markedForDeletion: boolean; markedWithWarningSign: boolean; studyIds: string[]; restore: (group: StudyViewComparisonGroup) => void; delete: (group: StudyViewComparisonGroup) => void; shareGroup: (group: StudyViewComparisonGroup) => void; color: string; onChangeGroupColor: ( group: StudyViewComparisonGroup, color: string | undefined ) => void; } const COLOR_UNDEFINED = '#FFFFFF'; @observer export default class GroupCheckbox extends React.Component< IGroupCheckboxProps, {} > { constructor(props: IGroupCheckboxProps) { super(props); makeObservable(this); } @autobind private onCheckboxClick() { this.props.store.toggleComparisonGroupSelected(this.props.group.uid); this.props.store.flagDuplicateColorsForSelectedGroups( this.props.group.uid, this.props.color! ); } @autobind private onRestoreClick() { this.props.restore(this.props.group); } @autobind private onDeleteClick() { this.props.delete(this.props.group); } @autobind private shareGroup() { this.props.shareGroup(this.props.group); } @computed get label() { return (  ( {caseCounts( getNumSamples(this.props.group), getNumPatients(this.props.group) )} ) ); } @computed get colorList() { let colors: string[] = COLORS.slice(0, 20); colors.push(CLI_YES_COLOR); colors.push(CLI_NO_COLOR); colors.push(CLI_FEMALE_COLOR); colors.push(DARK_GREY); return colors; } @action.bound handleChangeComplete = (color: any, event: any) => { // if same color is select, unselect it (go back to no color) if (color.hex === this.props.color) { this.props.onChangeGroupColor(this.props.group, undefined); this.props.store.flagDuplicateColorsForSelectedGroups( this.props.group.uid, undefined ); } else { this.props.onChangeGroupColor(this.props.group, color.hex); this.props.store.flagDuplicateColorsForSelectedGroups( this.props.group.uid, color.hex ); } }; buildColorChooserWidget = () => (
{ e.nativeEvent.stopImmediatePropagation(); }} onClick={e => { e.nativeEvent.stopImmediatePropagation(); }} >
); render() { const group = this.props.group; let checkboxAndLabel; if (this.props.markedForDeletion) { checkboxAndLabel = ( {this.label} ); } else { checkboxAndLabel = (
{this.label}
); } return (
{checkboxAndLabel}
{!this.props.markedForDeletion && ( <> {this.props.markedWithWarningSign && ( )} )} {this.props.group.nonExistentSamples.length > 0 && ( } /> )} {this.props.markedForDeletion && ( )}
); } }