first step

Signed-off-by: Jakob <jakob.roehrl@web.de>

1. try

Signed-off-by: Jakob <jakob.roehrl@web.de>

remote calls are working

Signed-off-by: Jakob <jakob.roehrl@web.de>

litte changes

Signed-off-by: Jakob <jakob.roehrl@web.de>

small fixes

Signed-off-by: Jakob <jakob.roehrl@web.de>

incremental fetching

Signed-off-by: Jakob <jakob.roehrl@web.de>

integrated tiptap suggestions for test

Signed-off-by: Jakob <jakob.roehrl@web.de>

Update package-lock after rebase

Signed-off-by: Julius Härtl <jus@bitgrid.net>

Fix various errors

Signed-off-by: Julius Härtl <jus@bitgrid.net>

Cleanup mention plugin use

Signed-off-by: Julius Härtl <jus@bitgrid.net>

Downgrade tippy

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Jakob
2019-09-10 12:31:25 +02:00
committed by Julius Härtl
parent 3adadc23d0
commit 739a92e9a3
9 changed files with 1094 additions and 71 deletions

93
src/store/comment.js Normal file
View File

@@ -0,0 +1,93 @@
/*
* @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
*
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import { CommentApi } from '../services/CommentApi'
import xmlToTagList from '../helpers/xml'
import Vue from 'vue'
const apiClient = new CommentApi()
export default {
state: {
comments: {}
},
mutations: {
addComments(state, commentObj) {
if (state.comments[commentObj.cardId] === undefined) {
Vue.set(state.comments, commentObj.cardId, commentObj.comments)
} else {
// FIXME append comments once incremental fetching is implemented
// state.comments[commentObj.cardId].push(...commentObj.comments)
Vue.set(state.comments, commentObj.cardId, commentObj.comments)
}
},
createComment(state, newComment) {
if (state.comments[newComment.cardId] === undefined) {
state.comments[newComment.cardId] = []
}
state.comments[newComment.cardId].push(newComment)
},
updateComment(state, comment) {
let 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)
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 = {
cardId: card.id,
comments: commentsJson
}
commit('addComments', returnObj)
})
},
createComment({ commit }, newComment) {
apiClient.createComment(newComment)
.then((newComment) => {
commit('createComment', newComment)
})
},
deleteComment({ commit }, data) {
apiClient.deleteComment(data)
.then((retVal) => {
commit('deleteComment', data)
})
},
updateComment({ commit }, data) {
apiClient.updateComment(data)
.then((retVal) => {
commit('updateComment', data)
})
}
}
}