Skip to content

Commit 9d6f428

Browse files
Merge remote-tracking branch 'remotes/origin/#453' into allfunctionality
2 parents e84f58d + 75bf86d commit 9d6f428

File tree

8 files changed

+150
-20
lines changed

8 files changed

+150
-20
lines changed

js/components/preview/molecule/redux/dispatchActions.js

+34-12
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import {
1919
updateVectorCompounds,
2020
updateBondColorMapOfCompounds,
2121
resetBondColorMapOfVectors,
22-
setCurrentVector
22+
setCurrentVector,
23+
setHideAll
2324
} from '../../../../reducers/selection/actions';
2425
import { base_url } from '../../../routes/constants';
2526
import {
@@ -115,11 +116,11 @@ const handleVector = (json, stage, data) => (dispatch, getState) => {
115116
dispatch(updateBondColorMapOfCompounds(data.smiles, vectorBondColorMap));
116117
};
117118

118-
export const addVector = (stage, data) => async (dispatch, getState) => {
119+
export const addVector = (stage, data, skipTracking = false) => async (dispatch, getState) => {
119120
const currentVector = getState().selectionReducers.currentVector;
120121

121122
dispatch(incrementCountOfPendingVectorLoadRequests());
122-
dispatch(appendVectorOnList(generateMoleculeId(data)));
123+
dispatch(appendVectorOnList(generateMoleculeId(data), skipTracking));
123124
dispatch(selectVectorAndResetCompounds(currentVector));
124125

125126
return api({ url: getViewUrl('graph', data) })
@@ -226,7 +227,7 @@ export const removeComplex = (stage, data, colourToggle, skipTracking = false) =
226227
dispatch(removeFromComplexList(generateMoleculeId(data), skipTracking));
227228
};
228229

229-
export const addSurface = (stage, data, colourToggle) => dispatch => {
230+
export const addSurface = (stage, data, colourToggle, skipTracking = false) => dispatch => {
230231
dispatch(
231232
loadObject({
232233
target: Object.assign({ display_div: VIEWS.MAJOR_VIEW }, generateSurfaceObject(data, colourToggle, base_url)),
@@ -237,17 +238,17 @@ export const addSurface = (stage, data, colourToggle) => dispatch => {
237238
const currentOrientation = stage.viewerControls.getOrientation();
238239
dispatch(setOrientation(VIEWS.MAJOR_VIEW, currentOrientation));
239240
});
240-
dispatch(appendSurfaceList(generateMoleculeId(data)));
241+
dispatch(appendSurfaceList(generateMoleculeId(data), skipTracking));
241242
};
242243

243-
export const removeSurface = (stage, data, colourToggle) => dispatch => {
244+
export const removeSurface = (stage, data, colourToggle, skipTracking = false) => dispatch => {
244245
dispatch(
245246
deleteObject(
246247
Object.assign({ display_div: VIEWS.MAJOR_VIEW }, generateSurfaceObject(data, colourToggle, base_url)),
247248
stage
248249
)
249250
);
250-
dispatch(removeFromSurfaceList(generateMoleculeId(data)));
251+
dispatch(removeFromSurfaceList(generateMoleculeId(data), skipTracking));
251252
};
252253

253254
export const addDensity = (stage, data, colourToggle) => dispatch => {
@@ -330,39 +331,51 @@ export const hideAllSelectedMolecules = (stage, currentMolecules) => (dispatch,
330331
const vectorOnList = state.selectionReducers.vectorOnList;
331332
const surfaceList = state.selectionReducers.surfaceList;
332333
const proteinList = state.selectionReducers.proteinList;
334+
const vectorList = state.selectionReducers.vector_list;
335+
336+
let ligandDataList = [];
337+
let complexDataList = [];
338+
let vectorOnDataList = [];
339+
let surfaceDataList = [];
340+
let proteinDataList = [];
333341

334342
fragmentDisplayList.forEach(moleculeId => {
335343
const data = currentMolecules.find(molecule => molecule.id === moleculeId);
336344
if (data) {
337-
dispatch(removeLigand(stage, data));
345+
ligandDataList.push(data);
346+
dispatch(removeLigand(stage, data, true));
338347
}
339348
});
340349
complexList.forEach(moleculeId => {
341350
const data = currentMolecules.find(molecule => molecule.id === moleculeId);
342351
if (data) {
343-
dispatch(removeComplex(stage, data, colourList[0]));
352+
complexDataList.push(data);
353+
dispatch(removeComplex(stage, data, colourList[0], true));
344354
}
345355
});
346356
vectorOnList.forEach(moleculeId => {
347357
const data = currentMolecules.find(molecule => molecule.id === moleculeId);
348358
if (data) {
349-
dispatch(removeVector(stage, data));
359+
vectorOnDataList.push(data);
360+
dispatch(removeVector(stage, data, true));
350361
}
351362
});
352363

353364
// remove Surface
354365
surfaceList.forEach(moleculeId => {
355366
const data = currentMolecules.find(molecule => molecule.id === moleculeId);
356367
if (data) {
357-
dispatch(removeSurface(stage, data));
368+
surfaceDataList.push(data);
369+
dispatch(removeSurface(stage, data, colourList[0], true));
358370
}
359371
});
360372

361373
// remove Protein
362374
proteinList.forEach(moleculeId => {
363375
const data = currentMolecules.find(molecule => molecule.id === moleculeId);
364376
if (data) {
365-
dispatch(removeHitProtein(stage, data));
377+
proteinDataList.push(data);
378+
dispatch(removeHitProtein(stage, data, colourList[0], true));
366379
}
367380
});
368381

@@ -371,6 +384,15 @@ export const hideAllSelectedMolecules = (stage, currentMolecules) => (dispatch,
371384
dispatch(resetCompoundsOfVectors());
372385
dispatch(resetBondColorMapOfVectors());
373386
dispatch(setCompoundImage(noCompoundImage));
387+
388+
let data = {
389+
ligandList: ligandDataList,
390+
proteinList: proteinDataList,
391+
complexList: complexDataList,
392+
surfaceList: surfaceDataList,
393+
vectorOnList: vectorOnDataList
394+
};
395+
dispatch(setHideAll(data));
374396
};
375397

376398
export const searchMoleculeGroupByMoleculeID = moleculeID => (dispatch, getState) =>

js/reducers/selection/actions.js

+15-6
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,19 @@ export const setSurfaceList = function(surfaceList) {
114114
};
115115
};
116116

117-
export const appendSurfaceList = function(item) {
117+
export const appendSurfaceList = function(item, skipTracking = false) {
118118
return {
119119
type: constants.APPEND_SURFACE_LIST,
120-
item: item
120+
item: item,
121+
skipTracking: skipTracking
121122
};
122123
};
123124

124-
export const removeFromSurfaceList = function(item) {
125+
export const removeFromSurfaceList = function(item, skipTracking = false) {
125126
return {
126127
type: constants.REMOVE_FROM_SURFACE_LIST,
127-
item: item
128+
item: item,
129+
skipTracking: skipTracking
128130
};
129131
};
130132

@@ -156,10 +158,11 @@ export const setVectorOnList = function(vectorOnList) {
156158
};
157159
};
158160

159-
export const appendVectorOnList = function(item) {
161+
export const appendVectorOnList = function(item, skipTracking = false) {
160162
return {
161163
type: constants.APPEND_VECTOR_ON_LIST,
162-
item: item
164+
item: item,
165+
skipTracking: skipTracking
163166
};
164167
};
165168

@@ -253,3 +256,9 @@ export const setDeselectedAllByType = (type, items, isInspiration) => ({
253256
type: constants.SET_DESELECTED_ALL_BY_TYPE,
254257
payload: { type, items, isInspiration }
255258
});
259+
260+
export const setHideAll = (data, isHide = true) => ({
261+
type: constants.SET_HIDE_ALL,
262+
isHide: isHide,
263+
data: data
264+
});

js/reducers/selection/constants.js

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export const constants = {
3636
SET_DESELECTED_ALL: prefix + 'SET_DESELECTED_ALL',
3737
SET_SELECTED_ALL_BY_TYPE: prefix + 'SET_SELECTED_ALL_BY_TYPE',
3838
SET_DESELECTED_ALL_BY_TYPE: prefix + 'SET_DESELECTED_ALL_BY_TYPE',
39+
SET_HIDE_ALL: prefix + 'SET_HIDE_ALL',
3940

4041
RESET_COMPOUNDS_OF_VECTORS: prefix + 'RESET_COMPOUNDS_OF_VECTORS',
4142
UPDATE_VECTOR_COMPOUNDS: prefix + 'UPDATE_VECTOR_COMPOUNDS',

js/reducers/selection/selectionReducers.js

+4
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,10 @@ export function selectionReducers(state = INITIAL_STATE, action = {}) {
299299
return Object.assign({}, state, {
300300
moleculeAllTypeSelection: action.payload.type
301301
});
302+
303+
case constants.SET_HIDE_ALL:
304+
return state;
305+
302306
// Cases like: @@redux/INIT
303307
default:
304308
return state;

js/reducers/tracking/constants.js

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export const actionType = {
4242
REPRESENTATION_REMOVED: 'REPRESENTATION_REMOVED',
4343
UNDO: 'UNDO',
4444
REDO: 'REDO',
45+
ALL_HIDE: 'ALL_HIDE',
4546
ALL_TURNED_ON: 'ALL_TURNED_ON',
4647
ALL_TURNED_OFF: 'ALL_TURNED_OFF',
4748
ALL_TURNED_ON_BY_TYPE: 'ALL_TURNED_ON_BY_TYPE',
@@ -54,6 +55,8 @@ export const actionDescription = {
5455
TURNED_OFF: 'was turned off',
5556
SELECTED: 'was selected',
5657
DESELECTED: 'was deselected',
58+
HIDDEN: 'hidden',
59+
CANCELED: 'canceled',
5760
ADDED: 'was added',
5861
REMOVED: 'was removed',
5962
CHANGED: 'was changed',

js/reducers/tracking/dispatchActions.js

+78-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from './actions';
77
import { actionType, actionObjectType } from './constants';
88
import { VIEWS } from '../../../js/constants/constants';
9-
import { setCurrentVector, appendToBuyList, removeFromToBuyList } from '../selection/actions';
9+
import { setCurrentVector, appendToBuyList, removeFromToBuyList, setHideAll } from '../selection/actions';
1010
import { unmountPreviewComponent, shouldLoadProtein } from '../../components/preview/redux/dispatchActions';
1111
import { setCurrentProject } from '../../components/projects/redux/actions';
1212
import {
@@ -772,6 +772,9 @@ const handleUndoAction = (action, stages) => (dispatch, getState) => {
772772

773773
const type = action.type;
774774
switch (type) {
775+
case actionType.ALL_HIDE:
776+
dispatch(handleAllHideAction(action, true, majorViewStage));
777+
break;
775778
case actionType.ALL_TURNED_ON:
776779
dispatch(handleAllAction(action, false, majorViewStage, state));
777780
break;
@@ -867,6 +870,9 @@ const handleRedoAction = (action, stages) => (dispatch, getState) => {
867870

868871
const type = action.type;
869872
switch (type) {
873+
case actionType.ALL_HIDE:
874+
dispatch(handleAllHideAction(action, false, majorViewStage));
875+
break;
870876
case actionType.ALL_TURNED_ON:
871877
dispatch(handleAllAction(action, true, majorViewStage, state));
872878
break;
@@ -1028,6 +1034,77 @@ const handleAllActionByType = (action, isAdd, stage) => (dispatch, getState) =>
10281034
}
10291035
};
10301036

1037+
const handleAllHideAction = (action, isAdd, stage) => (dispatch, getState) => {
1038+
let data = action.data;
1039+
let ligandDataList = data.ligandList;
1040+
let proteinDataList = data.proteinList;
1041+
let complexDataList = data.complexList;
1042+
let surfaceDataList = data.surfaceList;
1043+
let vectorOnDataList = data.vectorOnList;
1044+
1045+
dispatch(setHideAll(data, !isAdd));
1046+
1047+
if (isAdd) {
1048+
ligandDataList.forEach(data => {
1049+
if (data) {
1050+
dispatch(addType['ligand'](stage, data, colourList[data.id % colourList.length], true, true));
1051+
}
1052+
});
1053+
1054+
proteinDataList.forEach(data => {
1055+
if (data) {
1056+
dispatch(addType['protein'](stage, data, colourList[data.id % colourList.length], true));
1057+
}
1058+
});
1059+
1060+
complexDataList.forEach(data => {
1061+
if (data) {
1062+
dispatch(addType['complex'](stage, data, colourList[data.id % colourList.length], true));
1063+
}
1064+
});
1065+
1066+
surfaceDataList.forEach(data => {
1067+
if (data) {
1068+
dispatch(addType['surface'](stage, data, colourList[data.id % colourList.length], true));
1069+
}
1070+
});
1071+
vectorOnDataList.forEach(data => {
1072+
if (data) {
1073+
dispatch(addType['vector'](stage, data, true));
1074+
}
1075+
});
1076+
} else {
1077+
ligandDataList.forEach(data => {
1078+
if (data) {
1079+
dispatch(removeType['ligand'](stage, data, true));
1080+
}
1081+
});
1082+
1083+
proteinDataList.forEach(data => {
1084+
if (data) {
1085+
dispatch(removeType['protein'](stage, data, colourList[data.id % colourList.length], true));
1086+
}
1087+
});
1088+
1089+
complexDataList.forEach(data => {
1090+
if (data) {
1091+
dispatch(removeType['complex'](stage, data, colourList[data.id % colourList.length], true));
1092+
}
1093+
});
1094+
1095+
surfaceDataList.forEach(data => {
1096+
if (data) {
1097+
dispatch(removeType['surface'](stage, data, colourList[data.id % colourList.length], true));
1098+
}
1099+
});
1100+
vectorOnDataList.forEach(data => {
1101+
if (data) {
1102+
dispatch(removeType['vector'](stage, data, true));
1103+
}
1104+
});
1105+
}
1106+
};
1107+
10311108
const handleAllAction = (action, isSelected, majorViewStage, state) => (dispatch, getState) => {
10321109
let isSelection =
10331110
action.object_type === actionObjectType.MOLECULE || action.object_type === actionObjectType.INSPIRATION;

js/reducers/tracking/trackingActions.js

+14
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,20 @@ export const findTrackAction = (action, state) => {
5656
text: `${actionDescription.SITE} ${molGroupName} ${actionDescription.TURNED_OFF}`
5757
};
5858
}
59+
} else if (action.type === selectionConstants.SET_HIDE_ALL) {
60+
if (action.data) {
61+
let objectType = actionObjectType.MOLECULE;
62+
let description = action.isHide === true ? `` : `${actionDescription.CANCELED}`;
63+
64+
trackAction = {
65+
type: actionType.ALL_HIDE,
66+
timestamp: Date.now(),
67+
username: username,
68+
object_type: objectType,
69+
data: action.data,
70+
text: `${actionDescription.ALL} ${actionDescription.HIDDEN} ${description}`
71+
};
72+
}
5973
} else if (action.type === selectionConstants.SET_SELECTED_ALL) {
6074
if (action.item) {
6175
let objectType = action.item.isInspiration === true ? actionObjectType.INSPIRATION : actionObjectType.MOLECULE;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fragalysis-frontend",
3-
"version": "0.9.30",
3+
"version": "0.9.31",
44
"description": "Frontend for fragalysis",
55
"main": "webpack.config.js",
66
"scripts": {

0 commit comments

Comments
 (0)