Use config permssions to view comments

This commit is contained in:
Julia Radzhabova 2021-03-17 20:08:47 +03:00
parent f35e929713
commit 8a3a74dc2d
4 changed files with 45 additions and 19 deletions

View file

@ -778,6 +778,7 @@ define([
comment.set('date', t.dateToLocaleTimeString(date)); 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('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('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')); replies = _.clone(comment.get('replys'));
@ -804,12 +805,17 @@ define([
showReplyInPopover : false, showReplyInPopover : false,
scope : t.view, 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()), 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); comment.set('replys', replies);
if (!this.popoverComments.findWhere({hide: false})) {
this.getPopover() && this.getPopover().hideComments();
}
if (!silentUpdate) { if (!silentUpdate) {
this.updateComments(false, true); this.updateComments(false, true);
@ -924,12 +930,15 @@ define([
}); });
this.popoverComments.reset(comments); this.popoverComments.reset(comments);
if (popover.isVisible()) { if (this.popoverComments.findWhere({hide: false})) {
popover.hide(); if (popover.isVisible()) {
} popover.hide();
}
popover.setLeftTop(posX, posY, leftX); popover.setLeftTop(posX, posY, leftX);
popover.showComments(animate, false, true, text); popover.showComments(animate, false, true, text);
} else
popover.hideComments();
} }
this.isModeChanged = false; this.isModeChanged = false;
}, },
@ -1007,9 +1016,12 @@ define([
}); });
this.popoverComments.reset(comments); this.popoverComments.reset(comments);
useAnimation = true; if (this.popoverComments.findWhere({hide: false})) {
this.getPopover().showComments(useAnimation, undefined, undefined, text); useAnimation = true;
} else if (!this.getPopover().isVisible()) { 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); this.getPopover().showComments(false, undefined, undefined, text);
} }
@ -1245,6 +1257,7 @@ define([
scope : this.view, scope : this.view,
editable : (this.mode.canEditComments || (data.asc_getUserId() == this.currentUserId)) && Common.Utils.UserInfoParser.canEditComment(data.asc_getUserName()), 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()), 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, hint : !this.mode.canComments,
groupName : (groupname && groupname.length>1) ? groupname[1] : null groupName : (groupname && groupname.length>1) ? groupname[1] : null
}); });
@ -1282,7 +1295,8 @@ define([
showReplyInPopover : false, showReplyInPopover : false,
scope : this.view, 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()), 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()) { if (this.getPopover().isVisible()) {
this.getPopover().hide(); this.getPopover().hide();
} }

View file

@ -98,7 +98,8 @@ define([
editTextInPopover : false, editTextInPopover : false,
scope : null, scope : null,
editable : true, editable : true,
removable : true removable : true,
hide : false
} }
}); });
}); });

View file

@ -22,9 +22,13 @@
<!-- replys elements --> <!-- replys elements -->
<% var add_arrow = true; %>
<% if (replys.length) { %> <% if (replys.length) { %>
<div class="reply-arrow img-commonctrl"></div>
<% _.each(replys, function (item, index) { %> <% _.each(replys, function (item, index) { %>
<% if (!item.get("hide")) { %>
<% if (add_arrow) { add_arrow = false; %>
<div class="reply-arrow img-commonctrl"></div>
<% } %>
<div class="reply-item-ct" <% if (scope.viewmode && index==replys.length-1) { %>style="padding-bottom: 0;" <% } %>;> <div class="reply-item-ct" <% if (scope.viewmode && index==replys.length-1) { %>style="padding-bottom: 0;" <% } %>;>
<div class="user-name"> <div class="user-name">
<div class="color" style="display: inline-block; background-color: <% if (item.get("usercolor")!==null) { %><%=item.get("usercolor")%><% } else { %> #cfcfcf <% } %>; " ></div><%= scope.getUserName(item.get("username")) %> <div class="color" style="display: inline-block; background-color: <% if (item.get("usercolor")!==null) { %><%=item.get("usercolor")%><% } else { %> #cfcfcf <% } %>; " ></div><%= scope.getUserName(item.get("username")) %>
@ -50,13 +54,14 @@
</div> </div>
<% } %> <% } %>
</div> </div>
<% } %>
<% }); %> <% }); %>
<% } %> <% } %>
<!-- add reply button --> <!-- add reply button -->
<% if (!showReply && !scope.viewmode) { %> <% if (!showReply && !scope.viewmode) { %>
<% if (replys.length) { %> <% if (replys.length && !add_arrow) { %>
<label class="user-reply" style="margin-left: 20px; margin-top: 5px;" role="presentation" tabindex="-1">textAddReply</label> <label class="user-reply" style="margin-left: 20px; margin-top: 5px;" role="presentation" tabindex="-1">textAddReply</label>
<% } else { %> <% } else { %>
<label class="user-reply" role="presentation" tabindex="-1">textAddReply</label> <label class="user-reply" role="presentation" tabindex="-1">textAddReply</label>

View file

@ -1,3 +1,4 @@
<% if (!hide) { %>
<div id="<%=id%>" class="user-comment-item"> <div id="<%=id%>" class="user-comment-item">
<!-- comment block --> <!-- comment block -->
@ -22,9 +23,13 @@
<!-- replys elements --> <!-- replys elements -->
<% var add_arrow = true; %>
<% if (replys.length) { %> <% if (replys.length) { %>
<div class="reply-arrow img-commonctrl"></div>
<% _.each(replys, function (item) { %> <% _.each(replys, function (item) { %>
<% if (!item.get("hide")) { %>
<% if (add_arrow) { add_arrow = false; %>
<div class="reply-arrow img-commonctrl"></div>
<% } %>
<div class="reply-item-ct"> <div class="reply-item-ct">
<div class="user-name"> <div class="user-name">
<div class="color" style="display: inline-block; background-color: <% if (item.get("usercolor")!==null) { %><%=item.get("usercolor")%><% } else { %> #cfcfcf <% } %>; " ></div><%= scope.getUserName(item.get("username")) %> <div class="color" style="display: inline-block; background-color: <% if (item.get("usercolor")!==null) { %><%=item.get("usercolor")%><% } else { %> #cfcfcf <% } %>; " ></div><%= scope.getUserName(item.get("username")) %>
@ -49,15 +54,15 @@
<button class="btn normal dlg-btn btn-inner-close">textClose</button> <button class="btn normal dlg-btn btn-inner-close">textClose</button>
</div> </div>
<% } %> <% } %>
</div> </div>
<% } %>
<% }); %> <% }); %>
<% } %> <% } %>
<!-- add reply button --> <!-- add reply button -->
<% if (!showReplyInPopover && !hideAddReply && !hint) { %> <% if (!showReplyInPopover && !hideAddReply && !hint) { %>
<% if (replys.length) { %> <% if (replys.length && !add_arrow) { %>
<label class="user-reply" style="margin-left: 20px; margin-top: 5px;" role="presentation" tabindex="-1">textAddReply</label> <label class="user-reply" style="margin-left: 20px; margin-top: 5px;" role="presentation" tabindex="-1">textAddReply</label>
<% } else { %> <% } else { %>
<label class="user-reply" role="presentation" tabindex="-1">textAddReply</label> <label class="user-reply" role="presentation" tabindex="-1">textAddReply</label>
@ -97,4 +102,5 @@
<div class="lock-author" style="cursor: default;"><%=lockuserid%></div> <div class="lock-author" style="cursor: default;"><%=lockuserid%></div>
<% } %> <% } %>
</div> </div>
<% } %>