Skip to content

Commit

Permalink
#519 L and V toggle incosisten Undo/Redo behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
Adriána Kohanová committed Feb 2, 2021
1 parent 5b48a2e commit 42a5391
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
8 changes: 5 additions & 3 deletions js/components/preview/molecule/redux/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,14 @@ export const addLigand = (
});
};

export const removeLigand = (stage, data, skipTracking = false) => dispatch => {
export const removeLigand = (stage, data, skipTracking = false, withVector = true) => dispatch => {
dispatch(deleteObject(Object.assign({ display_div: VIEWS.MAJOR_VIEW }, generateMoleculeObject(data)), stage));
dispatch(removeFromFragmentDisplayList(generateMoleculeId(data), skipTracking));

// remove vector
dispatch(removeVector(stage, data, skipTracking));
if (withVector === true) {
// remove vector
dispatch(removeVector(stage, data, skipTracking));
}
};

/**
Expand Down
16 changes: 13 additions & 3 deletions js/reducers/tracking/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,8 @@ const restoreAllSelectionByTypeActions = (moleculesAction, stage, isSelection) =
if (data) {
if (type === 'ligand') {
dispatch(addType[type](stage, data, colourList[data.id % colourList.length], true, true));
} else if (type === 'vector') {
dispatch(addType[type](stage, data, true));
} else {
dispatch(addType[type](stage, data, colourList[data.id % colourList.length], true));
}
Expand Down Expand Up @@ -1121,6 +1123,8 @@ const addNewType = (moleculesAction, actionType, type, stage, state, skipTrackin
if (data) {
if (type === 'ligand') {
dispatch(addType[type](stage, data, colourList[data.id % colourList.length], true, skipTracking));
} else if (type === 'vector') {
dispatch(addType[type](stage, data, true));
} else {
dispatch(addType[type](stage, data, colourList[data.id % colourList.length], skipTracking));
}
Expand All @@ -1135,6 +1139,8 @@ const addNewTypeOfAction = (action, type, stage, state, skipTracking = false) =>
if (data) {
if (type === 'ligand') {
dispatch(addType[type](stage, data, colourList[data.id % colourList.length], true, skipTracking));
} else if (type === 'vector') {
dispatch(addType[type](stage, data, true));
} else {
dispatch(addType[type](stage, data, colourList[data.id % colourList.length], skipTracking));
}
Expand Down Expand Up @@ -1595,6 +1601,8 @@ const handleAllActionByType = (action, isAdd, stage) => (dispatch, getState) =>
if (data) {
if (type === 'ligand') {
dispatch(addType[type](stage, data, colourList[data.id % colourList.length], true, true));
} else if (type === 'vector') {
dispatch(addType[type](stage, data, true));
} else {
dispatch(addType[type](stage, data, colourList[data.id % colourList.length], true));
}
Expand All @@ -1605,7 +1613,7 @@ const handleAllActionByType = (action, isAdd, stage) => (dispatch, getState) =>

actionItems.forEach(data => {
if (data) {
if (type === 'ligand') {
if (type === 'ligand' || type === 'vector') {
dispatch(removeType[type](stage, data, true));
} else {
dispatch(removeType[type](stage, data, colourList[data.id % colourList.length], true));
Expand Down Expand Up @@ -2125,6 +2133,8 @@ const handleMoleculeGroupAction = (action, isSelected, stageSummaryView, majorVi
for (const mol of typeGroup) {
if (type === 'ligand') {
dispatch(addType[type](majorViewStage, mol, colourList[mol.id % colourList.length], true, true));
} else if (type === 'vector') {
dispatch(addType[type](majorViewStage, mol, true));
} else {
dispatch(addType[type](majorViewStage, mol, colourList[mol.id % colourList.length], true));
}
Expand Down Expand Up @@ -2176,8 +2186,8 @@ const removeNewType = (action, type, stage, state, skipTracking) => dispatch =>
if (action) {
let data = getMolecule(action.object_name, state);
if (data) {
if (type === 'ligand') {
dispatch(removeType[type](stage, data, skipTracking));
if (type === 'ligand' || type === 'vector') {
dispatch(removeType[type](stage, data, skipTracking, false));
} else {
dispatch(removeType[type](stage, data, colourList[data.id % colourList.length], skipTracking));
}
Expand Down

0 comments on commit 42a5391

Please sign in to comment.