Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/allfunctionality' into #486
Browse files Browse the repository at this point in the history
  • Loading branch information
boriskovar-m2ms committed Jan 25, 2021
2 parents 68eaab9 + 4efbbee commit 41957fe
Show file tree
Hide file tree
Showing 10 changed files with 328 additions and 125 deletions.
27 changes: 14 additions & 13 deletions js/components/preview/compounds/redux/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ export const selectAllCompounds = () => (dispatch, getState) => {
for (let index in currentVectorCompoundsFiltered[key]) {
if (index !== 'vector') {
for (let indexOfCompound in currentVectorCompoundsFiltered[key][index]) {
let compoundId = parseInt(indexOfCompound);
var thisObj = {
smiles: currentVectorCompoundsFiltered[key][index][indexOfCompound].end,
vector: currentVectorCompoundsFiltered[key].vector.split('_')[0],
mol: smiles,
class: parseInt(currentCompoundClass),
indexOfCompound: indexOfCompound,
index: index
compoundId: compoundId
};
items.push(thisObj);
dispatch(appendToBuyList(thisObj, index, true));
dispatch(addSelectedCompoundClass(currentCompoundClass, parseInt(indexOfCompound)));
dispatch(appendToBuyList(thisObj, compoundId, true));
dispatch(addSelectedCompoundClass(currentCompoundClass, compoundId));
}
}
}
Expand Down Expand Up @@ -215,28 +215,29 @@ export const handleClickOnCompound = ({ event, data, majorViewStage, index }) =>
}
};

export const handleBuyList = ({ isSelected, data, index }) => async (dispatch, getState) => {
export const handleBuyList = ({ isSelected, data, compoundId }) => (dispatch, getState) => {
const state = getState();
const currentCompoundClass = state.previewReducers.compounds.currentCompoundClass;

dispatch(setHighlightedCompoundId(index));
dispatch(setHighlightedCompoundId(compoundId));

if (isSelected === false) {
await dispatch(removeSelectedCompoundClass(index));
dispatch(removeFromToBuyList(data, index, true));
dispatch(removeSelectedCompoundClass(compoundId));
dispatch(removeFromToBuyList(data, compoundId, true));
} else {
await dispatch(addSelectedCompoundClass(currentCompoundClass, index));
dispatch(appendToBuyList(Object.assign({}, data, { class: currentCompoundClass }), index, true));
dispatch(addSelectedCompoundClass(currentCompoundClass, compoundId));
dispatch(appendToBuyList(Object.assign({}, data, { class: currentCompoundClass }), compoundId, true));
}
};

export const handleBuyListAll = ({ isSelected, items, majorViewStage }) => async (dispatch, getState) => {
export const handleBuyListAll = ({ isSelected, items, majorViewStage }) => (dispatch, getState) => {
if (isSelected === false) {
dispatch(clearCompounds(items, majorViewStage));
} else {
for (var item in items) {
dispatch(appendToBuyList(item, item.index, true));
dispatch(addSelectedCompoundClass(item.class, item.indexOfCompound));
let index = item.compoundId;
dispatch(appendToBuyList(item, index, true));
dispatch(addSelectedCompoundClass(item.class, index));
}
dispatch(appendToBuyListAll(items));
}
Expand Down
5 changes: 2 additions & 3 deletions js/components/preview/molecule/moleculeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,6 @@ export const MoleculeList = memo(({ height, setFilterItemsHeight, filterItemsHei
}
}, [getJoinedMoleculeList, getAllMoleculeList, searchString]);

// Used for MoleculeListSortFilterDialog when using textSearch
const joinedMoleculeListsCopy = useMemo(() => [...joinedMoleculeLists], [joinedMoleculeLists]);

const addSelectedMoleculesFromUnselectedSites = useCallback((joinedMoleculeLists, list) => {
const result = [...joinedMoleculeLists];
list?.forEach(moleculeID => {
Expand Down Expand Up @@ -451,6 +448,8 @@ export const MoleculeList = memo(({ height, setFilterItemsHeight, filterItemsHei
setFilterItemsHeight(0);
}
}, [isActiveFilter, setFilterItemsHeight]);

const joinedMoleculeListsCopy = useMemo(() => [...joinedMoleculeLists], [joinedMoleculeLists]);

useEffect(() => {
if (!joinedMoleculeListsCopy.length) {
Expand Down
13 changes: 10 additions & 3 deletions js/components/preview/viewerControls/displayControls/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
addComponentRepresentation,
removeComponentRepresentation,
updateComponentRepresentation,
updateComponentRepresentationVisibility,
updateComponentRepresentationVisibilityAll,
changeComponentRepresentation
} from '../../../../reducers/ngl/actions';
import { deleteObject } from '../../../../reducers/ngl/dispatchActions';
Expand Down Expand Up @@ -52,7 +54,10 @@ export default memo(({ open, onClose }) => {
const newVisibility = !r.getVisibility();
// update in redux
representation.params.visible = newVisibility;
dispatch(updateComponentRepresentation(parentKey, representation.uuid, representation));
dispatch(updateComponentRepresentation(parentKey, representation.uuid, representation, '', true));
dispatch(
updateComponentRepresentationVisibility(parentKey, representation.uuid, representation, newVisibility)
);
// update in nglView
r.setVisibility(newVisibility);
}
Expand Down Expand Up @@ -121,7 +126,7 @@ export default memo(({ open, onClose }) => {
const targetObject = objectsInView[parentKey];
const nglView = getNglView(objectsInView[parentKey].display_div);
const comp = nglView.stage.getComponentsByName(parentKey).first;
comp.eachRepresentation(representation => dispatch(removeComponentRepresentation(parentKey, representation)));
comp.eachRepresentation(representation => dispatch(removeComponentRepresentation(parentKey, representation, true)));

// remove from nglReducer and selectionReducer
dispatch(deleteObject(targetObject, nglView.stage, true));
Expand All @@ -144,10 +149,12 @@ export default memo(({ open, onClose }) => {
// update in nglView
r.setVisibility(newVisibility);
// update in redux
dispatch(updateComponentRepresentation(parentKey, representation.uuid, representation));
dispatch(updateComponentRepresentation(parentKey, representation.uuid, representation, '', true));
}
});
});

dispatch(updateComponentRepresentationVisibilityAll(parentKey, newVisibility));
};

const hasAllRepresentationVisibled = parentKey => {
Expand Down
2 changes: 1 addition & 1 deletion js/components/preview/viewerControls/settingsControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const SettingControls = memo(({ open, onClose }) => {
step={1}
min={0}
max={100}
onChange={(e, value) => dispatch(setNglClipFar(value, viewParams[NGL_PARAMS.cli], majorView))}
onChange={(e, value) => dispatch(setNglClipFar(value, viewParams[NGL_PARAMS.clipFar], majorView))}
/>
</Grid>
</Grid>
Expand Down
35 changes: 32 additions & 3 deletions js/reducers/ngl/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,41 @@ export const deleteNglObject = target => ({
target
});

export const updateComponentRepresentation = (objectInViewID, representationID, newRepresentation, change) => ({
export const updateComponentRepresentationVisibility = (
objectInViewID,
representationID,
representation,
newVisibility,
skipTracking = false
) => ({
type: CONSTANTS.UPDATE_COMPONENT_REPRESENTATION_VISIBILITY,
representationID,
representation,
newVisibility,
objectInViewID,
skipTracking
});

export const updateComponentRepresentationVisibilityAll = (objectInViewID, newVisibility, skipTracking = false) => ({
type: CONSTANTS.UPDATE_COMPONENT_REPRESENTATION_VISIBILITY_ALL,
newVisibility,
objectInViewID,
skipTracking
});

export const updateComponentRepresentation = (
objectInViewID,
representationID,
newRepresentation,
change,
skipTracking = false
) => ({
type: CONSTANTS.UPDATE_COMPONENT_REPRESENTATION,
representationID,
newRepresentation,
objectInViewID,
change
change,
skipTracking
});

export const addComponentRepresentation = (objectInViewID, newRepresentation, skipTracking = false) => ({
Expand Down Expand Up @@ -51,7 +80,7 @@ export const setNglViewParams = (key, value, stage = undefined, objectId = undef
};
};

export const setBackgroundColor = (color) => {
export const setBackgroundColor = color => {
return {
type: CONSTANTS.SET_BACKGROUND_COLOR,
payload: color
Expand Down
2 changes: 2 additions & 0 deletions js/reducers/ngl/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export const CONSTANTS = {
LOAD_OBJECT: prefix + 'LOAD_OBJECT',
DELETE_OBJECT: prefix + 'DELETE_OBJECT',
// NGL Component Representation
UPDATE_COMPONENT_REPRESENTATION_VISIBILITY: prefix + 'UPDATE_COMPONENT_REPRESENTATION_VISIBILITY',
UPDATE_COMPONENT_REPRESENTATION_VISIBILITY_ALL: prefix + 'UPDATE_COMPONENT_REPRESENTATION_VISIBILITY_ALL',
UPDATE_COMPONENT_REPRESENTATION: prefix + 'UPDATE_COMPONENT_REPRESENTATION',
REMOVE_COMPONENT_REPRESENTATION: prefix + 'REMOVE_COMPONENT_REPRESENTATION',
ADD_COMPONENT_REPRESENTATION: prefix + 'ADD_COMPONENT_REPRESENTATION',
Expand Down
7 changes: 5 additions & 2 deletions js/reducers/tracking/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export const actionType = {
COMPOUND_SELECTED: 'COMPOUND_SELECTED',
COMPOUND_DESELECTED: 'COMPOUND_DESELECTED',
REPRESENTATION_UPDATED: 'REPRESENTATION_UPDATED',
REPRESENTATION_VISIBILITY_UPDATED: 'REPRESENTATION_VISIBILITY_UPDATED',
REPRESENTATION_VISIBILITY_ALL_UPDATED: 'REPRESENTATION_VISIBILITY_ALL_UPDATED',
REPRESENTATION_ADDED: 'REPRESENTATION_ADDED',
REPRESENTATION_REMOVED: 'REPRESENTATION_REMOVED',
REPRESENTATION_CHANGED: 'REPRESENTATION_CHANGED',
Expand Down Expand Up @@ -76,11 +78,13 @@ export const actionDescription = {
SELECTED: 'was selected',
DESELECTED: 'was deselected',
HIDDEN: 'hidden',
VISIBLE: 'visible',
CANCELED: 'canceled',
ADDED: 'was added',
REMOVED: 'was removed',
CHANGED: 'was changed',
UPDATED: 'was updated',
VISIBILITY: 'visiblity',
TO_SHOPPING_CART: 'to shopping cart',
FROM_SHOPPING_CART: 'from shopping cart',
LIGAND: 'Ligand',
Expand All @@ -94,8 +98,7 @@ export const actionDescription = {
TARGET: 'Target',
ALL: 'All',
LIGANDS: 'Ligands',
SIDECHAINS: 'Sidechains',
INTERACTIONS: 'Interactions'
SIDECHAINS: 'Sidechains'
};

export const actionObjectType = {
Expand Down
Loading

0 comments on commit 41957fe

Please sign in to comment.