Skip to content

Commit a665ed5

Browse files
committed
#1261 added buttons into observation dialog for later poses handling
1 parent e76b303 commit a665ed5

File tree

1 file changed

+98
-1
lines changed

1 file changed

+98
-1
lines changed

js/components/preview/molecule/observationsDialog.js

+98-1
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ import SearchField from '../../common/Components/SearchField';
3232
import GroupNglControlButtonsContext from './groupNglControlButtonsContext';
3333
import MoleculeView from './moleculeView';
3434
import { TagEditor } from '../tags/modal/tagEditor';
35+
import { ToastContext } from '../../toast';
36+
import { DJANGO_CONTEXT } from '../../../utils/djangoContext';
3537

3638
const useStyles = makeStyles(theme => ({
3739
paper: {
3840
width: 472,
39-
height: 294,
41+
// minHeight: 294,
4042
overflowY: 'hidden'
4143
},
4244
molHeader: {
@@ -112,6 +114,39 @@ const useStyles = makeStyles(theme => ({
112114
backgroundColor: theme.palette.primary.semidark
113115
//color: theme.palette.black
114116
}
117+
},
118+
contColButtonBottomRow: {
119+
border: '1px solid'
120+
},
121+
bottomRow: {
122+
marginTop: theme.spacing(1) / 4
123+
},
124+
dropdownContent: {
125+
display: 'none',
126+
position: 'absolute',
127+
backgroundColor: theme.palette.primary.contrastText,
128+
maxWidth: 150,
129+
marginTop: -1,
130+
border: '1px solid',
131+
borderColor: theme.palette.primary.main,
132+
// color: theme.palette.primary.contrastText,
133+
// boxShadow: '0px 8px 16px 0px rgba(0, 0, 0, 0.2)',
134+
zIndex: 1
135+
},
136+
dropdownItem: {
137+
fontSize: 12,
138+
// fontWeight: 'bold',
139+
paddingLeft: theme.spacing(1) / 4,
140+
paddingRight: theme.spacing(1) / 4,
141+
'&:hover': {
142+
cursor: 'pointer',
143+
backgroundColor: theme.palette.primary.light
144+
}
145+
},
146+
dropdown: {
147+
'&:hover $dropdownContent': {
148+
display: 'flex'
149+
}
115150
}
116151
}));
117152

@@ -127,6 +162,7 @@ export const ObservationsDialog = memo(
127162
const selectedAll = useRef(false);
128163

129164
const { getNglView } = useContext(NglContext);
165+
const { toastInfo } = useContext(ToastContext);
130166
const stage = getNglView(VIEWS.MAJOR_VIEW) && getNglView(VIEWS.MAJOR_VIEW).stage;
131167

132168
const isLoadingInspirationListOfMolecules = useSelector(
@@ -304,6 +340,20 @@ export const ObservationsDialog = memo(
304340
buttonState => buttonState
305341
);
306342

343+
const handleSetAsGroupName = () => {
344+
toastInfo('calling handleSetAsGroupName!', { autoHideDuration: 5000 });
345+
};
346+
const handleSetMainObservation = () => {
347+
toastInfo('calling handleSetMainObservation!', { autoHideDuration: 5000 });
348+
};
349+
const handleManageGrouping = (poseId) => {
350+
if (poseId === 0) {
351+
toastInfo(`calling handleManageGrouping and creating new pose from selection`, { autoHideDuration: 5000 });
352+
} else {
353+
toastInfo(`calling handleManageGrouping for pose with id ${poseId}`, { autoHideDuration: 5000 });
354+
}
355+
};
356+
307357
// TODO refactor to this line
308358

309359
return (
@@ -465,6 +515,53 @@ export const ObservationsDialog = memo(
465515
</Grid>
466516
)}
467517
</div>
518+
{DJANGO_CONTEXT.pk && <Grid container direction="row" justifyContent="space-evenly" alignItems="center" className={classes.bottomRow}>
519+
<Grid item>
520+
<Button
521+
onClick={handleSetAsGroupName}
522+
disabled={allSelectedMolecules.length !== 1}
523+
color="inherit"
524+
variant="text"
525+
size="small"
526+
data-id="setAsGroupName"
527+
className={classNames(classes.contColButton, classes.contColButtonBottomRow)}
528+
>
529+
Set as group name
530+
</Button>
531+
</Grid>
532+
<Grid item>
533+
<Button
534+
onClick={handleSetMainObservation}
535+
disabled={allSelectedMolecules.length !== 1}
536+
color="inherit"
537+
variant="text"
538+
size="small"
539+
data-id="setMainObservation"
540+
className={classNames(classes.contColButton, classes.contColButtonBottomRow)}
541+
>
542+
Set main observation
543+
</Button>
544+
</Grid>
545+
<Grid item className={classes.dropdown}>
546+
<Button
547+
disabled={allSelectedMolecules.length < 1}
548+
color="inherit"
549+
variant="text"
550+
size="small"
551+
data-id="manageGrouping"
552+
className={classNames(classes.contColButton, classes.contColButtonBottomRow)}
553+
>
554+
Manage grouping
555+
</Button>
556+
<Grid container direction="column" className={classes.dropdownContent} >
557+
<Grid item className={classes.dropdownItem} onClick={() => handleManageGrouping(0)}>new group from selection</Grid>
558+
{/* TODO just a placeholder for poses here */}
559+
{[{ id: 1, label: '1x' }, { id: 2, label: '2x' }, { id: 3, label: '3x' }].map(pose =>
560+
<Grid item className={classes.dropdownItem} onClick={() => handleManageGrouping(pose.id)}>add selection to {pose.label}</Grid>
561+
)}
562+
</Grid>
563+
</Grid>
564+
</Grid>}
468565
</>
469566
)}
470567
{isLoadingInspirationListOfMolecules === true && (

0 commit comments

Comments
 (0)