Actually update comments in the backend

This commit is contained in:
Maximilian Grundke
2017-08-31 17:42:20 +02:00
parent 17fb22b9df
commit 00e727a325

View File

@ -262,6 +262,24 @@ also, all settings from the rails model needed for the editor configuration in t
jqxhr.fail(ajaxError);
}
function updateComment(commentId, text, editor, file_id, callback) {
cleanupPopovers();
var jqxhr = $.ajax({
type: 'PATCH',
url: "/comments/" + commentId,
data: {
comment: {
text: text
}
}
});
jqxhr.done(function () {
setAnnotations(editor, file_id);
callback();
});
jqxhr.fail(ajaxError);
}
function createComment(file_id, row, editor, commenttext){
cleanupPopovers();
var jqxhr = $.ajax({
@ -324,13 +342,18 @@ also, all settings from the rails model needed for the editor configuration in t
var deleteButton = parent.find('.action-delete');
var commentContent = parent.find('.comment-content');
var commentEditor = parent.find('textarea.comment-editor');
var commentUpdated = parent.find('.comment-updated');
if (currentlyEditing) {
updateComment(commentId, commentEditor.val(), editor, fileid, function () {
button.text('<%= t('shared.edit') %>');
button.data('editing', false);
commentContent.text(commentEditor.val());
deleteButton.show();
commentContent.show();
commentEditor.hide();
commentUpdated.removeClass('hidden');
});
} else {
button.text('<%= t('comments.save_update') %>');
button.data('editing', true);