Skip to content

Commit

Permalink
- #441 - finished implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
boriskovar-m2ms committed Feb 15, 2021
1 parent ff812f1 commit c4d8499
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions js/components/preview/compounds/compoundView.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const CompoundView = memo(({ height, width, data, index }) => {
const highlightedCompoundId = useSelector(state => state.previewReducers.compounds.highlightedCompoundId);
const showedCompoundList = useSelector(state => state.previewReducers.compounds.showedCompoundList);
const selectedCompoundsClass = useSelector(state => state.previewReducers.compounds.selectedCompoundsClass);
const allSelectedCompounds = useSelector(state => state.previewReducers.compounds.allSelectedCompounds);
const { getNglView } = useContext(NglContext);
const majorViewStage = getNglView(VIEWS.MAJOR_VIEW) && getNglView(VIEWS.MAJOR_VIEW).stage;
const [image, setImage] = useState(loadingCompoundImage);
Expand Down Expand Up @@ -62,14 +63,27 @@ export const CompoundView = memo(({ height, width, data, index }) => {
current_style = Object.assign(current_style, highlightedStyle);
}

let classFound = false;
Object.keys(selectedCompoundsClass).forEach(classKey => {
if (selectedCompoundsClass[classKey].find(item => item === index) !== undefined) {
classFound = true;
current_style = Object.assign(current_style, {
backgroundColor: compoundsColors[classKey].color
});
}
});

if (!classFound) {
if (allSelectedCompounds[data.smiles]) {
const foundData = allSelectedCompounds[data.smiles];
if (foundData['compoundClass']) {
current_style = Object.assign(current_style, {
backgroundColor: compoundsColors[foundData['compoundClass']].color
});
}
}
}

return (
<div>
<div
Expand Down
1 change: 1 addition & 0 deletions js/components/preview/compounds/redux/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ export const handleClickOnCompound = ({ event, data, majorViewStage, index }) =>
dispatch(setSelectedCompounds(selectedCompoundsCopy));
} else {
data['index'] = index;
data['compoundClass'] = currentCompoundClass;
dispatch(addSelectedCompoundClass(currentCompoundClass, index));
dispatch(appendToBuyList(Object.assign({}, data, { class: currentCompoundClass, compoundId: index }), index));
dispatch(appendMoleculeToCompoundsOfDatasetToBuy(AUX_VECTOR_SELECTOR_DATASET_ID, data.smiles, ''));
Expand Down

0 comments on commit c4d8499

Please sign in to comment.