Some comments code cleanup

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2020-01-25 09:52:30 +01:00
parent 739a92e9a3
commit ad069e5e14
10 changed files with 187 additions and 163 deletions

View File

@@ -28,7 +28,7 @@ const apiClient = new CommentApi()
export default {
state: {
comments: {}
comments: {},
},
mutations: {
addComments(state, commentObj) {
@@ -47,26 +47,26 @@ export default {
state.comments[newComment.cardId].push(newComment)
},
updateComment(state, comment) {
let existingIndex = state.comments[comment.cardId].findIndex(_comment => _comment.id === comment.commentId)
const existingIndex = state.comments[comment.cardId].findIndex(_comment => _comment.id === comment.commentId)
if (existingIndex !== -1) {
state.comments[comment.cardId][existingIndex].message = comment.comment
}
},
deleteComment(state, comment) {
let existingIndex = state.comments[comment.cardId].findIndex(_comment => _comment.id === comment.commentId)
const existingIndex = state.comments[comment.cardId].findIndex(_comment => _comment.id === comment.commentId)
if (existingIndex !== -1) {
state.comments[comment.cardId].splice(existingIndex, 1)
}
}
},
},
actions: {
listComments({ commit }, card) {
apiClient.listComments(card)
.then((comments) => {
const commentsJson = xmlToTagList(comments)
let returnObj = {
const returnObj = {
cardId: card.id,
comments: commentsJson
comments: commentsJson,
}
commit('addComments', returnObj)
})
@@ -88,6 +88,6 @@ export default {
.then((retVal) => {
commit('updateComment', data)
})
}
}
},
},
}

View File

@@ -95,7 +95,7 @@ export default new Vuex.Store({
},
currentBoardLabels: state => {
return state.currentBoard ? state.currentBoard.labels : []
}
},
},
mutations: {
toggleShowArchived(state) {