@@ -14,7 +14,7 @@ import {
14
14
IconButton ,
15
15
ButtonGroup
16
16
} from '@material-ui/core' ;
17
- import React , { useState , useEffect , memo , useRef , useContext , useCallback } from 'react' ;
17
+ import React , { useState , useEffect , memo , useRef , useContext } from 'react' ;
18
18
import { useDispatch , useSelector } from 'react-redux' ;
19
19
import { DatasetMoleculeView , colourList } from './datasetMoleculeView' ;
20
20
import InfiniteScroll from 'react-infinite-scroller' ;
@@ -23,7 +23,7 @@ import { Panel } from '../common/Surfaces/Panel';
23
23
import { ComputeSize } from '../../utils/computeSize' ;
24
24
import { VIEWS } from '../../constants/constants' ;
25
25
import { NglContext } from '../nglView/nglProvider' ;
26
- import { useDisableUserInteraction } from '../helpers/useEnableUserInteracion' ;
26
+ // import { useDisableUserInteraction } from '../helpers/useEnableUserInteracion';
27
27
import classNames from 'classnames' ;
28
28
import {
29
29
addDatasetLigand ,
@@ -34,7 +34,9 @@ import {
34
34
removeDatasetComplex ,
35
35
addDatasetSurface ,
36
36
removeDatasetSurface ,
37
- autoHideDatasetDialogsOnScroll
37
+ autoHideDatasetDialogsOnScroll ,
38
+ moveMoleculeInspirationsSettings ,
39
+ removeAllSelectedDatasetMolecules
38
40
} from './redux/dispatchActions' ;
39
41
import { setFilterDialogOpen , setSearchStringOfCompoundSet } from './redux/actions' ;
40
42
import { DatasetFilter } from './datasetFilter' ;
@@ -44,6 +46,8 @@ import { debounce } from 'lodash';
44
46
import { InspirationDialog } from './inspirationDialog' ;
45
47
import { CrossReferenceDialog } from './crossReferenceDialog' ;
46
48
import { AlertModal } from '../common/Modal/AlertModal' ;
49
+ import { hideAllSelectedMolecules } from '../preview/molecule/redux/dispatchActions' ;
50
+ import { getMoleculeList } from '../preview/molecule/redux/selectors' ;
47
51
import { setSelectedAllByType , setDeselectedAllByType } from './redux/actions' ;
48
52
49
53
const useStyles = makeStyles ( theme => ( {
@@ -226,7 +230,10 @@ export const DatasetMoleculeList = memo(
226
230
const filterRef = useRef ( ) ;
227
231
let joinedMoleculeLists = moleculeLists [ datasetID ] || [ ] ;
228
232
229
- const disableUserInteraction = useDisableUserInteraction ( ) ;
233
+ const getJoinedMoleculeList = useSelector ( state => getMoleculeList ( state ) ) ;
234
+ const inspirationMoleculeDataList = useSelector ( state => state . datasetsReducers . allInspirationMoleculeDataList ) ;
235
+
236
+ // const disableUserInteraction = useDisableUserInteraction();
230
237
231
238
// TODO Reset Infinity scroll
232
239
@@ -258,6 +265,15 @@ export const DatasetMoleculeList = memo(
258
265
259
266
const selectedAll = useRef ( false ) ;
260
267
268
+ const objectsInView = useSelector ( state => state . nglReducers . objectsInView ) || { } ;
269
+
270
+ const proteinListMolecule = useSelector ( state => state . selectionReducers . proteinList ) ;
271
+ const complexListMolecule = useSelector ( state => state . selectionReducers . complexList ) ;
272
+ const fragmentDisplayListMolecule = useSelector ( state => state . selectionReducers . fragmentDisplayList ) ;
273
+ const surfaceListMolecule = useSelector ( state => state . selectionReducers . surfaceList ) ;
274
+ const densityListMolecule = useSelector ( state => state . selectionReducers . densityList ) ;
275
+ const vectorOnListMolecule = useSelector ( state => state . selectionReducers . vectorOnList ) ;
276
+
261
277
const ligandList = useSelector ( state => state . datasetsReducers . ligandLists [ datasetID ] ) ;
262
278
const proteinList = useSelector ( state => state . datasetsReducers . proteinLists [ datasetID ] ) ;
263
279
const complexList = useSelector ( state => state . datasetsReducers . complexLists [ datasetID ] ) ;
@@ -280,31 +296,30 @@ export const DatasetMoleculeList = memo(
280
296
surface : removeDatasetSurface
281
297
} ;
282
298
299
+ const removeOfAllSelectedTypesOfInspirations = ( ) => {
300
+ let molecules = [ ...getJoinedMoleculeList , ...inspirationMoleculeDataList ] ;
301
+ dispatch ( hideAllSelectedMolecules ( stage , [ ...molecules ] ) ) ;
302
+ } ;
303
+
283
304
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
- } ) ;
305
+ dispatch ( removeAllSelectedDatasetMolecules ( stage ) ) ;
306
+ } ;
307
+
308
+ const moveSelectedMoleculeInspirationsSettings = ( data , newItemData ) => ( dispatch , getState ) => {
309
+ dispatch (
310
+ moveMoleculeInspirationsSettings (
311
+ data ,
312
+ newItemData ,
313
+ stage ,
314
+ objectsInView ,
315
+ fragmentDisplayListMolecule ,
316
+ proteinListMolecule ,
317
+ complexListMolecule ,
318
+ surfaceListMolecule ,
319
+ densityListMolecule ,
320
+ vectorOnListMolecule
321
+ )
322
+ ) ;
308
323
} ;
309
324
310
325
// TODO "currentMolecules" do not need to correspondent to selections in {type}List
@@ -552,7 +567,7 @@ export const DatasetMoleculeList = memo(
552
567
[ classes . contColButtonSelected ] : isLigandOn
553
568
} ) }
554
569
onClick = { ( ) => onButtonToggle ( 'ligand' ) }
555
- disabled = { disableUserInteraction }
570
+ disabled = { false }
556
571
>
557
572
L
558
573
</ Button >
@@ -566,7 +581,7 @@ export const DatasetMoleculeList = memo(
566
581
[ classes . contColButtonSelected ] : isProteinOn
567
582
} ) }
568
583
onClick = { ( ) => onButtonToggle ( 'protein' ) }
569
- disabled = { disableUserInteraction }
584
+ disabled = { false }
570
585
>
571
586
P
572
587
</ Button >
@@ -581,7 +596,7 @@ export const DatasetMoleculeList = memo(
581
596
[ classes . contColButtonSelected ] : isComplexOn
582
597
} ) }
583
598
onClick = { ( ) => onButtonToggle ( 'complex' ) }
584
- disabled = { disableUserInteraction }
599
+ disabled = { false }
585
600
>
586
601
C
587
602
</ Button >
@@ -646,6 +661,13 @@ export const DatasetMoleculeList = memo(
646
661
previousItemData = { index > 0 && array [ index - 1 ] }
647
662
nextItemData = { index < array ?. length && array [ index + 1 ] }
648
663
removeOfAllSelectedTypes = { removeOfAllSelectedTypes }
664
+ removeOfAllSelectedTypesOfInspirations = { removeOfAllSelectedTypesOfInspirations }
665
+ moveSelectedMoleculeInspirationsSettings = { moveSelectedMoleculeInspirationsSettings }
666
+ L = { ligandList . includes ( data . id ) }
667
+ P = { proteinList . includes ( data . id ) }
668
+ C = { complexList . includes ( data . id ) }
669
+ S = { surfaceList . includes ( data . id ) }
670
+ V = { false }
649
671
/>
650
672
) ) }
651
673
</ InfiniteScroll >
0 commit comments