some overall changes

Signed-off-by: Jakob Röhrl <jakob.roehrl@web.de>
This commit is contained in:
Jakob Röhrl
2019-05-24 09:34:36 +02:00
committed by Julius Härtl
parent f71f24c450
commit 501545f2e5
7 changed files with 160 additions and 98 deletions

View File

@@ -21,6 +21,9 @@
*/
import Vue from 'vue'
import { CardApi } from './../services/CardApi'
const apiClient = new CardApi()
export default {
state: {
@@ -36,15 +39,22 @@ export default {
},
mutations: {
addCard(state, card) {
let existingIndex = state.cards.findIndex(_card => _card.id === card.id)
state.cards.push(card)
/* let existingIndex = state.cards.findIndex(_card => _card.id === card.id)
if (existingIndex !== -1) {
let existingCard = state.cards.find(_card => _card.id === card.id)
Vue.set(state.cards, existingIndex, Object.assign({}, existingCard, card))
} else {
state.cards.push(card)
}
} */
}
},
actions: {
addCard({ commit }, card) {
apiClient.addCard(card)
.then((createdCard) => {
commit('addCard', createdCard)
})
}
}
}

View File

@@ -54,13 +54,15 @@ export default {
},
deleteStack(state, stack) {
let existingIndex = state.stacks.findIndex(_stack => _stack.id === stack.id)
console.log(existingIndex)
if (existingIndex !== -1) {
state.stacks.splice(existingIndex, 1)
}
},
updateStack(state, stack) {
let existingIndex = state.stacks.findIndex(_stack => _stack.id === stack.id)
if (existingIndex !== -1) {
state.stacks[existingIndex] = stack
}
}
},
actions: {