diff --git a/app/Repos/CommentRepo.php b/app/Repos/CommentRepo.php index 55af0fe12..b8aa579c6 100644 --- a/app/Repos/CommentRepo.php +++ b/app/Repos/CommentRepo.php @@ -46,8 +46,8 @@ class CommentRepo { } public function delete($comment) { - $comment->text = trans('errors.cannot_add_comment_to_draft'); - $comment->html = trans('errors.cannot_add_comment_to_draft'); + $comment->text = trans('activities.comment_deleted'); + $comment->html = trans('activities.comment_deleted'); $comment->active = false; $userId = user()->id; $comment->updated_by = $userId; diff --git a/resources/assets/js/controllers.js b/resources/assets/js/controllers.js index 0a4e7b333..51f018232 100644 --- a/resources/assets/js/controllers.js +++ b/resources/assets/js/controllers.js @@ -777,12 +777,14 @@ module.exports = function (ngApp, events) { $scope.errors = {}; // keep track of comment levels $scope.level = 1; - vm.totalCommentsStr = 'Loading...'; + vm.totalCommentsStr = trans('entities.comments_loading'); vm.permissions = {}; $scope.$on('evt.new-comment', function (event, comment) { // add the comment to the comment list. vm.comments.push(comment); + ++vm.totalComments; + setTotalCommentMsg(); event.stopPropagation(); event.preventDefault(); }); @@ -812,21 +814,26 @@ module.exports = function (ngApp, events) { return; } vm.comments = resp.data.comments; - vm.totalComments = resp.data.total; + vm.totalComments = +resp.data.total; vm.permissions = resp.data.permissions; vm.current_user_id = resp.data.user_id; - - // TODO : Fetch message from translate. - if (vm.totalComments === 0) { - vm.totalCommentsStr = 'No comments found.'; - } else if (vm.totalComments === 1) { - vm.totalCommentsStr = '1 Comments'; - } else { - vm.totalCommentsStr = vm.totalComments + ' Comments'; - } + setTotalCommentMsg(); }, checkError('app')); }); + function setTotalCommentMsg () { + // TODO : Fetch message from translate. + if (vm.totalComments === 0) { + vm.totalCommentsStr = trans('entities.no_comments'); + } else if (vm.totalComments === 1) { + vm.totalCommentsStr = trans('entities.one_comment'); + } else { + vm.totalCommentsStr = trans('entities.x_comments', { + numComments: vm.totalComments + }); + } + } + function checkError(errorGroupName) { $scope.errors[errorGroupName] = {}; return function(response) { @@ -836,15 +843,12 @@ module.exports = function (ngApp, events) { }]); function updateComment(comment, resp, $timeout, isDelete) { - if (isDelete && !resp.comment.active) { - comment.html = trans('entities.comment_deleted'); - } comment.text = resp.comment.text; comment.updated = resp.comment.updated; comment.updated_by = resp.comment.updated_by; comment.active = resp.comment.active; if (isDelete && !resp.comment.active) { - comment.html = trans('entities.comment_deleted'); + comment.html = trans('activities.comment_deleted'); } else { comment.html = resp.comment.html; } diff --git a/resources/assets/sass/_comments.scss b/resources/assets/sass/_comments.scss index 0328341c3..5da53a14d 100644 --- a/resources/assets/sass/_comments.scss +++ b/resources/assets/sass/_comments.scss @@ -54,6 +54,12 @@ margin-bottom: 1em; } + .comment-inactive { + font-style: italic; + font-size: 0.85em; + padding-top: 5px; + } + .user-image { float: left; margin-right: 10px; diff --git a/resources/lang/en/activities.php b/resources/lang/en/activities.php index 56af4ca07..125326b33 100644 --- a/resources/lang/en/activities.php +++ b/resources/lang/en/activities.php @@ -37,4 +37,10 @@ return [ 'book_sort' => 'sorted book', 'book_sort_notification' => 'Book Successfully Re-sorted', + // Comments + 'comment_create_notification' => '', + 'comment_update_notification' => '', + 'comment_delete_notification' => '', + 'comment_deleted' => 'This comment has been deleted.' + ]; diff --git a/resources/lang/en/entities.php b/resources/lang/en/entities.php index 610309362..8480879d6 100644 --- a/resources/lang/en/entities.php +++ b/resources/lang/en/entities.php @@ -240,5 +240,9 @@ return [ */ 'comment' => 'Comment', 'comments' => 'Comments', - 'comment_placeholder' => 'Enter your comments here, markdown supported...' + 'comment_placeholder' => 'Enter your comments here, markdown supported...', + 'no_comments' => 'No Comments', + 'x_comments' => ':numComments Comments', + 'one_comment' => '1 Comment', + 'comments_loading' => 'Loading...' ]; \ No newline at end of file diff --git a/resources/views/comments/list-item.blade.php b/resources/views/comments/list-item.blade.php index 22cbb24c0..12629f0d6 100644 --- a/resources/views/comments/list-item.blade.php +++ b/resources/views/comments/list-item.blade.php @@ -6,11 +6,11 @@
@{{ ::comment.created_by.name }}
-
+
-
- {{ trans('entites.comment_deleted') }} +
+ {{ trans('activities.comment_deleted') }}