Skip to content

Commit 66126f0

Browse files
author
Adriána Kohanová
committed
#549 (reopening #460) Leave LHS things displayed if site is turned off
1 parent 8529735 commit 66126f0

File tree

5 files changed

+9
-123
lines changed

5 files changed

+9
-123
lines changed

js/components/nglView/redux/dispatchActions.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ export const toggleMoleculeGroup = (molGroupId, summaryViewStage) => (dispatch,
5757
).catch(error => {
5858
throw new Error(error);
5959
});
60-
dispatch(
61-
clearAfterDeselectingMoleculeGroup()
62-
);
60+
dispatch(clearAfterDeselectingMoleculeGroup({ molGroupId }));
6361
}
6462
};
6563

js/components/preview/moleculeGroups/redux/dispatchActions.js

+4-99
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,16 @@
1-
import {
2-
complexObjectTypes,
3-
generateComplex,
4-
generateMolecule,
5-
generateSphere
6-
} from '../../molecule/molecules_helpers';
1+
import { generateSphere } from '../../molecule/molecules_helpers';
72
import { VIEWS } from '../../../../constants/constants';
83
import {
94
decrementCountOfRemainingMoleculeGroupsWithSavingDefaultState,
105
deleteObject,
116
loadObject
127
} from '../../../../reducers/ngl/dispatchActions';
138
import {
14-
removeFromComplexList,
15-
removeFromProteinList,
16-
removeFromSurfaceList,
17-
removeFromFragmentDisplayList,
18-
removeFromVectorOnList,
199
resetSelectionState,
2010
setComplexList,
2111
setFilter,
2212
setFragmentDisplayList,
2313
setMolGroupSelection,
24-
setObjectSelection,
2514
setVectorList,
2615
setVectorOnList
2716
} from '../../../../reducers/selection/actions';
@@ -33,90 +22,12 @@ import { setSortDialogOpen } from '../../molecule/redux/actions';
3322
import { resetCurrentCompoundsSettings } from '../../compounds/redux/actions';
3423
import { reloadSession } from '../../../snapshot/redux/dispatchActions';
3524
import { resetRestoringState } from '../../../../reducers/tracking/dispatchActions';
36-
import { selectJoinedMoleculeList } from '../../molecule/redux/selectors';
3725
import { URLS } from '../../../routes/constants';
3826

39-
export const clearAfterDeselectingMoleculeGroup = ({ molGroupId, currentMolGroup, majorViewStage }) => (
40-
dispatch,
41-
getState
42-
) => {
43-
dispatch(setObjectSelection([molGroupId]));
44-
45-
let site;
46-
const state = getState();
47-
const { fragmentDisplayList, complexList, proteinList, surfaceList, vectorOnList, vector_list } = state.selectionReducers;
48-
49-
const actionFragmentDisplayList = [];
50-
const actionComplexList = [];
51-
const actionProteinList = [];
52-
const actionSurfaceList = [];
53-
const actionVectorOnList = [];
54-
55-
// loop through all molecules
56-
selectJoinedMoleculeList(state).forEach(mol => {
57-
site = mol.site;
58-
59-
// remove Ligand
60-
dispatch(
61-
deleteObject(
62-
Object.assign({ display_div: VIEWS.MAJOR_VIEW }, generateMolecule(mol.protein_code, mol.sdf_info)),
63-
majorViewStage
64-
)
65-
);
66-
67-
// remove Complex, Protein, Surface
68-
Object.keys(complexObjectTypes).forEach(type => {
69-
dispatch(
70-
deleteObject(
71-
Object.assign(
72-
{ display_div: VIEWS.MAJOR_VIEW },
73-
generateComplex(mol.protein_code, mol.sdf_info, mol.molecule_protein, type)
74-
),
75-
majorViewStage
76-
)
77-
);
78-
});
79-
80-
if (fragmentDisplayList.find(ligand => ligand === mol.id)) actionFragmentDisplayList.push(mol);
81-
if (complexList.find(ligand => ligand === mol.id)) actionComplexList.push(mol);
82-
if (proteinList.find(ligand => ligand === mol.id)) actionProteinList.push(mol);
83-
if (surfaceList.find(ligand => ligand === mol.id)) actionSurfaceList.push(mol);
84-
if (vectorOnList.find(ligand => ligand === mol.id)) actionVectorOnList.push(mol);
85-
});
86-
dispatch(setMolGroupOff(molGroupId, {
87-
ligand: actionFragmentDisplayList,
88-
protein: actionProteinList,
89-
complex: actionComplexList,
90-
surface: actionSurfaceList,
91-
vector: actionVectorOnList
92-
}));
93-
94-
// remove all Vectors
95-
vector_list
96-
.filter(v => v.site === site)
97-
.forEach(item => {
98-
dispatch(deleteObject(Object.assign({ display_div: VIEWS.MAJOR_VIEW }, item), majorViewStage));
99-
});
100-
101-
dispatch(setObjectSelection(undefined));
102-
27+
export const clearAfterDeselectingMoleculeGroup = ({ molGroupId }) => dispatch => {
10328
// remove all molecule orientations
10429
dispatch(setMoleculeOrientations({}));
105-
106-
// remove all selected ALCV of given site
107-
currentMolGroup.mol_id.forEach(moleculeID => {
108-
// remove Ligand, Complex, Vectors from selection
109-
//Ligand
110-
dispatch(removeFromFragmentDisplayList({ id: moleculeID }, true));
111-
// Complex
112-
dispatch(removeFromComplexList({ id: moleculeID }, true));
113-
// Protein
114-
dispatch(removeFromProteinList({ id: moleculeID }, true));
115-
// Surface
116-
dispatch(removeFromSurfaceList({ id: moleculeID }, true));
117-
// Vectors
118-
dispatch(removeFromVectorOnList({ id: moleculeID }, true));
119-
});
30+
dispatch(setMolGroupOff(molGroupId));
12031
};
12132

12233
export const saveMoleculeGroupsToNglView = (molGroupList, stage, projectId) => dispatch => {
@@ -288,13 +199,7 @@ export const onDeselectMoleculeGroup = ({ moleculeGroup, stageSummaryView, major
288199
const mol_group_selection = state.selectionReducers.mol_group_selection;
289200
const selectionCopy = mol_group_selection.slice();
290201
const objIdx = mol_group_selection.indexOf(moleculeGroup.id);
291-
dispatch(
292-
clearAfterDeselectingMoleculeGroup({
293-
molGroupId: moleculeGroup.id,
294-
currentMolGroup,
295-
majorViewStage
296-
})
297-
);
202+
dispatch(clearAfterDeselectingMoleculeGroup({ molGroupId: moleculeGroup.id }));
298203
selectionCopy.splice(objIdx, 1);
299204
dispatch(
300205
deleteObject(

js/reducers/api/actions.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,10 @@ export const setMolGroupOn = function(mol_group_id) {
5959
};
6060
};
6161

62-
export const setMolGroupOff = function(mol_group_id, selectionGroups) {
62+
export const setMolGroupOff = function(mol_group_id) {
6363
return {
6464
type: constants.SET_MOL_GROUP_OFF,
65-
mol_group_off: mol_group_id,
66-
selectionGroups
65+
mol_group_off: mol_group_id
6766
};
6867
};
6968

js/reducers/tracking/dispatchActions.js

+1-16
Original file line numberDiff line numberDiff line change
@@ -2299,26 +2299,11 @@ const handleArrowNavigationActionOfCompound = (action, isSelected, majorViewStag
22992299
const handleMoleculeGroupAction = (action, isSelected, stageSummaryView, majorViewStage) => (dispatch, getState) => {
23002300
const state = getState();
23012301
if (action) {
2302-
const { selectionGroups, object_name } = action;
2302+
const { object_name } = action;
23032303
let moleculeGroup = getMolGroup(object_name, state);
23042304
if (moleculeGroup) {
23052305
if (isSelected === true) {
23062306
dispatch(selectMoleculeGroup(moleculeGroup, stageSummaryView));
2307-
2308-
for (const type in selectionGroups) {
2309-
if (selectionGroups.hasOwnProperty(type)) {
2310-
const typeGroup = selectionGroups[type];
2311-
for (const mol of typeGroup) {
2312-
if (type === 'ligand') {
2313-
dispatch(addType[type](majorViewStage, mol, colourList[mol.id % colourList.length], true, true));
2314-
} else if (type === 'vector') {
2315-
dispatch(addType[type](majorViewStage, mol, true));
2316-
} else {
2317-
dispatch(addType[type](majorViewStage, mol, colourList[mol.id % colourList.length], true));
2318-
}
2319-
}
2320-
}
2321-
}
23222307
} else {
23232308
dispatch(onDeselectMoleculeGroup({ moleculeGroup, stageSummaryView, majorViewStage }));
23242309
}

js/reducers/tracking/trackingActions.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const findTrackAction = (action, state) => {
4747
}
4848
}
4949
} else if (action.type === apiConstants.SET_MOL_GROUP_OFF) {
50-
const { mol_group_off, selectionGroups } = action;
50+
const { mol_group_off } = action;
5151
let molGroupName = getMolGroupName(mol_group_off, state);
5252
trackAction = {
5353
type: actionType.SITE_TURNED_OFF,
@@ -56,7 +56,6 @@ export const findTrackAction = (action, state) => {
5656
object_type: actionObjectType.SITE,
5757
object_name: molGroupName,
5858
object_id: mol_group_off,
59-
selectionGroups,
6059
text: `${actionDescription.SITE} ${molGroupName} ${actionDescription.TURNED_OFF}`
6160
};
6261
} else if (action.type === selectionConstants.SET_OBJECT_SELECTION) {

0 commit comments

Comments
 (0)