mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-09-06 01:22:23 +00:00
#47 - Fixes a couple of issues found during testing - delete not updating the UI, delete none not working properly.
This commit is contained in:
parent
652a67ad65
commit
38fe756725
@ -747,7 +747,7 @@ module.exports = function (ngApp, events) {
|
|||||||
} else if (response.data) {
|
} else if (response.data) {
|
||||||
msg = response.data.message;
|
msg = response.data.message;
|
||||||
} else {
|
} else {
|
||||||
msg = trans('errors.comment_add_error');
|
msg = trans('errors.comment_add');
|
||||||
}
|
}
|
||||||
if (msg) {
|
if (msg) {
|
||||||
events.emit('success', msg);
|
events.emit('success', msg);
|
||||||
@ -761,15 +761,15 @@ module.exports = function (ngApp, events) {
|
|||||||
|
|
||||||
vm.delete = function(comment) {
|
vm.delete = function(comment) {
|
||||||
$http.delete(window.baseUrl(`/ajax/comment/${comment.id}`)).then(resp => {
|
$http.delete(window.baseUrl(`/ajax/comment/${comment.id}`)).then(resp => {
|
||||||
if (isCommentOpSuccess(resp)) {
|
if (!isCommentOpSuccess(resp)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
updateComment(comment, resp.data, $timeout, true);
|
updateComment(comment, resp.data, $timeout, true);
|
||||||
}, function (resp) {
|
}, function (resp) {
|
||||||
if (isCommentOpSuccess(resp)) {
|
if (isCommentOpSuccess(resp)) {
|
||||||
events.emit('success', trans('entities.comment_delete_success'));
|
events.emit('success', trans('entities.comment_deleted'));
|
||||||
} else {
|
} else {
|
||||||
events.emit('error', trans('entities.comment_delete_fail'));
|
events.emit('error', trans('error.comment_delete'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -794,17 +794,21 @@ module.exports = function (ngApp, events) {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
vm.canEdit = function (comment) {
|
vm.canEditDelete = function (comment, prop) {
|
||||||
if (!comment.active) {
|
if (!comment.active) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (vm.permissions.comment_update_all) {
|
let propAll = prop + '_all';
|
||||||
|
let propOwn = prop + '_own';
|
||||||
|
|
||||||
|
if (vm.permissions[propAll]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm.permissions.comment_update_own && comment.created_by.id === vm.current_user_id) {
|
if (vm.permissions[propOwn] && comment.created_by.id === vm.current_user_id) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -815,6 +819,9 @@ module.exports = function (ngApp, events) {
|
|||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$http.get(window.baseUrl(`/ajax/page/${$scope.pageId}/comments/`)).then(resp => {
|
$http.get(window.baseUrl(`/ajax/page/${$scope.pageId}/comments/`)).then(resp => {
|
||||||
if (!isCommentOpSuccess(resp)) {
|
if (!isCommentOpSuccess(resp)) {
|
||||||
|
// just show that no comments are available.
|
||||||
|
vm.totalComments = 0;
|
||||||
|
setTotalCommentMsg();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vm.comments = resp.data.comments;
|
vm.comments = resp.data.comments;
|
||||||
@ -845,7 +852,7 @@ module.exports = function (ngApp, events) {
|
|||||||
} else if (response.data) {
|
} else if (response.data) {
|
||||||
msg = response.data.message;
|
msg = response.data.message;
|
||||||
} else {
|
} else {
|
||||||
msg = trans('errors.comment_error');
|
msg = trans('errors.comment_list');
|
||||||
}
|
}
|
||||||
if (msg) {
|
if (msg) {
|
||||||
events.emit('success', msg);
|
events.emit('success', msg);
|
||||||
|
@ -61,9 +61,10 @@ return [
|
|||||||
'role_registration_default_cannot_delete' => 'This role cannot be deleted while set as the default registration role',
|
'role_registration_default_cannot_delete' => 'This role cannot be deleted while set as the default registration role',
|
||||||
|
|
||||||
// Comments
|
// Comments
|
||||||
'comment_error' => 'An error occurred while fetching the comments.',
|
'comment_list' => 'An error occurred while fetching the comments.',
|
||||||
'cannot_add_comment_to_draft' => 'You cannot add comments to a draft.',
|
'cannot_add_comment_to_draft' => 'You cannot add comments to a draft.',
|
||||||
'comment_add_error' => 'An error occurred while adding the comment.',
|
'comment_add' => 'An error occurred while adding the comment.',
|
||||||
|
'comment_delete' => 'An error occurred while deleting the comment.',
|
||||||
'empty_comment' => 'Cannot add an empty comment.',
|
'empty_comment' => 'Cannot add an empty comment.',
|
||||||
|
|
||||||
// Error pages
|
// Error pages
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
<div class="comment-actions">
|
<div class="comment-actions">
|
||||||
<ul ng-if="!comment.is_hidden">
|
<ul ng-if="!comment.is_hidden">
|
||||||
<li ng-if="::(level < 3 && vm.canComment())"><a href="#" comment-reply-link no-comment-reply-dupe="true" comment="comment" is-reply="true">{{ trans('entities.comment_reply') }}</a></li>
|
<li ng-if="::(level < 3 && vm.canComment())"><a href="#" comment-reply-link no-comment-reply-dupe="true" comment="comment" is-reply="true">{{ trans('entities.comment_reply') }}</a></li>
|
||||||
<li ng-if="::vm.canEdit(comment)"><a href="#" comment-reply-link no-comment-reply-dupe="true" comment="comment" >{{ trans('entities.comment_edit') }}</a></li>
|
<li ng-if="::vm.canEditDelete(comment, 'comment_update')"><a href="#" comment-reply-link no-comment-reply-dupe="true" comment="comment" >{{ trans('entities.comment_edit') }}</a></li>
|
||||||
<li ng-if="::vm.canEdit(comment, true)"><a href="#" comment-delete-link comment="comment" >{{ trans('entities.comment_delete') }}</a></li>
|
<li ng-if="::vm.canEditDelete(comment, 'comment_delete')"><a href="#" comment-delete-link comment="comment" >{{ trans('entities.comment_delete') }}</a></li>
|
||||||
<li>Created <a title="@{{::comment.created.day_time_str}}" href="#comment-@{{::comment.id}}-@{{::pageId}}">@{{::comment.created.diff}}</a></li>
|
<li>Created <a title="@{{::comment.created.day_time_str}}" href="#comment-@{{::comment.id}}-@{{::pageId}}">@{{::comment.created.diff}}</a></li>
|
||||||
<li ng-if="::comment.updated"><span title="@{{::comment.updated.day_time_str}}">@{{ ::vm.trans('entities.comment_updated_text', { updateDiff: comment.updated.diff }) }}
|
<li ng-if="::comment.updated"><span title="@{{::comment.updated.day_time_str}}">@{{ ::vm.trans('entities.comment_updated_text', { updateDiff: comment.updated.diff }) }}
|
||||||
<a href="@{{::comment.updated_by.profile_url}}">@{{::comment.updated_by.name}}</a></span></li>
|
<a href="@{{::comment.updated_by.profile_url}}">@{{::comment.updated_by.name}}</a></span></li>
|
||||||
|
Loading…
Reference in New Issue
Block a user