Vue Comments: Comments ported to Vue + DnD fileupload
* Drag and drop files to comment editor to add a file attachment * Using Vue to render comments Since comments now has attachments we need to update the schemas ./manage.py maintenance replace_pillar_node_type_schemas
This commit is contained in:
46
src/scripts/js/es6/common/api/comments.js
Normal file
46
src/scripts/js/es6/common/api/comments.js
Normal file
@@ -0,0 +1,46 @@
|
||||
function thenGetComments(parentId) {
|
||||
return $.getJSON(`/api/nodes/${parentId}/comments`);
|
||||
}
|
||||
|
||||
function thenCreateComment(parentId, msg, attachments) {
|
||||
let data = JSON.stringify({
|
||||
msg: msg,
|
||||
attachments: attachments
|
||||
});
|
||||
return $.ajax({
|
||||
url: `/api/nodes/${parentId}/comments`,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
contentType: 'application/json; charset=UTF-8'
|
||||
});
|
||||
}
|
||||
|
||||
function thenUpdateComment(parentId, commentId, msg, attachments) {
|
||||
let data = JSON.stringify({
|
||||
msg: msg,
|
||||
attachments: attachments
|
||||
});
|
||||
return $.ajax({
|
||||
url: `/api/nodes/${parentId}/comments/${commentId}`,
|
||||
type: 'PATCH',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
contentType: 'application/json; charset=UTF-8'
|
||||
});
|
||||
}
|
||||
|
||||
function thenVoteComment(parentId, commentId, vote) {
|
||||
let data = JSON.stringify({
|
||||
vote: vote
|
||||
});
|
||||
return $.ajax({
|
||||
url: `/api/nodes/${parentId}/comments/${commentId}/vote`,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
contentType: 'application/json; charset=UTF-8'
|
||||
});
|
||||
}
|
||||
|
||||
export { thenGetComments, thenCreateComment, thenUpdateComment, thenVoteComment }
|
Reference in New Issue
Block a user