@@ -44,6 +44,7 @@ import { getFilteredDatasetMoleculeList } from './redux/selectors';
44
44
import { debounce } from 'lodash' ;
45
45
import { InspirationDialog } from './inspirationDialog' ;
46
46
import { CrossReferenceDialog } from './crossReferenceDialog' ;
47
+ import { AlertModal } from '../common/Modal/AlertModal' ;
47
48
48
49
const useStyles = makeStyles ( theme => ( {
49
50
container : {
@@ -182,6 +183,11 @@ const useStyles = makeStyles(theme => ({
182
183
} ,
183
184
loading : {
184
185
paddingTop : theme . spacing ( 2 )
186
+ } ,
187
+ total : {
188
+ ...theme . typography . button ,
189
+ color : theme . palette . primary . main ,
190
+ fontStyle : 'italic'
185
191
}
186
192
} ) ) ;
187
193
@@ -255,8 +261,9 @@ export const DatasetMoleculeList = memo(
255
261
const ligandList = useSelector ( state => state . datasetsReducers . ligandLists [ datasetID ] ) ;
256
262
const proteinList = useSelector ( state => state . datasetsReducers . proteinLists [ datasetID ] ) ;
257
263
const complexList = useSelector ( state => state . datasetsReducers . complexLists [ datasetID ] ) ;
258
- const isLigandOn = ( ligandList && ligandList . length > 0 ) || false ;
264
+ const surfaceList = useSelector ( state => state . datasetsReducers . surfaceLists [ datasetID ] ) ;
259
265
266
+ const isLigandOn = ( ligandList && ligandList . length > 0 ) || false ;
260
267
const isProteinOn = ( proteinList && proteinList . length > 0 ) || false ;
261
268
const isComplexOn = ( complexList && complexList . length > 0 ) || false ;
262
269
const addType = {
@@ -273,6 +280,33 @@ export const DatasetMoleculeList = memo(
273
280
surface : removeDatasetSurface
274
281
} ;
275
282
283
+ const removeOfAllSelectedTypes = ( ) => {
284
+ ligandList ?. forEach ( moleculeID => {
285
+ const foundedMolecule = joinedMoleculeLists ?. find ( mol => mol . id === moleculeID ) ;
286
+ dispatch (
287
+ removeDatasetLigand ( stage , foundedMolecule , colourList [ foundedMolecule . id % colourList . length ] , datasetID )
288
+ ) ;
289
+ } ) ;
290
+ proteinList ?. forEach ( moleculeID => {
291
+ const foundedMolecule = joinedMoleculeLists ?. find ( mol => mol . id === moleculeID ) ;
292
+ dispatch (
293
+ removeDatasetHitProtein ( stage , foundedMolecule , colourList [ foundedMolecule . id % colourList . length ] , datasetID )
294
+ ) ;
295
+ } ) ;
296
+ complexList ?. forEach ( moleculeID => {
297
+ const foundedMolecule = joinedMoleculeLists ?. find ( mol => mol . id === moleculeID ) ;
298
+ dispatch (
299
+ removeDatasetComplex ( stage , foundedMolecule , colourList [ foundedMolecule . id % colourList . length ] , datasetID )
300
+ ) ;
301
+ } ) ;
302
+ surfaceList ?. forEach ( moleculeID => {
303
+ const foundedMolecule = joinedMoleculeLists ?. find ( mol => mol . id === moleculeID ) ;
304
+ dispatch (
305
+ removeDatasetSurface ( stage , foundedMolecule , colourList [ foundedMolecule . id % colourList . length ] , datasetID )
306
+ ) ;
307
+ } ) ;
308
+ } ;
309
+
276
310
// TODO "currentMolecules" do not need to correspondent to selections in {type}List
277
311
// TODO so this could lead to inconsistend behaviour while scrolling
278
312
// TODO maybe change "currentMolecules.forEach" to "{type}List.forEach"
@@ -365,6 +399,8 @@ export const DatasetMoleculeList = memo(
365
399
const inspirationDialogRef = useRef ( ) ;
366
400
const scrollBarRef = useRef ( ) ;
367
401
402
+ const [ isOpenAlert , setIsOpenAlert ] = useState ( false ) ;
403
+
368
404
return (
369
405
< ComputeSize
370
406
componentRef = { filterRef . current }
@@ -373,6 +409,18 @@ export const DatasetMoleculeList = memo(
373
409
forceCompute = { isActiveFilter }
374
410
>
375
411
< Panel hasHeader title = { title } withTooltip headerActions = { actions } >
412
+ < AlertModal
413
+ title = "Are you sure?"
414
+ description = { `Loading of ${ joinedMoleculeLists ?. length } may take a long time` }
415
+ open = { isOpenAlert }
416
+ handleOnOk = { ( ) => {
417
+ setNextXMolecules ( joinedMoleculeLists ?. length || 0 ) ;
418
+ setIsOpenAlert ( false ) ;
419
+ } }
420
+ handleOnCancel = { ( ) => {
421
+ setIsOpenAlert ( false ) ;
422
+ } }
423
+ />
376
424
{ sortDialogOpen && (
377
425
< DatasetFilter
378
426
open = { sortDialogOpen }
@@ -550,7 +598,7 @@ export const DatasetMoleculeList = memo(
550
598
useWindow = { false }
551
599
>
552
600
{ datasetID &&
553
- currentMolecules . map ( ( data , index ) => (
601
+ currentMolecules . map ( ( data , index , array ) => (
554
602
< DatasetMoleculeView
555
603
key = { index }
556
604
index = { index }
@@ -560,12 +608,18 @@ export const DatasetMoleculeList = memo(
560
608
datasetID = { datasetID }
561
609
setRef = { setSelectedMoleculeRef }
562
610
showCrossReferenceModal
611
+ previousItemData = { index > 0 && array [ index - 1 ] }
612
+ nextItemData = { index < array ?. length && array [ index + 1 ] }
613
+ removeOfAllSelectedTypes = { removeOfAllSelectedTypes }
563
614
/>
564
615
) ) }
565
616
</ InfiniteScroll >
566
617
</ Grid >
567
618
< Grid item >
568
- < Grid container justify = "flex-end" direction = "row" >
619
+ < Grid container justify = "space-between" alignItems = "center" direction = "row" >
620
+ < Grid item >
621
+ < span className = { classes . total } > { `Total ${ joinedMoleculeLists ?. length } ` } </ span >
622
+ </ Grid >
569
623
< Grid item >
570
624
< ButtonGroup
571
625
variant = "text"
@@ -589,7 +643,11 @@ export const DatasetMoleculeList = memo(
589
643
</ Button >
590
644
< Button
591
645
onClick = { ( ) => {
592
- setNextXMolecules ( joinedMoleculeLists ?. length || 0 ) ;
646
+ if ( joinedMoleculeLists ?. length > 300 ) {
647
+ setIsOpenAlert ( true ) ;
648
+ } else {
649
+ setNextXMolecules ( joinedMoleculeLists ?. length || 0 ) ;
650
+ }
593
651
} }
594
652
>
595
653
Load full list
0 commit comments