Skip to content

Commit

Permalink
#549 (reopening #460) Leave LHS things displayed if site is turned off
Browse files Browse the repository at this point in the history
  • Loading branch information
Adriána Kohanová committed Feb 10, 2021
1 parent 8529735 commit 66126f0
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 123 deletions.
4 changes: 1 addition & 3 deletions js/components/nglView/redux/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ export const toggleMoleculeGroup = (molGroupId, summaryViewStage) => (dispatch,
).catch(error => {
throw new Error(error);
});
dispatch(
clearAfterDeselectingMoleculeGroup()
);
dispatch(clearAfterDeselectingMoleculeGroup({ molGroupId }));
}
};

Expand Down
103 changes: 4 additions & 99 deletions js/components/preview/moleculeGroups/redux/dispatchActions.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
import {
complexObjectTypes,
generateComplex,
generateMolecule,
generateSphere
} from '../../molecule/molecules_helpers';
import { generateSphere } from '../../molecule/molecules_helpers';
import { VIEWS } from '../../../../constants/constants';
import {
decrementCountOfRemainingMoleculeGroupsWithSavingDefaultState,
deleteObject,
loadObject
} from '../../../../reducers/ngl/dispatchActions';
import {
removeFromComplexList,
removeFromProteinList,
removeFromSurfaceList,
removeFromFragmentDisplayList,
removeFromVectorOnList,
resetSelectionState,
setComplexList,
setFilter,
setFragmentDisplayList,
setMolGroupSelection,
setObjectSelection,
setVectorList,
setVectorOnList
} from '../../../../reducers/selection/actions';
Expand All @@ -33,90 +22,12 @@ import { setSortDialogOpen } from '../../molecule/redux/actions';
import { resetCurrentCompoundsSettings } from '../../compounds/redux/actions';
import { reloadSession } from '../../../snapshot/redux/dispatchActions';
import { resetRestoringState } from '../../../../reducers/tracking/dispatchActions';
import { selectJoinedMoleculeList } from '../../molecule/redux/selectors';
import { URLS } from '../../../routes/constants';

export const clearAfterDeselectingMoleculeGroup = ({ molGroupId, currentMolGroup, majorViewStage }) => (
dispatch,
getState
) => {
dispatch(setObjectSelection([molGroupId]));

let site;
const state = getState();
const { fragmentDisplayList, complexList, proteinList, surfaceList, vectorOnList, vector_list } = state.selectionReducers;

const actionFragmentDisplayList = [];
const actionComplexList = [];
const actionProteinList = [];
const actionSurfaceList = [];
const actionVectorOnList = [];

// loop through all molecules
selectJoinedMoleculeList(state).forEach(mol => {
site = mol.site;

// remove Ligand
dispatch(
deleteObject(
Object.assign({ display_div: VIEWS.MAJOR_VIEW }, generateMolecule(mol.protein_code, mol.sdf_info)),
majorViewStage
)
);

// remove Complex, Protein, Surface
Object.keys(complexObjectTypes).forEach(type => {
dispatch(
deleteObject(
Object.assign(
{ display_div: VIEWS.MAJOR_VIEW },
generateComplex(mol.protein_code, mol.sdf_info, mol.molecule_protein, type)
),
majorViewStage
)
);
});

if (fragmentDisplayList.find(ligand => ligand === mol.id)) actionFragmentDisplayList.push(mol);
if (complexList.find(ligand => ligand === mol.id)) actionComplexList.push(mol);
if (proteinList.find(ligand => ligand === mol.id)) actionProteinList.push(mol);
if (surfaceList.find(ligand => ligand === mol.id)) actionSurfaceList.push(mol);
if (vectorOnList.find(ligand => ligand === mol.id)) actionVectorOnList.push(mol);
});
dispatch(setMolGroupOff(molGroupId, {
ligand: actionFragmentDisplayList,
protein: actionProteinList,
complex: actionComplexList,
surface: actionSurfaceList,
vector: actionVectorOnList
}));

// remove all Vectors
vector_list
.filter(v => v.site === site)
.forEach(item => {
dispatch(deleteObject(Object.assign({ display_div: VIEWS.MAJOR_VIEW }, item), majorViewStage));
});

dispatch(setObjectSelection(undefined));

export const clearAfterDeselectingMoleculeGroup = ({ molGroupId }) => dispatch => {
// remove all molecule orientations
dispatch(setMoleculeOrientations({}));

// remove all selected ALCV of given site
currentMolGroup.mol_id.forEach(moleculeID => {
// remove Ligand, Complex, Vectors from selection
//Ligand
dispatch(removeFromFragmentDisplayList({ id: moleculeID }, true));
// Complex
dispatch(removeFromComplexList({ id: moleculeID }, true));
// Protein
dispatch(removeFromProteinList({ id: moleculeID }, true));
// Surface
dispatch(removeFromSurfaceList({ id: moleculeID }, true));
// Vectors
dispatch(removeFromVectorOnList({ id: moleculeID }, true));
});
dispatch(setMolGroupOff(molGroupId));
};

export const saveMoleculeGroupsToNglView = (molGroupList, stage, projectId) => dispatch => {
Expand Down Expand Up @@ -288,13 +199,7 @@ export const onDeselectMoleculeGroup = ({ moleculeGroup, stageSummaryView, major
const mol_group_selection = state.selectionReducers.mol_group_selection;
const selectionCopy = mol_group_selection.slice();
const objIdx = mol_group_selection.indexOf(moleculeGroup.id);
dispatch(
clearAfterDeselectingMoleculeGroup({
molGroupId: moleculeGroup.id,
currentMolGroup,
majorViewStage
})
);
dispatch(clearAfterDeselectingMoleculeGroup({ molGroupId: moleculeGroup.id }));
selectionCopy.splice(objIdx, 1);
dispatch(
deleteObject(
Expand Down
5 changes: 2 additions & 3 deletions js/reducers/api/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,10 @@ export const setMolGroupOn = function(mol_group_id) {
};
};

export const setMolGroupOff = function(mol_group_id, selectionGroups) {
export const setMolGroupOff = function(mol_group_id) {
return {
type: constants.SET_MOL_GROUP_OFF,
mol_group_off: mol_group_id,
selectionGroups
mol_group_off: mol_group_id
};
};

Expand Down
17 changes: 1 addition & 16 deletions js/reducers/tracking/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2299,26 +2299,11 @@ const handleArrowNavigationActionOfCompound = (action, isSelected, majorViewStag
const handleMoleculeGroupAction = (action, isSelected, stageSummaryView, majorViewStage) => (dispatch, getState) => {
const state = getState();
if (action) {
const { selectionGroups, object_name } = action;
const { object_name } = action;
let moleculeGroup = getMolGroup(object_name, state);
if (moleculeGroup) {
if (isSelected === true) {
dispatch(selectMoleculeGroup(moleculeGroup, stageSummaryView));

for (const type in selectionGroups) {
if (selectionGroups.hasOwnProperty(type)) {
const typeGroup = selectionGroups[type];
for (const mol of typeGroup) {
if (type === 'ligand') {
dispatch(addType[type](majorViewStage, mol, colourList[mol.id % colourList.length], true, true));
} else if (type === 'vector') {
dispatch(addType[type](majorViewStage, mol, true));
} else {
dispatch(addType[type](majorViewStage, mol, colourList[mol.id % colourList.length], true));
}
}
}
}
} else {
dispatch(onDeselectMoleculeGroup({ moleculeGroup, stageSummaryView, majorViewStage }));
}
Expand Down
3 changes: 1 addition & 2 deletions js/reducers/tracking/trackingActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const findTrackAction = (action, state) => {
}
}
} else if (action.type === apiConstants.SET_MOL_GROUP_OFF) {
const { mol_group_off, selectionGroups } = action;
const { mol_group_off } = action;
let molGroupName = getMolGroupName(mol_group_off, state);
trackAction = {
type: actionType.SITE_TURNED_OFF,
Expand All @@ -56,7 +56,6 @@ export const findTrackAction = (action, state) => {
object_type: actionObjectType.SITE,
object_name: molGroupName,
object_id: mol_group_off,
selectionGroups,
text: `${actionDescription.SITE} ${molGroupName} ${actionDescription.TURNED_OFF}`
};
} else if (action.type === selectionConstants.SET_OBJECT_SELECTION) {
Expand Down

0 comments on commit 66126f0

Please sign in to comment.