Skip to content

Commit 99591ac

Browse files
committed
Adjusted tracking behaviour for turned off sites
1 parent 653e165 commit 99591ac

File tree

6 files changed

+78
-32
lines changed

6 files changed

+78
-32
lines changed

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

+26-7
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
setVectorOnList
2828
} from '../../../../reducers/selection/actions';
2929
import { setCountOfRemainingMoleculeGroups, setMoleculeOrientations } from '../../../../reducers/ngl/actions';
30-
import { setMolGroupList, setMolGroupOn } from '../../../../reducers/api/actions';
30+
import { setMolGroupList, setMolGroupOn, setMolGroupOff } from '../../../../reducers/api/actions';
3131
import { getUrl, loadFromServer } from '../../../../utils/genericList';
3232
import { OBJECT_TYPE } from '../../../nglView/constants';
3333
import { setSortDialogOpen } from '../../molecule/redux/actions';
@@ -43,7 +43,13 @@ export const clearAfterDeselectingMoleculeGroup = ({ molGroupId, currentMolGroup
4343

4444
let site;
4545
const state = getState();
46-
const vector_list = state.selectionReducers.vector_list;
46+
const { fragmentDisplayList, complexList, proteinList, surfaceList, vectorOnList, vector_list } = state.selectionReducers;
47+
48+
const actionFragmentDisplayList = [];
49+
const actionComplexList = [];
50+
const actionProteinList = [];
51+
const actionSurfaceList = [];
52+
const actionVectorOnList = [];
4753

4854
// loop through all molecules
4955
selectJoinedMoleculeList(state).forEach(mol => {
@@ -69,7 +75,20 @@ export const clearAfterDeselectingMoleculeGroup = ({ molGroupId, currentMolGroup
6975
)
7076
);
7177
});
78+
79+
if (fragmentDisplayList.find(ligand => ligand === mol.id)) actionFragmentDisplayList.push(mol);
80+
if (complexList.find(ligand => ligand === mol.id)) actionComplexList.push(mol);
81+
if (proteinList.find(ligand => ligand === mol.id)) actionProteinList.push(mol);
82+
if (surfaceList.find(ligand => ligand === mol.id)) actionSurfaceList.push(mol);
83+
if (vectorOnList.find(ligand => ligand === mol.id)) actionVectorOnList.push(mol);
7284
});
85+
dispatch(setMolGroupOff(molGroupId, {
86+
ligand: actionFragmentDisplayList,
87+
protein: actionProteinList,
88+
complex: actionComplexList,
89+
surface: actionSurfaceList,
90+
vector: actionVectorOnList
91+
}));
7392

7493
// remove all Vectors
7594
vector_list
@@ -87,15 +106,15 @@ export const clearAfterDeselectingMoleculeGroup = ({ molGroupId, currentMolGroup
87106
currentMolGroup.mol_id.forEach(moleculeID => {
88107
// remove Ligand, Complex, Vectors from selection
89108
//Ligand
90-
dispatch(removeFromFragmentDisplayList({ id: moleculeID }));
109+
dispatch(removeFromFragmentDisplayList({ id: moleculeID }, true));
91110
// Complex
92-
dispatch(removeFromComplexList({ id: moleculeID }));
111+
dispatch(removeFromComplexList({ id: moleculeID }, true));
93112
// Protein
94-
dispatch(removeFromProteinList({ id: moleculeID }));
113+
dispatch(removeFromProteinList({ id: moleculeID }, true));
95114
// Surface
96-
dispatch(removeFromSurfaceList({ id: moleculeID }));
115+
dispatch(removeFromSurfaceList({ id: moleculeID }, true));
97116
// Vectors
98-
dispatch(removeFromVectorOnList({ id: moleculeID }));
117+
dispatch(removeFromVectorOnList({ id: moleculeID }, true));
99118
});
100119
};
101120

js/reducers/api/actions.js

+8
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ export const setMolGroupOn = function(mol_group_id) {
5959
};
6060
};
6161

62+
export const setMolGroupOff = function(mol_group_id, selectionGroups) {
63+
return {
64+
type: constants.SET_MOL_GROUP_OFF,
65+
mol_group_off: mol_group_id,
66+
selectionGroups
67+
};
68+
};
69+
6270
export const setMolGroupList = function(mol_group_list) {
6371
return {
6472
type: constants.SET_MOL_GROUP_LIST,

js/reducers/api/constants.js

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const constants = {
1111
SET_PANNDA_EVENT_ON: prefix + 'SET_PANNDA_EVENT_ON',
1212

1313
SET_MOL_GROUP_ON: prefix + 'SET_MOL_GROUP_ON',
14+
SET_MOL_GROUP_OFF: prefix + 'SET_MOL_GROUP_OFF',
1415
SET_MOL_GROUP_LIST: prefix + 'SET_MOL_GROUP_LIST',
1516
SET_MOLECULE_LIST: prefix + 'SET_MOLECULE_LIST',
1617
SET_CACHED_MOL_LISTS: prefix + 'SET_CACHED_MOL_LISTS',

js/reducers/selection/actions.js

+15-10
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ export const setCurrentVector = vectorSmile => {
3939
};
4040
};
4141

42-
export const setFragmentDisplayList = function(fragmentDisplayList) {
42+
export const setFragmentDisplayList = function(fragmentDisplayList, skipTracking = false) {
4343
return {
4444
type: constants.SET_FRAGMENT_DISPLAY_LIST,
45-
fragmentDisplayList: fragmentDisplayList
45+
fragmentDisplayList: fragmentDisplayList,
46+
skipTracking
4647
};
4748
};
4849

@@ -62,10 +63,11 @@ export const removeFromFragmentDisplayList = function(item, skipTracking = false
6263
};
6364
};
6465

65-
export const setProteinList = function(proteinList) {
66+
export const setProteinList = function(proteinList, skipTracking = false) {
6667
return {
6768
type: constants.SET_PROTEIN_LIST,
68-
proteinList: proteinList
69+
proteinList: proteinList,
70+
skipTracking
6971
};
7072
};
7173

@@ -84,10 +86,11 @@ export const removeFromProteinList = function(item, skipTracking = false) {
8486
skipTracking: skipTracking
8587
};
8688
};
87-
export const setComplexList = function(complexList) {
89+
export const setComplexList = function(complexList, skipTracking = false) {
8890
return {
8991
type: constants.SET_COMPLEX_LIST,
90-
complexList: complexList
92+
complexList: complexList,
93+
skipTracking
9194
};
9295
};
9396

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

110-
export const setSurfaceList = function(surfaceList) {
113+
export const setSurfaceList = function(surfaceList, skipTracking = false) {
111114
return {
112115
type: constants.SET_SURFACE_LIST,
113-
surfaceList: surfaceList
116+
surfaceList: surfaceList,
117+
skipTracking
114118
};
115119
};
116120

@@ -151,10 +155,11 @@ export const removeFromDensityList = function(item) {
151155
};
152156
};
153157

154-
export const setVectorOnList = function(vectorOnList) {
158+
export const setVectorOnList = function(vectorOnList, skipTracking = false) {
155159
return {
156160
type: constants.SET_VECTOR_ON_LIST,
157-
vectorOnList: vectorOnList
161+
vectorOnList: vectorOnList,
162+
skipTracking
158163
};
159164
};
160165

js/reducers/tracking/dispatchActions.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -1513,10 +1513,24 @@ const removeRepresentation = (parentKey, representation, nglView) => (dispatch,
15131513
const handleMoleculeGroupAction = (action, isSelected, stageSummaryView, majorViewStage) => (dispatch, getState) => {
15141514
const state = getState();
15151515
if (action) {
1516-
let moleculeGroup = getMolGroup(action.object_name, state);
1516+
const { selectionGroups, object_name } = action;
1517+
let moleculeGroup = getMolGroup(object_name, state);
15171518
if (moleculeGroup) {
15181519
if (isSelected === true) {
15191520
dispatch(selectMoleculeGroup(moleculeGroup, stageSummaryView));
1521+
1522+
for (const type in selectionGroups) {
1523+
if (selectionGroups.hasOwnProperty(type)) {
1524+
const typeGroup = selectionGroups[type];
1525+
for (const mol of typeGroup) {
1526+
if (type === 'ligand') {
1527+
dispatch(addType[type](majorViewStage, mol, colourList[mol.id % colourList.length], true, true));
1528+
} else {
1529+
dispatch(addType[type](majorViewStage, mol, colourList[mol.id % colourList.length], true));
1530+
}
1531+
}
1532+
}
1533+
}
15201534
} else {
15211535
dispatch(onDeselectMoleculeGroup({ moleculeGroup, stageSummaryView, majorViewStage }));
15221536
}

js/reducers/tracking/trackingActions.js

+13-14
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,19 @@ export const findTrackAction = (action, state) => {
4242
};
4343
}
4444
}
45-
} else if (action.type.includes(selectionConstants.SET_OBJECT_SELECTION)) {
46-
let objectId = action.payload && action.payload[0];
47-
if (objectId) {
48-
let molGroupName = getMolGroupName(objectId, state);
49-
trackAction = {
50-
type: actionType.SITE_TURNED_OFF,
51-
timestamp: Date.now(),
52-
username: username,
53-
object_type: actionObjectType.SITE,
54-
object_name: molGroupName,
55-
object_id: objectId,
56-
text: `${actionDescription.SITE} ${molGroupName} ${actionDescription.TURNED_OFF}`
57-
};
58-
}
45+
} else if (action.type.includes(apiConstants.SET_MOL_GROUP_OFF)) {
46+
const { mol_group_off, selectionGroups } = action;
47+
let molGroupName = getMolGroupName(mol_group_off, state);
48+
trackAction = {
49+
type: actionType.SITE_TURNED_OFF,
50+
timestamp: Date.now(),
51+
username: username,
52+
object_type: actionObjectType.SITE,
53+
object_name: molGroupName,
54+
object_id: mol_group_off,
55+
selectionGroups,
56+
text: `${actionDescription.SITE} ${molGroupName} ${actionDescription.TURNED_OFF}`
57+
};
5958
} else if (action.type === selectionConstants.SET_HIDE_ALL) {
6059
if (action.data) {
6160
let objectType = actionObjectType.MOLECULE;

0 commit comments

Comments
 (0)