- $scope.defaultAvatar = defaultAvatar;
- vm.totalCommentsStr = 'Loading...';
- $scope.editorChange = function (content) {
- console.log(content);
- }
+ // keep track of comment levels
+ $scope.level = 1;
+ vm.totalCommentsStr = trans('entities.comments_loading');
+ vm.permissions = {};
+ vm.trans = window.trans;
+
+ $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();
+ });
+
+ vm.canEditDelete = function (comment, prop) {
+ if (!comment.active) {
+ return false;
+ }
+ let propAll = prop + '_all';
+ let propOwn = prop + '_own';
+
+ if (vm.permissions[propAll]) {
+ return true;
+ }
+
+ if (vm.permissions[propOwn] && comment.created_by.id === vm.current_user_id) {
+ return true;
+ }
+
+ return false;
+ };
+
+ vm.canComment = function () {
+ return vm.permissions.comment_create;
+ };
+
+ // check if there are is any direct linking
+ let linkedCommentId = $location.search().cm;