added new functions

Signed-off-by: Jakob <jakob.roehrl@web.de>
This commit is contained in:
Jakob
2019-07-11 14:31:08 +02:00
committed by Julius Härtl
parent 408ea69272
commit fcabdbdc24
12 changed files with 235 additions and 45 deletions

View File

@@ -21,6 +21,7 @@
*/
import { CardApi } from './../services/CardApi'
import Vue from 'vue'
const apiClient = new CardApi()
@@ -37,6 +38,9 @@ export default {
}
},
mutations: {
clearCards(state) {
state.cards = []
},
addCard(state, card) {
let existingIndex = state.cards.findIndex(_card => _card.id === card.id)
if (existingIndex !== -1) {
@@ -45,6 +49,21 @@ export default {
} else {
state.cards.push(card)
}
},
deleteCard(state, card) {
let existingIndex = state.cards.findIndex(_card => _card.id === card.id)
if (existingIndex !== -1) {
state.cards.splice(existingIndex, 1)
}
},
updateTitle(state, card) {
let existingIndex = state.cards.findIndex(_card => _card.id === card.id)
if (existingIndex !== -1) {
state.cards[existingIndex].title = card.title
}
},
assignCardToMe(state, card) {
// let existingIndex = state.cards.findIndex(_card => _card.id === card.id)
}
},
actions: {
@@ -53,6 +72,35 @@ export default {
.then((createdCard) => {
commit('addCard', createdCard)
})
},
updateCard({ commit }, card) {
apiClient.updateCard(card)
.then((updatedCard) => {
commit('updateTitle', updatedCard)
})
},
deleteCard({ commit }, card) {
apiClient.deleteCard(card.id)
.then((card) => {
commit('deleteCard', card)
})
},
archiveUnarchiveCard({ commit }, card) {
let call = 'archiveCard'
if (card.archived === false) {
call = 'unArchiveCard'
}
apiClient[call](card)
.then((card) => {
commit('deleteCard', card)
})
},
assignCardToMe({ commit }, card) {
apiClient.assignUser(card)
.then((card) => {
commit('assignCardToMe', card)
})
}
}
}

View File

@@ -46,10 +46,12 @@ export default new Vuex.Store({
},
strict: debug,
state: {
showArchived: false,
navShown: true,
compactMode: false,
sidebarShown: false,
currentBoard: null,
currentCard: null,
boards: [],
sharees: [],
boardFilter: BOARD_FILTERS.ALL
@@ -90,6 +92,9 @@ export default new Vuex.Store({
}
},
mutations: {
toggleShowArchived(state) {
state.showArchived = !state.showArchived
},
/**
* Adds or replaces a board in the store.
* Matches a board by it's id.
@@ -143,6 +148,9 @@ export default new Vuex.Store({
setCurrentBoard(state, board) {
state.currentBoard = board
},
setCurrentCard(state, card) {
state.currentCard = card
},
// label mutators
removeLabelFromCurrentBoard(state, labelId) {
@@ -196,6 +204,9 @@ export default new Vuex.Store({
}
},
actions: {
toggleShowArchived({ commit }) {
commit('toggleShowArchived')
},
/**
* @param commit
* @param state
@@ -272,6 +283,9 @@ export default new Vuex.Store({
setCurrentBoard({ commit }, board) {
commit('setCurrentBoard', board)
},
setCurrentCard({ commit }, card) {
commit('setCurrentCard', card)
},
// label actions
removeLabelFromCurrentBoard({ commit }, label) {

View File

@@ -77,7 +77,12 @@ export default {
})
},
loadStacks({ commit }, board) {
apiClient.loadStacks(board.id)
commit('clearCards')
let call = 'loadStacks'
if (this.state.showArchived === true) {
call = 'loadArchivedStacks'
}
apiClient[call](board.id)
.then((stacks) => {
for (let i in stacks) {
let stack = stacks[i]