From 8a3a74dc2d7b3cea1378c11d28af5be6a1cf75cb Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 17 Mar 2021 20:08:47 +0300 Subject: [PATCH] Use config permssions to view comments --- apps/common/main/lib/controller/Comments.js | 36 +++++++++++++------ apps/common/main/lib/model/Comment.js | 3 +- .../main/lib/template/Comments.template | 9 +++-- .../lib/template/CommentsPopover.template | 16 ++++++--- 4 files changed, 45 insertions(+), 19 deletions(-) diff --git a/apps/common/main/lib/controller/Comments.js b/apps/common/main/lib/controller/Comments.js index 1f32e1139..d6b3e56ee 100644 --- a/apps/common/main/lib/controller/Comments.js +++ b/apps/common/main/lib/controller/Comments.js @@ -778,6 +778,7 @@ define([ comment.set('date', t.dateToLocaleTimeString(date)); comment.set('editable', (t.mode.canEditComments || (data.asc_getUserId() == t.currentUserId)) && Common.Utils.UserInfoParser.canEditComment(data.asc_getUserName())); comment.set('removable', (t.mode.canDeleteComments || (data.asc_getUserId() == t.currentUserId)) && Common.Utils.UserInfoParser.canDeleteComment(data.asc_getUserName())); + comment.set('hide', !Common.Utils.UserInfoParser.canViewComment(data.asc_getUserName())); replies = _.clone(comment.get('replys')); @@ -804,12 +805,17 @@ define([ showReplyInPopover : false, scope : t.view, editable : (t.mode.canEditComments || (data.asc_getReply(i).asc_getUserId() == t.currentUserId)) && Common.Utils.UserInfoParser.canEditComment(data.asc_getReply(i).asc_getUserName()), - removable : (t.mode.canDeleteComments || (data.asc_getReply(i).asc_getUserId() == t.currentUserId)) && Common.Utils.UserInfoParser.canDeleteComment(data.asc_getReply(i).asc_getUserName()) + removable : (t.mode.canDeleteComments || (data.asc_getReply(i).asc_getUserId() == t.currentUserId)) && Common.Utils.UserInfoParser.canDeleteComment(data.asc_getReply(i).asc_getUserName()), + hide : !Common.Utils.UserInfoParser.canViewComment(data.asc_getReply(i).asc_getUserName()) })); } comment.set('replys', replies); + if (!this.popoverComments.findWhere({hide: false})) { + this.getPopover() && this.getPopover().hideComments(); + } + if (!silentUpdate) { this.updateComments(false, true); @@ -924,12 +930,15 @@ define([ }); this.popoverComments.reset(comments); - if (popover.isVisible()) { - popover.hide(); - } + if (this.popoverComments.findWhere({hide: false})) { + if (popover.isVisible()) { + popover.hide(); + } - popover.setLeftTop(posX, posY, leftX); - popover.showComments(animate, false, true, text); + popover.setLeftTop(posX, posY, leftX); + popover.showComments(animate, false, true, text); + } else + popover.hideComments(); } this.isModeChanged = false; }, @@ -1007,9 +1016,12 @@ define([ }); this.popoverComments.reset(comments); - useAnimation = true; - this.getPopover().showComments(useAnimation, undefined, undefined, text); - } else if (!this.getPopover().isVisible()) { + if (this.popoverComments.findWhere({hide: false})) { + useAnimation = true; + this.getPopover().showComments(useAnimation, undefined, undefined, text); + } else + this.getPopover().hideComments(); + } else if (!this.getPopover().isVisible() && this.popoverComments.findWhere({hide: false})) { this.getPopover().showComments(false, undefined, undefined, text); } @@ -1245,6 +1257,7 @@ define([ scope : this.view, editable : (this.mode.canEditComments || (data.asc_getUserId() == this.currentUserId)) && Common.Utils.UserInfoParser.canEditComment(data.asc_getUserName()), removable : (this.mode.canDeleteComments || (data.asc_getUserId() == this.currentUserId)) && Common.Utils.UserInfoParser.canDeleteComment(data.asc_getUserName()), + hide : !Common.Utils.UserInfoParser.canViewComment(data.asc_getUserName()), hint : !this.mode.canComments, groupName : (groupname && groupname.length>1) ? groupname[1] : null }); @@ -1282,7 +1295,8 @@ define([ showReplyInPopover : false, scope : this.view, editable : (this.mode.canEditComments || (data.asc_getReply(i).asc_getUserId() == this.currentUserId)) && Common.Utils.UserInfoParser.canEditComment(data.asc_getReply(i).asc_getUserName()), - removable : (this.mode.canDeleteComments || (data.asc_getReply(i).asc_getUserId() == this.currentUserId)) && Common.Utils.UserInfoParser.canDeleteComment(data.asc_getReply(i).asc_getUserName()) + removable : (this.mode.canDeleteComments || (data.asc_getReply(i).asc_getUserId() == this.currentUserId)) && Common.Utils.UserInfoParser.canDeleteComment(data.asc_getReply(i).asc_getUserName()), + hide : !Common.Utils.UserInfoParser.canViewComment(data.asc_getReply(i).asc_getUserName()) })); } } @@ -1449,7 +1463,7 @@ define([ } } - if (this.getPopover() && this.popoverComments.length>0) { + if (this.getPopover() && this.popoverComments.length>0 && this.popoverComments.findWhere({hide: false})) { if (this.getPopover().isVisible()) { this.getPopover().hide(); } diff --git a/apps/common/main/lib/model/Comment.js b/apps/common/main/lib/model/Comment.js index 80c8667ba..e58713cfd 100644 --- a/apps/common/main/lib/model/Comment.js +++ b/apps/common/main/lib/model/Comment.js @@ -98,7 +98,8 @@ define([ editTextInPopover : false, scope : null, editable : true, - removable : true + removable : true, + hide : false } }); }); diff --git a/apps/common/main/lib/template/Comments.template b/apps/common/main/lib/template/Comments.template index 82a1e531b..4d587d722 100644 --- a/apps/common/main/lib/template/Comments.template +++ b/apps/common/main/lib/template/Comments.template @@ -22,9 +22,13 @@ + <% var add_arrow = true; %> <% if (replys.length) { %> -
<% _.each(replys, function (item, index) { %> + <% if (!item.get("hide")) { %> + <% if (add_arrow) { add_arrow = false; %> +
+ <% } %>
style="padding-bottom: 0;" <% } %>;>
<%=item.get("usercolor")%><% } else { %> #cfcfcf <% } %>; " >
<%= scope.getUserName(item.get("username")) %> @@ -50,13 +54,14 @@
<% } %>
+ <% } %> <% }); %> <% } %> <% if (!showReply && !scope.viewmode) { %> - <% if (replys.length) { %> + <% if (replys.length && !add_arrow) { %> <% } else { %> diff --git a/apps/common/main/lib/template/CommentsPopover.template b/apps/common/main/lib/template/CommentsPopover.template index 9bd905834..5f4c5911d 100644 --- a/apps/common/main/lib/template/CommentsPopover.template +++ b/apps/common/main/lib/template/CommentsPopover.template @@ -1,3 +1,4 @@ +<% if (!hide) { %>
@@ -22,9 +23,13 @@ + <% var add_arrow = true; %> <% if (replys.length) { %> -
<% _.each(replys, function (item) { %> + <% if (!item.get("hide")) { %> + <% if (add_arrow) { add_arrow = false; %> +
+ <% } %>
<%=item.get("usercolor")%><% } else { %> #cfcfcf <% } %>; " >
<%= scope.getUserName(item.get("username")) %> @@ -49,15 +54,15 @@
<% } %> -
+
+ <% } %> <% }); %> - <% } %> <% if (!showReplyInPopover && !hideAddReply && !hint) { %> - <% if (replys.length) { %> + <% if (replys.length && !add_arrow) { %> <% } else { %> @@ -97,4 +102,5 @@
<%=lockuserid%>
<% } %> - \ No newline at end of file + +<% } %> \ No newline at end of file