@@ -8,12 +8,16 @@ import {
8
8
handleAllLigandsOfCrossReferenceDialog ,
9
9
resetCrossReferenceDialog ,
10
10
removeOrAddAllHitProteinsOfList ,
11
- removeOrAddAllComplexesOfList
11
+ removeOrAddAllComplexesOfList ,
12
+ removeDatasetLigand ,
13
+ removeDatasetHitProtein ,
14
+ removeDatasetComplex ,
15
+ removeDatasetSurface
12
16
} from './redux/dispatchActions' ;
13
17
import { Button } from '../common/Inputs/Button' ;
14
18
import classNames from 'classnames' ;
15
19
import { useDisableUserInteraction } from '../helpers/useEnableUserInteracion' ;
16
- import { DatasetMoleculeView } from './datasetMoleculeView' ;
20
+ import { colourList , DatasetMoleculeView } from './datasetMoleculeView' ;
17
21
import { NglContext } from '../nglView/nglProvider' ;
18
22
import { VIEWS } from '../../constants/constants' ;
19
23
import { Panel } from '../common/Surfaces/Panel' ;
@@ -136,6 +140,66 @@ export const CrossReferenceDialog = memo(
136
140
const proteinList = useSelector ( state => getListOfSelectedProteinOfAllDatasets ( state ) ) ;
137
141
const complexList = useSelector ( state => getListOfSelectedComplexOfAllDatasets ( state ) ) ;
138
142
143
+ const ligandListAllDatasets = useSelector ( state => state . datasetsReducers . ligandLists ) ;
144
+ const proteinListAllDatasets = useSelector ( state => state . datasetsReducers . proteinLists ) ;
145
+ const complexListAllDatasets = useSelector ( state => state . datasetsReducers . complexLists ) ;
146
+ const surfaceListAllDatasets = useSelector ( state => state . datasetsReducers . surfaceLists ) ;
147
+
148
+ const removeOfAllSelectedTypes = ( ) => {
149
+ Object . keys ( ligandListAllDatasets ) . forEach ( datasetKey => {
150
+ ligandListAllDatasets [ datasetKey ] ?. forEach ( moleculeID => {
151
+ const foundedMolecule = moleculeList ?. find ( mol => mol ?. molecule ?. id === moleculeID ) ;
152
+ dispatch (
153
+ removeDatasetLigand (
154
+ stage ,
155
+ foundedMolecule ?. molecule ,
156
+ colourList [ foundedMolecule ?. molecule ?. id % colourList . length ] ,
157
+ datasetKey
158
+ )
159
+ ) ;
160
+ } ) ;
161
+ } ) ;
162
+ Object . keys ( proteinListAllDatasets ) . forEach ( datasetKey => {
163
+ proteinListAllDatasets [ datasetKey ] ?. forEach ( moleculeID => {
164
+ const foundedMolecule = moleculeList ?. find ( mol => mol ?. molecule ?. id === moleculeID ) ;
165
+ dispatch (
166
+ removeDatasetHitProtein (
167
+ stage ,
168
+ foundedMolecule ?. molecule ,
169
+ colourList [ foundedMolecule ?. molecule ?. id % colourList . length ] ,
170
+ datasetKey
171
+ )
172
+ ) ;
173
+ } ) ;
174
+ } ) ;
175
+ Object . keys ( complexListAllDatasets ) . forEach ( datasetKey => {
176
+ complexListAllDatasets [ datasetKey ] ?. forEach ( moleculeID => {
177
+ const foundedMolecule = moleculeList ?. find ( mol => mol ?. molecule ?. id === moleculeID ) ;
178
+ dispatch (
179
+ removeDatasetComplex (
180
+ stage ,
181
+ foundedMolecule ?. molecule ,
182
+ colourList [ foundedMolecule ?. molecule ?. id % colourList . length ] ,
183
+ datasetKey
184
+ )
185
+ ) ;
186
+ } ) ;
187
+ } ) ;
188
+ Object . keys ( surfaceListAllDatasets ) . forEach ( datasetKey => {
189
+ surfaceListAllDatasets [ datasetKey ] ?. forEach ( moleculeID => {
190
+ const foundedMolecule = moleculeList ?. find ( mol => mol ?. molecule ?. id === moleculeID ) ;
191
+ dispatch (
192
+ removeDatasetSurface (
193
+ stage ,
194
+ foundedMolecule ?. molecule ,
195
+ colourList [ foundedMolecule ?. molecule ?. id % colourList . length ] ,
196
+ datasetKey
197
+ )
198
+ ) ;
199
+ } ) ;
200
+ } ) ;
201
+ } ;
202
+
139
203
useEffect ( ( ) => {
140
204
if ( moleculeList && Array . isArray ( moleculeList ) && moleculeList . length > 0 ) {
141
205
// moleculeList has following structure:
@@ -253,17 +317,19 @@ export const CrossReferenceDialog = memo(
253
317
</ Grid >
254
318
< div className = { classes . content } >
255
319
{ moleculeList . length > 0 &&
256
- moleculeList . map ( ( data , index ) => (
320
+ moleculeList . map ( ( data , index , array ) => (
257
321
< DatasetMoleculeView
258
322
key = { index }
323
+ index = { index }
259
324
imageHeight = { imgHeight }
260
325
imageWidth = { imgWidth }
261
326
data = { data . molecule }
262
327
datasetID = { data . datasetID }
263
328
hideFButton
264
329
showDatasetName
265
- previousItemData = { index > 0 && array [ index - 1 ] ?. molecule }
266
- nextItemData = { index < array ?. length && array [ index + 1 ] ?. molecule }
330
+ previousItemData = { index > 0 && array [ index - 1 ] }
331
+ nextItemData = { index < array ?. length && array [ index + 1 ] }
332
+ removeOfAllSelectedTypes = { removeOfAllSelectedTypes }
267
333
/>
268
334
) ) }
269
335
{ ! ( moleculeList . length > 0 ) && (
0 commit comments