update, delete and create are working

Signed-off-by: Jakob Röhrl <jakob.roehrl@web.de>
This commit is contained in:
Jakob Röhrl
2019-04-16 12:02:47 +02:00
committed by Julius Härtl
parent b3cb618707
commit 1cd1684936
3 changed files with 112 additions and 9 deletions

View File

@@ -139,6 +139,7 @@ export default new Vuex.Store({
// label mutators
removeLabelFromCurrentBoard(state, labelId) {
console.log(labelId)
const removeIndex = state.currentBoard.labels.findIndex((l) => {
return labelId === l.id
})
@@ -155,6 +156,10 @@ export default new Vuex.Store({
labelToUpdate.title = newLabel.title
labelToUpdate.color = newLabel.color
},
addLabelToCurrentBoard(state, newLabel) {
state.currentBoard.labels.push(newLabel)
}
},
actions: {
@@ -234,11 +239,23 @@ export default new Vuex.Store({
},
// label actions
removeLabelFromCurrentBoard({ commit }, labelId) {
commit('removeLabelFromCurrentBoard', labelId);
removeLabelFromCurrentBoard({ commit }, label) {
apiClient.deleteLabel(label)
.then((label) => {
commit('removeLabelFromCurrentBoard', label.id);
})
},
updateLabelFromCurrentBoard({ commit }, newLabel) {
commit('updateLabelFromCurrentBoard', newLabel);
apiClient.updateLabel(newLabel)
.then((newLabel) => {
commit('updateLabelFromCurrentBoard', newLabel);
})
},
addLabelToCurrentBoard({ commit }, newLabel) {
apiClient.createLabel(newLabel)
.then((newLabel) => {
commit('addLabelToCurrentBoard', newLabel);
})
}
}
})