@@ -32,11 +32,13 @@ import SearchField from '../../common/Components/SearchField';
32
32
import GroupNglControlButtonsContext from './groupNglControlButtonsContext' ;
33
33
import MoleculeView from './moleculeView' ;
34
34
import { TagEditor } from '../tags/modal/tagEditor' ;
35
+ import { ToastContext } from '../../toast' ;
36
+ import { DJANGO_CONTEXT } from '../../../utils/djangoContext' ;
35
37
36
38
const useStyles = makeStyles ( theme => ( {
37
39
paper : {
38
40
width : 472 ,
39
- height : 294 ,
41
+ // minHeight : 294,
40
42
overflowY : 'hidden'
41
43
} ,
42
44
molHeader : {
@@ -112,6 +114,39 @@ const useStyles = makeStyles(theme => ({
112
114
backgroundColor : theme . palette . primary . semidark
113
115
//color: theme.palette.black
114
116
}
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
+ }
115
150
}
116
151
} ) ) ;
117
152
@@ -127,6 +162,7 @@ export const ObservationsDialog = memo(
127
162
const selectedAll = useRef ( false ) ;
128
163
129
164
const { getNglView } = useContext ( NglContext ) ;
165
+ const { toastInfo } = useContext ( ToastContext ) ;
130
166
const stage = getNglView ( VIEWS . MAJOR_VIEW ) && getNglView ( VIEWS . MAJOR_VIEW ) . stage ;
131
167
132
168
const isLoadingInspirationListOfMolecules = useSelector (
@@ -304,6 +340,20 @@ export const ObservationsDialog = memo(
304
340
buttonState => buttonState
305
341
) ;
306
342
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
+
307
357
// TODO refactor to this line
308
358
309
359
return (
@@ -465,6 +515,53 @@ export const ObservationsDialog = memo(
465
515
</ Grid >
466
516
) }
467
517
</ 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 > }
468
565
</ >
469
566
) }
470
567
{ isLoadingInspirationListOfMolecules === true && (
0 commit comments