Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/#479' into allfunctionality
Browse files Browse the repository at this point in the history
  • Loading branch information
boriskovar-m2ms committed Jan 22, 2021
2 parents 9109471 + fc1b353 commit 886eeb3
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 61 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
24 changes: 10 additions & 14 deletions js/reducers/tracking/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1306,12 +1306,11 @@ const handleUndoAction = (action, stages) => (dispatch, getState) => {
dispatch(handleShoppingCartAction(action, true));
break;
case actionType.MOLECULE_ADDED_TO_SHOPPING_CART_ALL:
dispatch(handleShoppingCartAllAction(action, false));
dispatch(handleShoppingCartAllAction(action, false, majorViewStage));
break;
case actionType.MOLECULE_REMOVED_FROM_SHOPPING_CART_ALL:
dispatch(handleShoppingCartAllAction(action, true));
dispatch(handleShoppingCartAllAction(action, true, majorViewStage));
break;

case actionType.COMPOUND_SELECTED:
dispatch(handleCompoundAction(action, false));
break;
Expand Down Expand Up @@ -1444,10 +1443,10 @@ const handleRedoAction = (action, stages) => (dispatch, getState) => {
dispatch(handleShoppingCartAction(action, false));
break;
case actionType.MOLECULE_ADDED_TO_SHOPPING_CART_ALL:
dispatch(handleShoppingCartAllAction(action, true));
dispatch(handleShoppingCartAllAction(action, true, majorViewStage));
break;
case actionType.MOLECULE_REMOVED_FROM_SHOPPING_CART_ALL:
dispatch(handleShoppingCartAllAction(action, false));
dispatch(handleShoppingCartAllAction(action, false, majorViewStage));
break;
case actionType.COMPOUND_SELECTED:
dispatch(handleCompoundAction(action, true));
Expand Down Expand Up @@ -1691,8 +1690,8 @@ const handleVectorAction = (action, isSelected) => (dispatch, getState) => {
const handleVectorCompoundAction = (action, isSelected, majorViewStage) => (dispatch, getState) => {
if (action) {
let data = action.item;
let index = action.index;
dispatch(handleShowVectorCompound({ isSelected, data, index, majorViewStage: majorViewStage }));
let compoundId = action.compoundId;
dispatch(handleShowVectorCompound({ isSelected, data, index: compoundId, majorViewStage: majorViewStage }));
}
};

Expand Down Expand Up @@ -1747,20 +1746,17 @@ const handleCompoundAction = (action, isSelected) => (dispatch, getState) => {
const handleShoppingCartAction = (action, isAdd) => (dispatch, getState) => {
if (action) {
let data = action.item;
let index = action.index;
let compoundId = action.compoundId;

if (data) {
dispatch(handleBuyList({ isSelected: isAdd, data, index }));
dispatch(handleBuyList({ isSelected: isAdd, data, compoundId }));
}
}
};

const handleShoppingCartAllAction = (action, isAdd) => (dispatch, getState) => {
const handleShoppingCartAllAction = (action, isAdd, majorViewStage) => (dispatch, getState) => {
if (action) {
let data = action.items;
if (data) {
dispatch(handleBuyListAll({ isSelected: isAdd, data }));
}
dispatch(handleBuyListAll({ isSelected: isAdd, items: action.items, majorViewStage: majorViewStage }));
}
};

Expand Down
64 changes: 30 additions & 34 deletions js/reducers/tracking/trackingActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ export const findTrackAction = (action, state) => {
object_type: objectType,
object_name: objectName,
object_id: objectName,
index: action.index,
compoundId: action.item.compoundId,
item: action.item,
text: `${actionDescription.VECTOR} ${objectName} ${actionDescription.ADDED} ${actionDescription.TO_SHOPPING_CART}`
};
Expand All @@ -391,7 +391,7 @@ export const findTrackAction = (action, state) => {
object_type: objectType,
object_name: objectName,
object_id: objectName,
index: action.index,
compoundId: action.item.compoundId,
item: action.item,
text: `${actionDescription.VECTOR} ${objectName} ${actionDescription.REMOVED} ${actionDescription.FROM_SHOPPING_CART}`
};
Expand Down Expand Up @@ -423,41 +423,37 @@ export const findTrackAction = (action, state) => {
text: `${actionDescription.ALL} ${actionDescription.REMOVED} ${actionDescription.FROM_SHOPPING_CART}`
};
} else if (action.type === previewCompoundConstants.APPEND_SHOWED_COMPOUND_LIST) {
if (action.item && action.payload) {
let objectType = actionObjectType.COMPOUND;
let objectName = action.item && action.item.vector;
let objectType = actionObjectType.COMPOUND;
let objectName = action.item && action.item.vector;

trackAction = {
type: actionType.VECTOR_COUMPOUND_ADDED,
annotation: actionAnnotation.CHECK,
timestamp: Date.now(),
username: username,
object_type: objectType,
object_name: objectName,
object_id: action.payload,
item: action.item,
index: action.payload,
text: `${actionDescription.COMPOUND} ${objectName} ${actionDescription.ADDED}`
};
}
trackAction = {
type: actionType.VECTOR_COUMPOUND_ADDED,
annotation: actionAnnotation.CHECK,
timestamp: Date.now(),
username: username,
object_type: objectType,
object_name: objectName,
object_id: action.payload,
item: action.item,
compoundId: action.payload,
text: `${actionDescription.COMPOUND} ${objectName} ${actionDescription.ADDED}`
};
} else if (action.type === previewCompoundConstants.REMOVE_SHOWED_COMPOUND_LIST) {
if (action.item && action.payload) {
let objectType = actionObjectType.COMPOUND;
let objectName = action.item && action.item.vector;
let objectType = actionObjectType.COMPOUND;
let objectName = action.item && action.item.vector;

trackAction = {
type: actionType.VECTOR_COUMPOUND_REMOVED,
annotation: actionAnnotation.CLEAR,
timestamp: Date.now(),
username: username,
object_type: objectType,
object_name: objectName,
object_id: action.payload,
item: action.item,
index: action.payload,
text: `${actionDescription.COMPOUND} ${objectName} ${actionDescription.REMOVED}`
};
}
trackAction = {
type: actionType.VECTOR_COUMPOUND_REMOVED,
annotation: actionAnnotation.CLEAR,
timestamp: Date.now(),
username: username,
object_type: objectType,
object_name: objectName,
object_id: action.payload,
item: action.item,
compoundId: action.payload,
text: `${actionDescription.COMPOUND} ${objectName} ${actionDescription.REMOVED}`
};
} else if (action.type.includes(selectionConstants.SET_CURRENT_VECTOR)) {
if (action.payload) {
let objectType = actionObjectType.MOLECULE;
Expand Down

0 comments on commit 886eeb3

Please sign in to comment.