Skip to content

Commit 58ddbdd

Browse files
author
Adriána Kohanová
committed
Merge remote-tracking branch 'remotes/origin/allfunctionality' into #432
2 parents 85959ac + 602eeb8 commit 58ddbdd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1182
-358
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ npm-debug.log
88
*.offsets
99
yarn-error.log
1010
/yarn.lock
11+
/debug.log

js/components/datasets/crossReferenceDialog.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
} from './redux/dispatchActions';
1717
import { Button } from '../common/Inputs/Button';
1818
import classNames from 'classnames';
19-
import { useDisableUserInteraction } from '../helpers/useEnableUserInteracion';
19+
// import { useDisableUserInteraction } from '../helpers/useEnableUserInteracion';
2020
import { colourList, DatasetMoleculeView } from './datasetMoleculeView';
2121
import { NglContext } from '../nglView/nglProvider';
2222
import { VIEWS } from '../../constants/constants';
@@ -132,7 +132,7 @@ export const CrossReferenceDialog = memo(
132132

133133
const { getNglView } = useContext(NglContext);
134134
const stage = getNglView(VIEWS.MAJOR_VIEW) && getNglView(VIEWS.MAJOR_VIEW).stage;
135-
const disableUserInteraction = useDisableUserInteraction();
135+
// const disableUserInteraction = useDisableUserInteraction();
136136

137137
const moleculeList = useSelector(state => getCrossReferenceCompoundListByCompoundName(state));
138138
const isLoadingCrossReferenceScores = useSelector(state => state.datasetsReducers.isLoadingCrossReferenceScores);
@@ -272,7 +272,7 @@ export const CrossReferenceDialog = memo(
272272
onClick={() =>
273273
dispatch(handleAllLigandsOfCrossReferenceDialog(isLigandOn, moleculeList, stage))
274274
}
275-
disabled={disableUserInteraction}
275+
disabled={false}
276276
>
277277
L
278278
</Button>
@@ -289,7 +289,7 @@ export const CrossReferenceDialog = memo(
289289
onClick={() =>
290290
dispatch(removeOrAddAllHitProteinsOfList(isProteinOn, moleculeList, stage))
291291
}
292-
disabled={disableUserInteraction}
292+
disabled={false}
293293
>
294294
P
295295
</Button>
@@ -305,7 +305,7 @@ export const CrossReferenceDialog = memo(
305305
[classes.contColButtonHalfSelected]: isComplexOn === null
306306
})}
307307
onClick={() => dispatch(removeOrAddAllComplexesOfList(isComplexOn, moleculeList, stage))}
308-
disabled={disableUserInteraction}
308+
disabled={false}
309309
>
310310
C
311311
</Button>
@@ -336,6 +336,11 @@ export const CrossReferenceDialog = memo(
336336
previousItemData={previousData}
337337
nextItemData={nextData}
338338
removeOfAllSelectedTypes={removeOfAllSelectedTypes}
339+
L={ligandList.includes(data.id)}
340+
P={proteinList.includes(data.id)}
341+
C={complexList.includes(data.id)}
342+
S={false}
343+
V={false}
339344
/>
340345
);
341346
})}

js/components/datasets/datasetMoleculeList.js

+53-31
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
IconButton,
1515
ButtonGroup
1616
} 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';
1818
import { useDispatch, useSelector } from 'react-redux';
1919
import { DatasetMoleculeView, colourList } from './datasetMoleculeView';
2020
import InfiniteScroll from 'react-infinite-scroller';
@@ -23,7 +23,7 @@ import { Panel } from '../common/Surfaces/Panel';
2323
import { ComputeSize } from '../../utils/computeSize';
2424
import { VIEWS } from '../../constants/constants';
2525
import { NglContext } from '../nglView/nglProvider';
26-
import { useDisableUserInteraction } from '../helpers/useEnableUserInteracion';
26+
// import { useDisableUserInteraction } from '../helpers/useEnableUserInteracion';
2727
import classNames from 'classnames';
2828
import {
2929
addDatasetLigand,
@@ -34,7 +34,9 @@ import {
3434
removeDatasetComplex,
3535
addDatasetSurface,
3636
removeDatasetSurface,
37-
autoHideDatasetDialogsOnScroll
37+
autoHideDatasetDialogsOnScroll,
38+
moveMoleculeInspirationsSettings,
39+
removeAllSelectedDatasetMolecules
3840
} from './redux/dispatchActions';
3941
import { setFilterDialogOpen, setSearchStringOfCompoundSet } from './redux/actions';
4042
import { DatasetFilter } from './datasetFilter';
@@ -44,6 +46,8 @@ import { debounce } from 'lodash';
4446
import { InspirationDialog } from './inspirationDialog';
4547
import { CrossReferenceDialog } from './crossReferenceDialog';
4648
import { AlertModal } from '../common/Modal/AlertModal';
49+
import { hideAllSelectedMolecules } from '../preview/molecule/redux/dispatchActions';
50+
import { getMoleculeList } from '../preview/molecule/redux/selectors';
4751
import { setSelectedAllByType, setDeselectedAllByType } from './redux/actions';
4852

4953
const useStyles = makeStyles(theme => ({
@@ -226,7 +230,10 @@ export const DatasetMoleculeList = memo(
226230
const filterRef = useRef();
227231
let joinedMoleculeLists = moleculeLists[datasetID] || [];
228232

229-
const disableUserInteraction = useDisableUserInteraction();
233+
const getJoinedMoleculeList = useSelector(state => getMoleculeList(state));
234+
const inspirationMoleculeDataList = useSelector(state => state.datasetsReducers.allInspirationMoleculeDataList);
235+
236+
// const disableUserInteraction = useDisableUserInteraction();
230237

231238
// TODO Reset Infinity scroll
232239

@@ -258,6 +265,15 @@ export const DatasetMoleculeList = memo(
258265

259266
const selectedAll = useRef(false);
260267

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+
261277
const ligandList = useSelector(state => state.datasetsReducers.ligandLists[datasetID]);
262278
const proteinList = useSelector(state => state.datasetsReducers.proteinLists[datasetID]);
263279
const complexList = useSelector(state => state.datasetsReducers.complexLists[datasetID]);
@@ -280,31 +296,30 @@ export const DatasetMoleculeList = memo(
280296
surface: removeDatasetSurface
281297
};
282298

299+
const removeOfAllSelectedTypesOfInspirations = () => {
300+
let molecules = [...getJoinedMoleculeList, ...inspirationMoleculeDataList];
301+
dispatch(hideAllSelectedMolecules(stage, [...molecules]));
302+
};
303+
283304
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+
);
308323
};
309324

310325
// TODO "currentMolecules" do not need to correspondent to selections in {type}List
@@ -552,7 +567,7 @@ export const DatasetMoleculeList = memo(
552567
[classes.contColButtonSelected]: isLigandOn
553568
})}
554569
onClick={() => onButtonToggle('ligand')}
555-
disabled={disableUserInteraction}
570+
disabled={false}
556571
>
557572
L
558573
</Button>
@@ -566,7 +581,7 @@ export const DatasetMoleculeList = memo(
566581
[classes.contColButtonSelected]: isProteinOn
567582
})}
568583
onClick={() => onButtonToggle('protein')}
569-
disabled={disableUserInteraction}
584+
disabled={false}
570585
>
571586
P
572587
</Button>
@@ -581,7 +596,7 @@ export const DatasetMoleculeList = memo(
581596
[classes.contColButtonSelected]: isComplexOn
582597
})}
583598
onClick={() => onButtonToggle('complex')}
584-
disabled={disableUserInteraction}
599+
disabled={false}
585600
>
586601
C
587602
</Button>
@@ -646,6 +661,13 @@ export const DatasetMoleculeList = memo(
646661
previousItemData={index > 0 && array[index - 1]}
647662
nextItemData={index < array?.length && array[index + 1]}
648663
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}
649671
/>
650672
))}
651673
</InfiniteScroll>

0 commit comments

Comments
 (0)