refactor: split 'components/collections/addFolder.vue' to 'addFolder', 'editFolder'

This commit is contained in:
vlad0337187
2019-10-24 05:15:55 +03:00
parent 932b92e67d
commit 3743ff96ff
7 changed files with 199 additions and 129 deletions

View File

@@ -84,9 +84,9 @@ export const mutations = {
addNewCollection (state, collection) {
state.collections.push({
name: '',
folders: [],
requests: [],
name : '',
folders : [],
requests : [],
...collection,
})
},
@@ -98,12 +98,22 @@ export const mutations = {
editCollection (state, payload) {
const { collection, collectionIndex } = payload
state.collections[collectionIndex] = collection
state.collections[collectionIndex] = collection
},
addFolder (state, payload) {
addNewFolder (state, payload) {
const { collectionIndex, folder } = payload;
state.collections[collectionIndex].folders.push(folder);
state.collections[collectionIndex].folders.push({
name : '',
requests : [],
...folder,
});
},
editFolder (state, payload) {
const { collectionIndex, folder, folderIndex } = payload;
state.collections[collectionIndex].folders[folderIndex] = folder;
state.collections[collectionIndex].folders = [...state.collections[collectionIndex].folders] // mark updated
},
removeFolder (state, payload) {
@@ -111,11 +121,6 @@ export const mutations = {
state.collections[collectionIndex].folders.splice(folderIndex, 1)
},
saveFolder (state, payload) {
const { savedFolder } = payload;
state.collections[savedFolder.collectionIndex].folders[savedFolder.folderIndex] = savedFolder;
},
addRequest (state, payload) {
const { request } = payload;