Skip to content

Commit

Permalink
Adjusted tracking behaviour for turned off sites
Browse files Browse the repository at this point in the history
  • Loading branch information
ag-m2ms committed Dec 10, 2020
1 parent 653e165 commit 99591ac
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 32 deletions.
33 changes: 26 additions & 7 deletions js/components/preview/moleculeGroups/redux/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
setVectorOnList
} from '../../../../reducers/selection/actions';
import { setCountOfRemainingMoleculeGroups, setMoleculeOrientations } from '../../../../reducers/ngl/actions';
import { setMolGroupList, setMolGroupOn } from '../../../../reducers/api/actions';
import { setMolGroupList, setMolGroupOn, setMolGroupOff } from '../../../../reducers/api/actions';
import { getUrl, loadFromServer } from '../../../../utils/genericList';
import { OBJECT_TYPE } from '../../../nglView/constants';
import { setSortDialogOpen } from '../../molecule/redux/actions';
Expand All @@ -43,7 +43,13 @@ export const clearAfterDeselectingMoleculeGroup = ({ molGroupId, currentMolGroup

let site;
const state = getState();
const vector_list = state.selectionReducers.vector_list;
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 => {
Expand All @@ -69,7 +75,20 @@ export const clearAfterDeselectingMoleculeGroup = ({ molGroupId, currentMolGroup
)
);
});

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
Expand All @@ -87,15 +106,15 @@ export const clearAfterDeselectingMoleculeGroup = ({ molGroupId, currentMolGroup
currentMolGroup.mol_id.forEach(moleculeID => {
// remove Ligand, Complex, Vectors from selection
//Ligand
dispatch(removeFromFragmentDisplayList({ id: moleculeID }));
dispatch(removeFromFragmentDisplayList({ id: moleculeID }, true));
// Complex
dispatch(removeFromComplexList({ id: moleculeID }));
dispatch(removeFromComplexList({ id: moleculeID }, true));
// Protein
dispatch(removeFromProteinList({ id: moleculeID }));
dispatch(removeFromProteinList({ id: moleculeID }, true));
// Surface
dispatch(removeFromSurfaceList({ id: moleculeID }));
dispatch(removeFromSurfaceList({ id: moleculeID }, true));
// Vectors
dispatch(removeFromVectorOnList({ id: moleculeID }));
dispatch(removeFromVectorOnList({ id: moleculeID }, true));
});
};

Expand Down
8 changes: 8 additions & 0 deletions js/reducers/api/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ export const setMolGroupOn = function(mol_group_id) {
};
};

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

export const setMolGroupList = function(mol_group_list) {
return {
type: constants.SET_MOL_GROUP_LIST,
Expand Down
1 change: 1 addition & 0 deletions js/reducers/api/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const constants = {
SET_PANNDA_EVENT_ON: prefix + 'SET_PANNDA_EVENT_ON',

SET_MOL_GROUP_ON: prefix + 'SET_MOL_GROUP_ON',
SET_MOL_GROUP_OFF: prefix + 'SET_MOL_GROUP_OFF',
SET_MOL_GROUP_LIST: prefix + 'SET_MOL_GROUP_LIST',
SET_MOLECULE_LIST: prefix + 'SET_MOLECULE_LIST',
SET_CACHED_MOL_LISTS: prefix + 'SET_CACHED_MOL_LISTS',
Expand Down
25 changes: 15 additions & 10 deletions js/reducers/selection/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ export const setCurrentVector = vectorSmile => {
};
};

export const setFragmentDisplayList = function(fragmentDisplayList) {
export const setFragmentDisplayList = function(fragmentDisplayList, skipTracking = false) {
return {
type: constants.SET_FRAGMENT_DISPLAY_LIST,
fragmentDisplayList: fragmentDisplayList
fragmentDisplayList: fragmentDisplayList,
skipTracking
};
};

Expand All @@ -62,10 +63,11 @@ export const removeFromFragmentDisplayList = function(item, skipTracking = false
};
};

export const setProteinList = function(proteinList) {
export const setProteinList = function(proteinList, skipTracking = false) {
return {
type: constants.SET_PROTEIN_LIST,
proteinList: proteinList
proteinList: proteinList,
skipTracking
};
};

Expand All @@ -84,10 +86,11 @@ export const removeFromProteinList = function(item, skipTracking = false) {
skipTracking: skipTracking
};
};
export const setComplexList = function(complexList) {
export const setComplexList = function(complexList, skipTracking = false) {
return {
type: constants.SET_COMPLEX_LIST,
complexList: complexList
complexList: complexList,
skipTracking
};
};

Expand All @@ -107,10 +110,11 @@ export const removeFromComplexList = function(item, skipTracking = false) {
};
};

export const setSurfaceList = function(surfaceList) {
export const setSurfaceList = function(surfaceList, skipTracking = false) {
return {
type: constants.SET_SURFACE_LIST,
surfaceList: surfaceList
surfaceList: surfaceList,
skipTracking
};
};

Expand Down Expand Up @@ -151,10 +155,11 @@ export const removeFromDensityList = function(item) {
};
};

export const setVectorOnList = function(vectorOnList) {
export const setVectorOnList = function(vectorOnList, skipTracking = false) {
return {
type: constants.SET_VECTOR_ON_LIST,
vectorOnList: vectorOnList
vectorOnList: vectorOnList,
skipTracking
};
};

Expand Down
16 changes: 15 additions & 1 deletion js/reducers/tracking/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1513,10 +1513,24 @@ const removeRepresentation = (parentKey, representation, nglView) => (dispatch,
const handleMoleculeGroupAction = (action, isSelected, stageSummaryView, majorViewStage) => (dispatch, getState) => {
const state = getState();
if (action) {
let moleculeGroup = getMolGroup(action.object_name, state);
const { selectionGroups, 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 {
dispatch(addType[type](majorViewStage, mol, colourList[mol.id % colourList.length], true));
}
}
}
}
} else {
dispatch(onDeselectMoleculeGroup({ moleculeGroup, stageSummaryView, majorViewStage }));
}
Expand Down
27 changes: 13 additions & 14 deletions js/reducers/tracking/trackingActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,19 @@ export const findTrackAction = (action, state) => {
};
}
}
} else if (action.type.includes(selectionConstants.SET_OBJECT_SELECTION)) {
let objectId = action.payload && action.payload[0];
if (objectId) {
let molGroupName = getMolGroupName(objectId, state);
trackAction = {
type: actionType.SITE_TURNED_OFF,
timestamp: Date.now(),
username: username,
object_type: actionObjectType.SITE,
object_name: molGroupName,
object_id: objectId,
text: `${actionDescription.SITE} ${molGroupName} ${actionDescription.TURNED_OFF}`
};
}
} else if (action.type.includes(apiConstants.SET_MOL_GROUP_OFF)) {
const { mol_group_off, selectionGroups } = action;
let molGroupName = getMolGroupName(mol_group_off, state);
trackAction = {
type: actionType.SITE_TURNED_OFF,
timestamp: Date.now(),
username: username,
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_HIDE_ALL) {
if (action.data) {
let objectType = actionObjectType.MOLECULE;
Expand Down

0 comments on commit 99591ac

Please sign in to comment.