* 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
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
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 } |