Permalink
Browse files

Add logic to reset a currently edited item

  • Loading branch information...
markerikson committed Jan 22, 2017
1 parent f6608d0 commit 09c523602d07edee9c92034329d59c4662cbd0a3
@@ -3,6 +3,7 @@ import {
EDIT_ITEM_UPDATE,
EDIT_ITEM_APPLY,
EDIT_ITEM_STOP,
EDIT_ITEM_RESET,
} from "./editingConstants";
@@ -45,4 +46,14 @@ export function stopEditingItem(itemType, itemID) {
itemID
},
};
}
export function resetEditedItem(itemType, itemID) {
return {
type : EDIT_ITEM_RESET,
payload : {
itemType,
itemID,
},
};
}
@@ -1,4 +1,5 @@
export const EDIT_ITEM_EXISTING = "EDIT_ITEM_EXISTING";
export const EDIT_ITEM_UPDATE = "EDIT_ITEM_UPDATE";
export const EDIT_ITEM_APPLY = "EDIT_ITEM_APPLY";
export const EDIT_ITEM_STOP = "EDIT_ITEM_STOP";
export const EDIT_ITEM_STOP = "EDIT_ITEM_STOP";
export const EDIT_ITEM_RESET = "EDIT_ITEM_RESET";
@@ -13,6 +13,7 @@ import {
EDIT_ITEM_UPDATE,
EDIT_ITEM_APPLY,
EDIT_ITEM_STOP,
EDIT_ITEM_RESET,
} from "./editingConstants";
import {getModelByType} from "common/utils/modelUtils";
@@ -108,12 +109,21 @@ export function editItemApply(state, payload) {
}
export function editItemReset(state, payload) {
const stateWithoutItem = editItemStop(state, payload);
const stateWithCurrentItem = editItemExisting(stateWithoutItem, payload);
return stateWithCurrentItem;
}
const editingFeatureReducer = createReducer({}, {
[EDIT_ITEM_EXISTING] : editItemExisting,
[EDIT_ITEM_UPDATE] : editItemUpdate,
[EDIT_ITEM_APPLY] : editItemApply,
[EDIT_ITEM_STOP] : editItemStop,
[EDIT_ITEM_RESET] : editItemReset,
});
export default editingFeatureReducer;

0 comments on commit 09c5236

Please sign in to comment.