Implements Add new Item functionality

This commit is contained in:
Alicia Sykes
2021-10-25 23:22:41 +01:00
parent 31e172befb
commit 06d08a8fff
5 changed files with 59 additions and 6 deletions

View File

@@ -22,6 +22,7 @@ const {
REMOVE_SECTION,
COPY_ITEM,
REMOVE_ITEM,
INSERT_ITEM,
} = Keys;
const store = new Vuex.Store({
@@ -122,6 +123,17 @@ const store = new Vuex.Store({
}
state.config = newConfig;
},
[INSERT_ITEM](state, payload) {
const { newItem, targetSection } = payload;
const config = { ...state.config };
config.sections.forEach((section) => {
if (section.name === targetSection) {
section.items.push(newItem);
}
});
config.sections = applyItemId(config.sections);
state.config = config;
},
[COPY_ITEM](state, payload) {
const { item, toSection, appendTo } = payload;
const config = { ...state.config };