Skip to content

Commit cc48037

Browse files
#384 new behaviour of buttons to skip
1 parent efeff57 commit cc48037

10 files changed

+325
-55
lines changed

js/components/datasets/crossReferenceDialog.js

+71-5
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@ import {
88
handleAllLigandsOfCrossReferenceDialog,
99
resetCrossReferenceDialog,
1010
removeOrAddAllHitProteinsOfList,
11-
removeOrAddAllComplexesOfList
11+
removeOrAddAllComplexesOfList,
12+
removeDatasetLigand,
13+
removeDatasetHitProtein,
14+
removeDatasetComplex,
15+
removeDatasetSurface
1216
} from './redux/dispatchActions';
1317
import { Button } from '../common/Inputs/Button';
1418
import classNames from 'classnames';
1519
import { useDisableUserInteraction } from '../helpers/useEnableUserInteracion';
16-
import { DatasetMoleculeView } from './datasetMoleculeView';
20+
import { colourList, DatasetMoleculeView } from './datasetMoleculeView';
1721
import { NglContext } from '../nglView/nglProvider';
1822
import { VIEWS } from '../../constants/constants';
1923
import { Panel } from '../common/Surfaces/Panel';
@@ -136,6 +140,66 @@ export const CrossReferenceDialog = memo(
136140
const proteinList = useSelector(state => getListOfSelectedProteinOfAllDatasets(state));
137141
const complexList = useSelector(state => getListOfSelectedComplexOfAllDatasets(state));
138142

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+
139203
useEffect(() => {
140204
if (moleculeList && Array.isArray(moleculeList) && moleculeList.length > 0) {
141205
// moleculeList has following structure:
@@ -253,17 +317,19 @@ export const CrossReferenceDialog = memo(
253317
</Grid>
254318
<div className={classes.content}>
255319
{moleculeList.length > 0 &&
256-
moleculeList.map((data, index) => (
320+
moleculeList.map((data, index, array) => (
257321
<DatasetMoleculeView
258322
key={index}
323+
index={index}
259324
imageHeight={imgHeight}
260325
imageWidth={imgWidth}
261326
data={data.molecule}
262327
datasetID={data.datasetID}
263328
hideFButton
264329
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}
267333
/>
268334
))}
269335
{!(moleculeList.length > 0) && (

js/components/datasets/customDatasetList.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
clearDatasetSettings,
99
initializeDatasetFilter,
1010
loadCompoundScoresListOfDataSet,
11-
loadMoleculesOfDataSet
11+
loadMoleculesOfAllDataSets
1212
} from './redux/dispatchActions';
1313
import { DatasetMoleculeList } from './datasetMoleculeList';
1414

@@ -19,10 +19,7 @@ export const CustomDatasetList = memo(
1919
useEffect(() => {
2020
if (dataset && dataset.id && isActive) {
2121
dispatch(setMoleculeListIsLoading(true));
22-
Promise.all([
23-
dispatch(loadMoleculesOfDataSet(dataset.id)),
24-
dispatch(loadCompoundScoresListOfDataSet(dataset.id))
25-
])
22+
Promise.all([dispatch(loadMoleculesOfAllDataSets()), dispatch(loadCompoundScoresListOfDataSet(dataset.id))])
2623
.catch(error => {
2724
throw new Error(error);
2825
})

js/components/datasets/datasetMoleculeList.js

+30-1
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,9 @@ export const DatasetMoleculeList = memo(
261261
const ligandList = useSelector(state => state.datasetsReducers.ligandLists[datasetID]);
262262
const proteinList = useSelector(state => state.datasetsReducers.proteinLists[datasetID]);
263263
const complexList = useSelector(state => state.datasetsReducers.complexLists[datasetID]);
264-
const isLigandOn = (ligandList && ligandList.length > 0) || false;
264+
const surfaceList = useSelector(state => state.datasetsReducers.surfaceLists[datasetID]);
265265

266+
const isLigandOn = (ligandList && ligandList.length > 0) || false;
266267
const isProteinOn = (proteinList && proteinList.length > 0) || false;
267268
const isComplexOn = (complexList && complexList.length > 0) || false;
268269
const addType = {
@@ -279,6 +280,33 @@ export const DatasetMoleculeList = memo(
279280
surface: removeDatasetSurface
280281
};
281282

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+
282310
// TODO "currentMolecules" do not need to correspondent to selections in {type}List
283311
// TODO so this could lead to inconsistend behaviour while scrolling
284312
// TODO maybe change "currentMolecules.forEach" to "{type}List.forEach"
@@ -582,6 +610,7 @@ export const DatasetMoleculeList = memo(
582610
showCrossReferenceModal
583611
previousItemData={index > 0 && array[index - 1]}
584612
nextItemData={index < array?.length && array[index + 1]}
613+
removeOfAllSelectedTypes={removeOfAllSelectedTypes}
585614
/>
586615
))}
587616
</InfiniteScroll>

js/components/datasets/datasetMoleculeView.js

+18-14
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,9 @@ export const DatasetMoleculeView = memo(
228228
showDatasetName,
229229
index,
230230
previousItemData,
231-
nextItemData
231+
nextItemData,
232+
removeOfAllSelectedTypes
232233
}) => {
233-
// const [countOfVectors, setCountOfVectors] = useState('-');
234-
// const [cmpds, setCmpds] = useState('-');
235234
const selectedAll = useRef(false);
236235
const currentID = (data && data.id) || undefined;
237236
const classes = useStyles();
@@ -450,33 +449,38 @@ export const DatasetMoleculeView = memo(
450449
return cssClass;
451450
};
452451

453-
const moveSelectedMoleculeSettings = newItemData => {
452+
const moveSelectedMoleculeSettings = (newItemData, datasetIdOfMolecule) => {
454453
if (newItemData) {
455454
if (isLigandOn) {
456-
dispatch(addDatasetLigand(stage, newItemData, colourToggle, datasetID));
457-
removeSelectedLigand();
455+
dispatch(addDatasetLigand(stage, newItemData, colourToggle, datasetIdOfMolecule));
458456
}
459457
if (isProteinOn) {
460-
dispatch(addDatasetHitProtein(stage, newItemData, colourToggle, datasetID));
461-
removeSelectedProtein();
458+
dispatch(addDatasetHitProtein(stage, newItemData, colourToggle, datasetIdOfMolecule));
462459
}
463460
if (isComplexOn) {
464-
dispatch(addDatasetComplex(stage, newItemData, colourToggle, datasetID));
465-
removeSelectedComplex();
461+
dispatch(addDatasetComplex(stage, newItemData, colourToggle, datasetIdOfMolecule));
466462
}
467463
if (isSurfaceOn) {
468-
dispatch(addDatasetSurface(stage, newItemData, colourToggle, datasetID));
469-
removeSelectedSurface();
464+
dispatch(addDatasetSurface(stage, newItemData, colourToggle, datasetIdOfMolecule));
470465
}
471466
}
472467
};
473468

474469
const handleClickOnDownArrow = () => {
475-
moveSelectedMoleculeSettings(nextItemData);
470+
removeOfAllSelectedTypes();
471+
const nextItem = (nextItemData.hasOwnProperty('molecule') && nextItemData.molecule) || nextItemData;
472+
const nextDatasetID = (nextItemData.hasOwnProperty('datasetID') && nextItemData.datasetID) || datasetID;
473+
moveSelectedMoleculeSettings(nextItem, nextDatasetID);
476474
};
477475

478476
const handleClickOnUpArrow = () => {
479-
moveSelectedMoleculeSettings(previousItemData);
477+
removeOfAllSelectedTypes();
478+
const previousItem =
479+
(previousItemData.hasOwnProperty('molecule') && previousItemData.molecule) || previousItemData;
480+
const previousDatasetID =
481+
(previousItemData.hasOwnProperty('datasetID') && previousItemData.datasetID) || datasetID;
482+
483+
moveSelectedMoleculeSettings(previousItem, previousDatasetID);
480484
};
481485

482486
const moleculeTitle = data && data.name;

js/components/datasets/inspirationDialog.js

+35-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ import {
2020
removeComplex,
2121
removeLigand,
2222
removeHitProtein,
23-
removeSurface
23+
removeSurface,
24+
removeDensity,
25+
removeVector
2426
} from '../preview/molecule/redux/dispatchActions';
2527
import { loadInspirationMoleculesDataList } from './redux/dispatchActions';
2628
import MoleculeView from '../preview/molecule/moleculeView';
@@ -150,6 +152,9 @@ export const InspirationDialog = memo(
150152
const ligandList = useSelector(state => state.selectionReducers.fragmentDisplayList);
151153
const proteinList = useSelector(state => state.selectionReducers.proteinList);
152154
const complexList = useSelector(state => state.selectionReducers.complexList);
155+
const surfaceList = useSelector(state => state.selectionReducers.surfaceList);
156+
const densityList = useSelector(state => state.selectionReducers.densityList);
157+
const vectorOnList = useSelector(state => state.selectionReducers.vectorOnList);
153158

154159
const dispatch = useDispatch();
155160
const disableUserInteraction = useDisableUserInteraction();
@@ -213,6 +218,33 @@ export const InspirationDialog = memo(
213218
surface: removeSurface
214219
};
215220

221+
const removeOfAllSelectedTypes = () => {
222+
proteinList?.forEach(moleculeID => {
223+
const foundedMolecule = moleculeList?.find(mol => mol.id === moleculeID);
224+
dispatch(removeHitProtein(stage, foundedMolecule, colourList[foundedMolecule.id % colourList.length]));
225+
});
226+
complexList?.forEach(moleculeID => {
227+
const foundedMolecule = moleculeList?.find(mol => mol.id === moleculeID);
228+
dispatch(removeComplex(stage, foundedMolecule, colourList[foundedMolecule.id % colourList.length]));
229+
});
230+
ligandList?.forEach(moleculeID => {
231+
const foundedMolecule = moleculeList?.find(mol => mol.id === moleculeID);
232+
dispatch(removeLigand(stage, foundedMolecule, colourList[foundedMolecule.id % colourList.length]));
233+
});
234+
surfaceList?.forEach(moleculeID => {
235+
const foundedMolecule = moleculeList?.find(mol => mol.id === moleculeID);
236+
dispatch(removeSurface(stage, foundedMolecule, colourList[foundedMolecule.id % colourList.length]));
237+
});
238+
densityList?.forEach(moleculeID => {
239+
const foundedMolecule = moleculeList?.find(mol => mol.id === moleculeID);
240+
dispatch(removeDensity(stage, foundedMolecule, colourList[foundedMolecule.id % colourList.length]));
241+
});
242+
vectorOnList?.forEach(moleculeID => {
243+
const foundedMolecule = moleculeList?.find(mol => mol.id === moleculeID);
244+
dispatch(removeVector(stage, foundedMolecule, colourList[foundedMolecule.id % colourList.length]));
245+
});
246+
};
247+
216248
const removeSelectedType = type => {
217249
moleculeList.forEach(molecule => {
218250
dispatch(removeType[type](stage, molecule, colourList[molecule.id % colourList.length], datasetID));
@@ -357,12 +389,14 @@ export const InspirationDialog = memo(
357389
moleculeList.map((molecule, index, array) => (
358390
<MoleculeView
359391
key={index}
392+
index={index}
360393
imageHeight={imgHeight}
361394
imageWidth={imgWidth}
362395
data={molecule}
363396
searchMoleculeGroup
364397
previousItemData={index > 0 && array[index - 1]}
365398
nextItemData={index < array?.length && array[index + 1]}
399+
removeOfAllSelectedTypes={removeOfAllSelectedTypes}
366400
/>
367401
))}
368402
{!(moleculeList.length > 0) && (

0 commit comments

Comments
 (0)