✨ Implements Add new Item functionality
This commit is contained in:
12
src/store.js
12
src/store.js
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user