From 66126f03f34ebedbd36a6b1468ab9645b0b452b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1na=20Kohanov=C3=A1?= Date: Wed, 10 Feb 2021 07:53:50 +0100 Subject: [PATCH] #549 (reopening #460) Leave LHS things displayed if site is turned off --- .../nglView/redux/dispatchActions.js | 4 +- .../moleculeGroups/redux/dispatchActions.js | 103 +----------------- js/reducers/api/actions.js | 5 +- js/reducers/tracking/dispatchActions.js | 17 +-- js/reducers/tracking/trackingActions.js | 3 +- 5 files changed, 9 insertions(+), 123 deletions(-) diff --git a/js/components/nglView/redux/dispatchActions.js b/js/components/nglView/redux/dispatchActions.js index 4d8b2d0f6..d7f9704a0 100644 --- a/js/components/nglView/redux/dispatchActions.js +++ b/js/components/nglView/redux/dispatchActions.js @@ -57,9 +57,7 @@ export const toggleMoleculeGroup = (molGroupId, summaryViewStage) => (dispatch, ).catch(error => { throw new Error(error); }); - dispatch( - clearAfterDeselectingMoleculeGroup() - ); + dispatch(clearAfterDeselectingMoleculeGroup({ molGroupId })); } }; diff --git a/js/components/preview/moleculeGroups/redux/dispatchActions.js b/js/components/preview/moleculeGroups/redux/dispatchActions.js index 03faf8ee5..1c86eb9c8 100644 --- a/js/components/preview/moleculeGroups/redux/dispatchActions.js +++ b/js/components/preview/moleculeGroups/redux/dispatchActions.js @@ -1,9 +1,4 @@ -import { - complexObjectTypes, - generateComplex, - generateMolecule, - generateSphere -} from '../../molecule/molecules_helpers'; +import { generateSphere } from '../../molecule/molecules_helpers'; import { VIEWS } from '../../../../constants/constants'; import { decrementCountOfRemainingMoleculeGroupsWithSavingDefaultState, @@ -11,17 +6,11 @@ import { loadObject } from '../../../../reducers/ngl/dispatchActions'; import { - removeFromComplexList, - removeFromProteinList, - removeFromSurfaceList, - removeFromFragmentDisplayList, - removeFromVectorOnList, resetSelectionState, setComplexList, setFilter, setFragmentDisplayList, setMolGroupSelection, - setObjectSelection, setVectorList, setVectorOnList } from '../../../../reducers/selection/actions'; @@ -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 => { @@ -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( diff --git a/js/reducers/api/actions.js b/js/reducers/api/actions.js index e90283943..e68f3d5f8 100644 --- a/js/reducers/api/actions.js +++ b/js/reducers/api/actions.js @@ -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 }; }; diff --git a/js/reducers/tracking/dispatchActions.js b/js/reducers/tracking/dispatchActions.js index 8d221a6e0..57c19f223 100644 --- a/js/reducers/tracking/dispatchActions.js +++ b/js/reducers/tracking/dispatchActions.js @@ -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 })); } diff --git a/js/reducers/tracking/trackingActions.js b/js/reducers/tracking/trackingActions.js index 9cae43efc..59bd91bdc 100644 --- a/js/reducers/tracking/trackingActions.js +++ b/js/reducers/tracking/trackingActions.js @@ -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, @@ -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) {