Skip to content

Commit 452b8ce

Browse files
Merge remote-tracking branch 'remotes/origin/allfunctionality' into #441
2 parents c5af2dc + a2bbaa2 commit 452b8ce

21 files changed

+740
-345
lines changed

js/components/datasets/datasetFilter.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
setFilterDialogOpen,
99
setFilterProperties,
1010
setFilterSettings,
11+
setDatasetFilter,
1112
setFilterWithInspirations
1213
} from './redux/actions';
1314
import {
@@ -96,20 +97,25 @@ export const DatasetFilter = memo(
9697
return scoreDatasetList[Object.keys(scoreDatasetList).find(attrName => attrName === attr)];
9798
};
9899

99-
const handleFilterChange = (newFilterProperties, newFilterSettings) => {
100+
const handleFilterChange = (newFilterProperties, newFilterSettings, key, prio, oldPrio) => {
100101
Object.keys(scoreDatasetList).forEach(attrKey => {
101102
if (newFilterProperties[attrKey].priority === undefined || newFilterProperties[attrKey].priority === '') {
102103
newFilterProperties[attrKey].priority = 0;
103104
}
105+
if (attrKey === key && prio !== undefined && prio !== null) {
106+
newFilterProperties[attrKey].newPrio = prio;
107+
newFilterProperties[attrKey].oldPrio = oldPrio;
108+
}
104109
});
110+
dispatch(setDatasetFilter(datasetID, newFilterProperties, newFilterSettings, key));
105111
dispatch(setFilterProperties(datasetID, newFilterProperties));
106112
dispatch(setFilterSettings(datasetID, newFilterSettings));
107113
};
108114

109115
const handleItemChange = key => setting => {
110116
const newFilterSettings = createFilterSettingsObject({ active: true, predefined, priorityOrder });
111117
const newFilterProperties = { ...filterProperties, [key]: setting };
112-
handleFilterChange(newFilterProperties, newFilterSettings);
118+
handleFilterChange(newFilterProperties, newFilterSettings, key);
113119
};
114120

115121
const handlePrioChange = key => inc => () => {
@@ -124,13 +130,16 @@ export const DatasetFilter = memo(
124130
newFilterSettings.priorityOrder = localPriorityOrder;
125131
newFilterSettings.active = true;
126132

127-
handleFilterChange(filterProperties, newFilterSettings);
133+
let oldPrio = index;
134+
let newPrio = index + inc;
135+
let newFilterProperties = { ...filterProperties };
136+
handleFilterChange(newFilterProperties, newFilterSettings, key, newPrio, oldPrio);
128137
}
129138
};
130139

131140
const handleClear = () => {
132141
setPredefinedFilter('none');
133-
handleFilterChange(defaultFilterProperties, defaultFilterSettings);
142+
handleFilterChange(defaultFilterProperties, defaultFilterSettings, 'clear');
134143
};
135144

136145
// Check for multiple attributes with same sorting priority

js/components/datasets/datasetMoleculeListSortFilterItem.js

+37-35
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { memo, useState } from 'react';
1+
import React, { memo, useState, useEffect } from 'react';
22
import PropTypes from 'prop-types';
33
import Button from '@material-ui/core/Button';
44
import Slider from '@material-ui/core/Slider';
@@ -120,6 +120,10 @@ export const DatasetMoleculeListSortFilter = memo(
120120
isString
121121
};
122122

123+
useEffect(() => {
124+
setSliderValue([normMinValue, normMaxValue]);
125+
}, [normMinValue, normMaxValue]);
126+
123127
const handleCheckboxChange = e => {
124128
const isChecked = e.target.checked;
125129

@@ -142,7 +146,7 @@ export const DatasetMoleculeListSortFilter = memo(
142146
};
143147

144148
const handleCommitChangeSlider = (event, newValue) => {
145-
setting.minValue = isBoolean ? 1 : (isFloat ? newValue[0] / MULT : newValue[0]);
149+
setting.minValue = isFloat ? newValue[0] / MULT : newValue[0];
146150
setting.maxValue = isFloat ? newValue[1] / MULT : newValue[1];
147151
if (newValue === 1) {
148152
setting.isChecked = false;
@@ -259,7 +263,7 @@ export const DatasetMoleculeListSortFilter = memo(
259263
{isBoolean && (
260264
<>
261265
<Grid item className={classNames(classes.min, classes.centered)} style={{ width: widthMin }}>
262-
{"False"}
266+
{'False'}
263267
</Grid>
264268
<Grid item className={classNames(classes.centered, classes.slider)} style={{ width: widthSlider }}>
265269
<Slider
@@ -268,44 +272,42 @@ export const DatasetMoleculeListSortFilter = memo(
268272
onChangeCommitted={handleCommitChangeSlider}
269273
valueLabelDisplay="auto"
270274
step={null}
271-
marks={[{ value: 1, label: "", }, { value: 50, label: "Ignore", }, { value: 100, label: "", },]}
272-
getAriaValueText={
273-
value => {
274-
if (value === 0) {
275-
return "";
276-
} else if (value === 100) {
277-
return "";
278-
} else {
279-
return "Ignore";
280-
}
275+
marks={[
276+
{ value: 1, label: '' },
277+
{ value: 50, label: 'Ignore' },
278+
{ value: 100, label: '' }
279+
]}
280+
getAriaValueText={value => {
281+
if (value === 0) {
282+
return '';
283+
} else if (value === 100) {
284+
return '';
285+
} else {
286+
return 'Ignore';
281287
}
282-
}
283-
getAriaLabel={
284-
index => {
285-
if (index === 0) {
286-
return "False";
287-
} else if (index === 1) {
288-
return "Ignore";
289-
} else {
290-
return "True";
291-
}
288+
}}
289+
getAriaLabel={index => {
290+
if (index === 0) {
291+
return 'False';
292+
} else if (index === 1) {
293+
return 'Ignore';
294+
} else {
295+
return 'True';
292296
}
293-
}
294-
valueLabelFormat={
295-
value => {
296-
if (value === 1) {
297-
return "False";
298-
} else if (value === 50) {
299-
return "Ignore";
300-
} else {
301-
return "True";
302-
}
297+
}}
298+
valueLabelFormat={value => {
299+
if (value === 1) {
300+
return 'False';
301+
} else if (value === 50) {
302+
return 'Ignore';
303+
} else {
304+
return 'True';
303305
}
304-
}
306+
}}
305307
/>
306308
</Grid>
307309
<Grid item className={classNames(classes.min, classes.centered)} style={{ width: widthMin }}>
308-
{"True"}
310+
{'True'}
309311
</Grid>
310312
</>
311313
)}

js/components/datasets/datasetMoleculeView.js

-14
Original file line numberDiff line numberDiff line change
@@ -485,20 +485,6 @@ export const DatasetMoleculeView = memo(
485485
});
486486
};
487487

488-
const getInspirationsForMol = (datasetId, molId) => {
489-
let inspirations = [];
490-
491-
if (
492-
allInspirations &&
493-
allInspirations.hasOwnProperty(datasetId) &&
494-
allInspirations[datasetId].hasOwnProperty(molId)
495-
) {
496-
inspirations = allInspirations[datasetId][molId];
497-
}
498-
499-
return inspirations;
500-
};
501-
502488
const handleClickOnDownArrow = () => {
503489
const refNext = ref.current.nextSibling;
504490
scrollToElement(refNext);

js/components/datasets/datasetSelectorMenuButton.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Popper from '@material-ui/core/Popper';
66
import MenuItem from '@material-ui/core/MenuItem';
77
import MenuList from '@material-ui/core/MenuList';
88
import { makeStyles } from '@material-ui/core';
9+
import { useDispatch } from 'react-redux';
910

1011
const useStyles = makeStyles(theme => ({
1112
dropDown: {
@@ -21,9 +22,12 @@ export const DatasetSelectorMenuButton = ({
2122
setSelectedDatasetIndex
2223
}) => {
2324
const classes = useStyles();
25+
const dispatch = useDispatch();
2426

2527
const handleMenuItemClick = (event, index) => {
26-
setSelectedDatasetIndex(index);
28+
let oldDataset = customDatasets[selectedDatasetIndex]?.title;
29+
let newDataset = customDatasets[index]?.title;
30+
dispatch(setSelectedDatasetIndex(selectedDatasetIndex, index, newDataset, oldDataset));
2731
setOpen(false);
2832
event.stopPropagation();
2933
};

js/components/datasets/redux/actions.js

+21
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ export const setMoleculeListIsLoading = isLoading => ({
2626
payload: isLoading
2727
});
2828

29+
export const setSelectedDatasetIndex = (oldValue, tabValue, tabName, oldName, skipTracking = false) => ({
30+
type: constants.SET_SELECTED_DATASET_INDEX,
31+
payload: { oldValue: oldValue, value: tabValue, name: tabName, oldName: oldName },
32+
skipTracking: skipTracking
33+
});
34+
35+
export const setTabValue = (oldValue, tabValue, tabName, oldName) => ({
36+
type: constants.SET_TAB_VALUE,
37+
payload: { oldValue: oldValue, value: tabValue, name: tabName, oldName: oldName }
38+
});
39+
2940
export const replaceAllMoleculeLists = allMoleculeLists => ({
3041
type: constants.REPLACE_ALL_MOLECULELISTS,
3142
payload: allMoleculeLists
@@ -41,6 +52,11 @@ export const setFilterProperties = (datasetID, properties) => ({
4152
payload: { datasetID, properties }
4253
});
4354

55+
export const setDatasetFilter = (datasetID, properties, settings, key) => ({
56+
type: constants.SET_DATASET_FILTER,
57+
payload: { datasetID, properties, settings, key }
58+
});
59+
4460
export const setFilterDialogOpen = filterDialogOpen => ({
4561
type: constants.SET_FILTER_DIALOG_OPEN,
4662
payload: filterDialogOpen
@@ -234,6 +250,11 @@ export const updateFilterShowedScoreProperties = ({ datasetID, scoreList = [] })
234250
payload: { datasetID, scoreList }
235251
});
236252

253+
export const setFilterShowedScoreProperties = ({ datasetID, scoreList = [], oldScoreList, isChecked, scoreName }) => ({
254+
type: constants.SET_FILTER_SHOWED_SCORE_PROPERTIES,
255+
payload: { datasetID, scoreList, isChecked, scoreName, oldScoreList }
256+
});
257+
237258
export const removeFromFilterShowedScoreProperties = datasetID => ({
238259
type: constants.REMOVE_FROM_FILTER_SHOWED_SCORE_PROPERTIES,
239260
payload: datasetID

js/components/datasets/redux/constants.js

+4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ export const constants = {
77
ADD_MOLECULELIST: prefix + 'ADD_MOLECULELIST',
88
REMOVE_MOLECULELIST: prefix + 'REMOVE_MOLECULELIST',
99
SET_IS_LOADING_MOLECULE_LIST: prefix + 'SET_IS_LOADING_MOLECULE_LIST',
10+
SET_SELECTED_DATASET_INDEX: prefix + 'SET_SELECTED_DATASET_INDEX',
11+
SET_TAB_VALUE: prefix + 'SET_TAB_VALUE',
1012

1113
SET_FILTER_SETTINGS: prefix + 'SET_FILTER_SETTINGS',
1214
SET_FILTER_PROPERTIES: prefix + 'SET_FILTER_PROPERTIES',
1315
SET_FILTER_DIALOG_OPEN: prefix + 'SET_FILTER_DIALOG_OPEN',
1416
SET_FILTER_WITH_INSPIRATIONS: prefix + 'SET_FILTER_WITH_INSPIRATIONS',
17+
SET_DATASET_FILTER: prefix + 'SET_DATASET_FILTER',
1518

1619
SET_LIGAND_LIST: prefix + 'SET_LIGAND_LIST',
1720
APPEND_LIGAND_LIST: prefix + 'APPEND_LIGAND_LIST',
@@ -39,6 +42,7 @@ export const constants = {
3942
APPEND_TO_SCORE_COMPOUND_MAP_BY_SCORE_CATEGORY: prefix + 'APPEND_TO_SCORE_COMPOUND_MAP_BY_SCORE_CATEGORY',
4043
CLEAR_SCORE_COMPOUND_MAP: prefix + 'CLEAR_SCORE_COMPOUND_MAP',
4144

45+
SET_FILTER_SHOWED_SCORE_PROPERTIES: prefix + 'SET_FILTER_SHOWED_SCORE_PROPERTIES',
4246
UPDATE_FILTER_SHOWED_SCORE_PROPERTIES: prefix + 'UPDATE_FILTER_SHOWED_SCORE_PROPERTIES',
4347
REMOVE_FROM_FILTER_SHOWED_SCORE_PROPERTIES: prefix + 'REMOVE_FROM_FILTER_SHOWED_SCORE_PROPERTIES',
4448

js/components/datasets/redux/dispatchActions.js

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
appendToScoreDatasetMap,
1414
appendToScoreCompoundMapByScoreCategory,
1515
updateFilterShowedScoreProperties,
16+
setFilterShowedScoreProperties,
1617
setFilterProperties,
1718
setIsLoadingInspirationListOfMolecules,
1819
appendToInspirationMoleculeDataList,
@@ -339,6 +340,8 @@ export const selectScoreProperty = ({ isChecked, datasetID, scoreName }) => (dis
339340
const state = getState();
340341
const filteredScorePropertiesOfDataset = state.datasetsReducers.filteredScoreProperties[datasetID];
341342
const scoreDatasetMap = state.datasetsReducers.scoreDatasetMap[datasetID];
343+
let scoreList = [];
344+
let oldScoreList = [...filteredScorePropertiesOfDataset];
342345

343346
if (isChecked === true) {
344347
if (filteredScorePropertiesOfDataset.length === COUNT_OF_VISIBLE_SCORES) {
@@ -348,20 +351,24 @@ export const selectScoreProperty = ({ isChecked, datasetID, scoreName }) => (dis
348351
// 2. select new property
349352
const selectedProperty = scoreDatasetMap[scoreName];
350353
filteredScorePropertiesOfDataset.push(selectedProperty);
354+
scoreList = filteredScorePropertiesOfDataset;
351355
dispatch(
352356
updateFilterShowedScoreProperties({
353357
datasetID,
354358
scoreList: filteredScorePropertiesOfDataset
355359
})
356360
);
357361
} else {
362+
scoreList = filteredScorePropertiesOfDataset.filter(item => item.name !== scoreName);
358363
dispatch(
359364
updateFilterShowedScoreProperties({
360365
datasetID,
361366
scoreList: filteredScorePropertiesOfDataset.filter(item => item.name !== scoreName)
362367
})
363368
);
364369
}
370+
371+
dispatch(setFilterShowedScoreProperties({ datasetID, scoreList, oldScoreList, isChecked, scoreName }));
365372
};
366373

367374
export const loadInspirationMoleculesDataList = (inspirationList = []) => (dispatch, getState) => {

js/components/datasets/redux/reducer.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ export const INITIAL_STATE = {
77
scoreDatasetMap: {}, // map of $datasetID and its $scoreList
88
scoreCompoundMap: {}, // map of $compoundID and its $scoreList
99

10+
selectedDatasetIndex: 0,
11+
tabValue: 0,
12+
1013
// filter
1114
filterDatasetMap: {}, // map of $datasetID and its $filterSettings
1215
filterPropertiesDatasetMap: {}, // map of $datasetID and its $filterProperties
@@ -138,7 +141,7 @@ export const datasetsReducers = (state = INITIAL_STATE, action = {}) => {
138141
return Object.assign({}, state, { datasets: action.payload });
139142

140143
case constants.REPLACE_ALL_MOLECULELISTS:
141-
return {...state, moleculeLists: action.payload};
144+
return { ...state, moleculeLists: action.payload };
142145

143146
case constants.ADD_MOLECULELIST:
144147
// initialize also control containers
@@ -161,6 +164,12 @@ export const datasetsReducers = (state = INITIAL_STATE, action = {}) => {
161164
case constants.SET_IS_LOADING_MOLECULE_LIST:
162165
return Object.assign({}, state, { isLoadingMoleculeList: action.payload });
163166

167+
case constants.SET_SELECTED_DATASET_INDEX:
168+
return Object.assign({}, state, { selectedDatasetIndex: action.payload.value });
169+
170+
case constants.SET_TAB_VALUE:
171+
return Object.assign({}, state, { tabValue: action.payload.value });
172+
164173
case constants.SET_FILTER_SETTINGS:
165174
const { datasetID, filter } = action.payload;
166175
return { ...state, filterDatasetMap: { ...state.filterDatasetMap, [datasetID]: filter } };
@@ -347,7 +356,7 @@ export const datasetsReducers = (state = INITIAL_STATE, action = {}) => {
347356
return Object.assign({}, state, { inspirationFragmentList: [...diminishedInspirationFragmentList] });
348357

349358
case constants.SET_ALL_INSPIRATIONS:
350-
return {...state, allInspirations: action.payload};
359+
return { ...state, allInspirations: action.payload };
351360

352361
case constants.APPEND_MOLECULE_TO_COMPOUNDS_TO_BUY_OF_DATASET:
353362
const setOfMolecules = new Set(state.compoundsToBuyDatasetMap[action.payload.datasetID]);

js/components/nglView/redux/dispatchActions.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ export const toggleMoleculeGroup = (molGroupId, summaryViewStage) => (dispatch,
5757
).catch(error => {
5858
throw new Error(error);
5959
});
60-
dispatch(
61-
clearAfterDeselectingMoleculeGroup()
62-
);
60+
dispatch(clearAfterDeselectingMoleculeGroup({ molGroupId }));
6361
}
6462
};
6563

0 commit comments

Comments
 (0)