Actually update comments in the backend
This commit is contained in:
@ -262,6 +262,24 @@ also, all settings from the rails model needed for the editor configuration in t
|
|||||||
jqxhr.fail(ajaxError);
|
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){
|
function createComment(file_id, row, editor, commenttext){
|
||||||
cleanupPopovers();
|
cleanupPopovers();
|
||||||
var jqxhr = $.ajax({
|
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 deleteButton = parent.find('.action-delete');
|
||||||
var commentContent = parent.find('.comment-content');
|
var commentContent = parent.find('.comment-content');
|
||||||
var commentEditor = parent.find('textarea.comment-editor');
|
var commentEditor = parent.find('textarea.comment-editor');
|
||||||
|
var commentUpdated = parent.find('.comment-updated');
|
||||||
|
|
||||||
if (currentlyEditing) {
|
if (currentlyEditing) {
|
||||||
button.text('<%= t('shared.edit') %>');
|
updateComment(commentId, commentEditor.val(), editor, fileid, function () {
|
||||||
button.data('editing', false);
|
button.text('<%= t('shared.edit') %>');
|
||||||
deleteButton.show();
|
button.data('editing', false);
|
||||||
commentContent.show();
|
commentContent.text(commentEditor.val());
|
||||||
commentEditor.hide();
|
deleteButton.show();
|
||||||
|
commentContent.show();
|
||||||
|
commentEditor.hide();
|
||||||
|
commentUpdated.removeClass('hidden');
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
button.text('<%= t('comments.save_update') %>');
|
button.text('<%= t('comments.save_update') %>');
|
||||||
button.data('editing', true);
|
button.data('editing', true);
|
||||||
|
Reference in New Issue
Block a user