From 5e695a26da32a223f03a00d2211fa01e7bb3bbed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1na=20Kohanov=C3=A1?= Date: Mon, 25 Jan 2021 16:48:48 +0100 Subject: [PATCH] #505 Undo/redo is broken in vector selector --- .../preview/compounds/redux/dispatchActions.js | 13 ++++--------- js/reducers/tracking/dispatchActions.js | 4 ++-- js/reducers/tracking/trackingActions.js | 4 ++-- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/js/components/preview/compounds/redux/dispatchActions.js b/js/components/preview/compounds/redux/dispatchActions.js index fc3c82fca..1730066c2 100644 --- a/js/components/preview/compounds/redux/dispatchActions.js +++ b/js/components/preview/compounds/redux/dispatchActions.js @@ -206,11 +206,11 @@ export const handleClickOnCompound = ({ event, data, majorViewStage, index }) => } if (isSelectedID !== undefined) { - await dispatch(removeSelectedCompoundClass(index)); + dispatch(removeSelectedCompoundClass(index)); dispatch(removeFromToBuyList(data, index)); } else { - await dispatch(addSelectedCompoundClass(currentCompoundClass, index)); - dispatch(appendToBuyList(Object.assign({}, data, { class: currentCompoundClass })), index); + dispatch(addSelectedCompoundClass(currentCompoundClass, index)); + dispatch(appendToBuyList(Object.assign({}, data, { class: currentCompoundClass }), index)); } } }; @@ -234,12 +234,7 @@ export const handleBuyListAll = ({ isSelected, items, majorViewStage }) => (disp if (isSelected === false) { dispatch(clearCompounds(items, majorViewStage)); } else { - for (var item in items) { - let index = item.compoundId; - dispatch(appendToBuyList(item, index, true)); - dispatch(addSelectedCompoundClass(item.class, index)); - } - dispatch(appendToBuyListAll(items)); + dispatch(selectAllCompounds()); } }; diff --git a/js/reducers/tracking/dispatchActions.js b/js/reducers/tracking/dispatchActions.js index f0c784964..db7065c1d 100644 --- a/js/reducers/tracking/dispatchActions.js +++ b/js/reducers/tracking/dispatchActions.js @@ -1424,10 +1424,10 @@ const handleRedoAction = (action, stages) => (dispatch, getState) => { dispatch(handleVectorAction(action, false)); break; case actionType.VECTOR_COUMPOUND_ADDED: - dispatch(handleVectorCompoundAction(action, true)); + dispatch(handleVectorCompoundAction(action, true, majorViewStage)); break; case actionType.VECTOR_COUMPOUND_REMOVED: - dispatch(handleVectorCompoundAction(action, false)); + dispatch(handleVectorCompoundAction(action, false, majorViewStage)); break; case actionType.CLASS_SELECTED: dispatch(handleClassSelectedAction(action, true)); diff --git a/js/reducers/tracking/trackingActions.js b/js/reducers/tracking/trackingActions.js index 7fcc7414f..dcdac5b8a 100644 --- a/js/reducers/tracking/trackingActions.js +++ b/js/reducers/tracking/trackingActions.js @@ -373,7 +373,7 @@ export const findTrackAction = (action, state) => { object_type: objectType, object_name: objectName, object_id: objectName, - compoundId: action.item.compoundId, + compoundId: action.index, item: action.item, text: `${actionDescription.VECTOR} ${objectName} ${actionDescription.ADDED} ${actionDescription.TO_SHOPPING_CART}` }; @@ -391,7 +391,7 @@ export const findTrackAction = (action, state) => { object_type: objectType, object_name: objectName, object_id: objectName, - compoundId: action.item.compoundId, + compoundId: action.index, item: action.item, text: `${actionDescription.VECTOR} ${objectName} ${actionDescription.REMOVED} ${actionDescription.FROM_SHOPPING_CART}` };