[Mobile] Use config permssions to view comments
This commit is contained in:
parent
8a3a74dc2d
commit
916c911ac7
|
@ -791,6 +791,16 @@ define([
|
|||
return comment;
|
||||
},
|
||||
|
||||
findVisibleComment: function(uid) {
|
||||
var comment;
|
||||
if (this.groupCollectionFilter.length !== 0) {
|
||||
comment = this.findVisibleCommentInGroup(uid);
|
||||
} else if (this.collectionComments.length !== 0) {
|
||||
comment = _.findWhere(this.collectionComments, {uid: uid, hide: false});
|
||||
}
|
||||
return comment;
|
||||
},
|
||||
|
||||
apiShowComments: function(uid) {
|
||||
var comments,
|
||||
me = this;
|
||||
|
@ -988,12 +998,15 @@ define([
|
|||
|
||||
onViewPrevComment: function() {
|
||||
if (this.showComments && this.showComments.length > 0) {
|
||||
if (this.indexCurrentComment - 1 < 0) {
|
||||
this.indexCurrentComment = this.showComments.length - 1;
|
||||
} else {
|
||||
this.indexCurrentComment -= 1;
|
||||
for (var i=0; i<this.showComments.length; i++) {
|
||||
if (this.indexCurrentComment - 1 < 0) {
|
||||
this.indexCurrentComment = this.showComments.length - 1;
|
||||
} else {
|
||||
this.indexCurrentComment -= 1;
|
||||
}
|
||||
if (this.view.renderViewComments(this.showComments, this.indexCurrentComment))
|
||||
break;
|
||||
}
|
||||
this.view.renderViewComments(this.showComments, this.indexCurrentComment);
|
||||
var me = this;
|
||||
_.defer(function () {
|
||||
$('.comment-menu').single('click', _.buffered(me.initMenuComments, 100, me));
|
||||
|
@ -1005,12 +1018,15 @@ define([
|
|||
|
||||
onViewNextComment: function() {
|
||||
if (this.showComments && this.showComments.length > 0) {
|
||||
if (this.indexCurrentComment + 1 === this.showComments.length) {
|
||||
this.indexCurrentComment = 0;
|
||||
} else {
|
||||
this.indexCurrentComment += 1;
|
||||
for (var i=0; i<this.showComments.length; i++) {
|
||||
if (this.indexCurrentComment + 1 === this.showComments.length) {
|
||||
this.indexCurrentComment = 0;
|
||||
} else {
|
||||
this.indexCurrentComment += 1;
|
||||
}
|
||||
if (this.view.renderViewComments(this.showComments, this.indexCurrentComment))
|
||||
break;
|
||||
}
|
||||
this.view.renderViewComments(this.showComments, this.indexCurrentComment);
|
||||
var me = this;
|
||||
_.defer(function () {
|
||||
$('.comment-menu').single('click', _.buffered(me.initMenuComments, 100, me));
|
||||
|
@ -1543,7 +1559,8 @@ define([
|
|||
time : date.getTime(),
|
||||
userInitials : this.getInitials(username),
|
||||
editable : (this.appConfig.canEditComments || (data.asc_getReply(i).asc_getUserId() == _userId)) && Common.Utils.UserInfoParser.canEditComment(username),
|
||||
removable : (this.appConfig.canDeleteComments || (data.asc_getReply(i).asc_getUserId() == _userId)) && Common.Utils.UserInfoParser.canDeleteComment(username)
|
||||
removable : (this.appConfig.canDeleteComments || (data.asc_getReply(i).asc_getUserId() == _userId)) && Common.Utils.UserInfoParser.canDeleteComment(username),
|
||||
hide : !Common.Utils.UserInfoParser.canViewComment(data.asc_getReply(i).asc_getUserName())
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1573,7 +1590,8 @@ define([
|
|||
groupName : (groupname && groupname.length>1) ? groupname[1] : null,
|
||||
userInitials : this.getInitials(username),
|
||||
editable : (this.appConfig.canEditComments || (data.asc_getUserId() == _userId)) && Common.Utils.UserInfoParser.canEditComment(username),
|
||||
removable : (this.appConfig.canDeleteComments || (data.asc_getUserId() == _userId)) && Common.Utils.UserInfoParser.canDeleteComment(username)
|
||||
removable : (this.appConfig.canDeleteComments || (data.asc_getUserId() == _userId)) && Common.Utils.UserInfoParser.canDeleteComment(username),
|
||||
hide : !Common.Utils.UserInfoParser.canViewComment(username)
|
||||
};
|
||||
if (comment) {
|
||||
var replies = this.readSDKReplies(data);
|
||||
|
@ -1611,6 +1629,7 @@ define([
|
|||
comment.date = me.dateToLocaleTimeString(date);
|
||||
comment.editable = (me.appConfig.canEditComments || (data.asc_getUserId() == _userId)) && Common.Utils.UserInfoParser.canEditComment(data.asc_getUserName());
|
||||
comment.removable = (me.appConfig.canDeleteComments || (data.asc_getUserId() == _userId)) && Common.Utils.UserInfoParser.canDeleteComment(data.asc_getUserName());
|
||||
comment.hide = !Common.Utils.UserInfoParser.canViewComment(data.asc_getUserName());
|
||||
|
||||
replies = _.clone(comment.replys);
|
||||
|
||||
|
@ -1636,7 +1655,8 @@ define([
|
|||
time : dateReply.getTime(),
|
||||
userInitials : me.getInitials(username),
|
||||
editable : (me.appConfig.canEditComments || (data.asc_getReply(i).asc_getUserId() == _userId)) && Common.Utils.UserInfoParser.canEditComment(username),
|
||||
removable : (me.appConfig.canDeleteComments || (data.asc_getReply(i).asc_getUserId() == _userId)) && Common.Utils.UserInfoParser.canDeleteComment(username)
|
||||
removable : (me.appConfig.canDeleteComments || (data.asc_getReply(i).asc_getUserId() == _userId)) && Common.Utils.UserInfoParser.canDeleteComment(username),
|
||||
hide : !Common.Utils.UserInfoParser.canViewComment(username)
|
||||
});
|
||||
}
|
||||
comment.replys = replies;
|
||||
|
@ -1708,6 +1728,15 @@ define([
|
|||
}
|
||||
},
|
||||
|
||||
findVisibleCommentInGroup: function (id) {
|
||||
for (var name in this.groupCollectionComments) {
|
||||
var store = this.groupCollectionComments[name];
|
||||
var id = _.isArray(id) ? id[0] : id;
|
||||
var model = _.findWhere(store, {uid: id, hide: false});
|
||||
if (model) return model;
|
||||
}
|
||||
},
|
||||
|
||||
onApiRemoveComment: function (id, silentUpdate) {
|
||||
function remove (collection, key) {
|
||||
if(collection instanceof Array) {
|
||||
|
|
|
@ -165,66 +165,73 @@ define([
|
|||
renderViewComments: function(comments, indCurComment) {
|
||||
var isAndroid = Framework7.prototype.device.android === true;
|
||||
var me = this;
|
||||
var res = false;
|
||||
if ($('.page-view-comments .page-content').length > 0) {
|
||||
var template = '';
|
||||
if (comments && comments.length > 0) {
|
||||
template = '<div class="list-block">' +
|
||||
'<ul id="comments-list">';
|
||||
var comment = comments[indCurComment];
|
||||
template += '<li class="comment item-content" data-uid="' + comment.uid + '">' +
|
||||
'<div class="item-inner">' +
|
||||
'<div class="header-comment"><div class="comment-left">';
|
||||
if (isAndroid) {
|
||||
template += '<div class="initials-comment" style="background-color: ' + (comment.usercolor ? comment.usercolor : '#cfcfcf') + ';">' + comment.userInitials + '</div><div>';
|
||||
}
|
||||
template += '<div class="user-name">' + me.getUserName(comment.username) + '</div>' +
|
||||
'<div class="comment-date">' + comment.date + '</div>';
|
||||
if (isAndroid) {
|
||||
res = !comment.hide;
|
||||
if (res) {
|
||||
template = '<div class="list-block">' +
|
||||
'<ul id="comments-list">';
|
||||
template += '<li class="comment item-content" data-uid="' + comment.uid + '">' +
|
||||
'<div class="item-inner">' +
|
||||
'<div class="header-comment"><div class="comment-left">';
|
||||
if (isAndroid) {
|
||||
template += '<div class="initials-comment" style="background-color: ' + (comment.usercolor ? comment.usercolor : '#cfcfcf') + ';">' + comment.userInitials + '</div><div>';
|
||||
}
|
||||
template += '<div class="user-name">' + me.getUserName(comment.username) + '</div>' +
|
||||
'<div class="comment-date">' + comment.date + '</div>';
|
||||
if (isAndroid) {
|
||||
template += '</div>';
|
||||
}
|
||||
template += '</div>';
|
||||
}
|
||||
template += '</div>';
|
||||
if (!me.viewmode) {
|
||||
template += '<div class="comment-right">' +
|
||||
'<div class="comment-resolve"><i class="icon icon-resolve-comment' + (comment.resolved ? ' check' : '') + '"></i></div>' +
|
||||
'<div class="comment-menu"><i class="icon icon-menu-comment"></i></div>' +
|
||||
'</div>';
|
||||
}
|
||||
template += '</div>';
|
||||
|
||||
if (comment.quote) template += '<div class="comment-quote" data-ind="' + comment.uid + '">' + me.sliceQuote(comment.quote) + '</div>';
|
||||
template += '<div class="comment-text"><pre>' + comment.comment + '</pre></div>';
|
||||
if (comment.replys.length > 0) {
|
||||
template += '<ul class="list-reply">';
|
||||
_.each(comment.replys, function (reply) {
|
||||
template += '<li class="reply-item" data-ind="' + reply.ind + '">' +
|
||||
'<div class="header-reply">' +
|
||||
'<div class="reply-left">';
|
||||
if (isAndroid) {
|
||||
template += '<div class="initials-reply" style="background-color: ' + (reply.usercolor ? reply.usercolor : '#cfcfcf') + ';">' + reply.userInitials + '</div><div>'
|
||||
}
|
||||
template += '<div class="user-name">' + me.getUserName(reply.username) + '</div>' +
|
||||
'<div class="reply-date">' + reply.date + '</div>' +
|
||||
if (!me.viewmode) {
|
||||
template += '<div class="comment-right">' +
|
||||
'<div class="comment-resolve"><i class="icon icon-resolve-comment' + (comment.resolved ? ' check' : '') + '"></i></div>' +
|
||||
'<div class="comment-menu"><i class="icon icon-menu-comment"></i></div>' +
|
||||
'</div>';
|
||||
if (isAndroid) {
|
||||
template += '</div>';
|
||||
}
|
||||
if ((reply.editable || reply.removable) && !me.viewmode) {
|
||||
template += '<div class="reply-menu"><i class="icon icon-menu-comment"></i></div>';
|
||||
}
|
||||
template += '</div>' +
|
||||
'<div class="reply-text"><pre>' + reply.reply + '</pre></div>' +
|
||||
'</li>';
|
||||
});
|
||||
template += '</ul>'
|
||||
}
|
||||
}
|
||||
template += '</div>';
|
||||
|
||||
template += '</div>' +
|
||||
'</li>';
|
||||
template += '</ul></div>';
|
||||
$('.page-view-comments .page-content').html(template);
|
||||
if (comment.quote) template += '<div class="comment-quote" data-ind="' + comment.uid + '">' + me.sliceQuote(comment.quote) + '</div>';
|
||||
template += '<div class="comment-text"><pre>' + comment.comment + '</pre></div>';
|
||||
if (comment.replys.length > 0) {
|
||||
template += '<ul class="list-reply">';
|
||||
_.each(comment.replys, function (reply) {
|
||||
if (!reply.hide) {
|
||||
template += '<li class="reply-item" data-ind="' + reply.ind + '">' +
|
||||
'<div class="header-reply">' +
|
||||
'<div class="reply-left">';
|
||||
if (isAndroid) {
|
||||
template += '<div class="initials-reply" style="background-color: ' + (reply.usercolor ? reply.usercolor : '#cfcfcf') + ';">' + reply.userInitials + '</div><div>'
|
||||
}
|
||||
template += '<div class="user-name">' + me.getUserName(reply.username) + '</div>' +
|
||||
'<div class="reply-date">' + reply.date + '</div>' +
|
||||
'</div>';
|
||||
if (isAndroid) {
|
||||
template += '</div>';
|
||||
}
|
||||
if ((reply.editable || reply.removable) && !me.viewmode) {
|
||||
template += '<div class="reply-menu"><i class="icon icon-menu-comment"></i></div>';
|
||||
}
|
||||
template += '</div>' +
|
||||
'<div class="reply-text"><pre>' + reply.reply + '</pre></div>' +
|
||||
'</li>';
|
||||
}
|
||||
});
|
||||
template += '</ul>'
|
||||
}
|
||||
|
||||
template += '</div>' +
|
||||
'</li>';
|
||||
template += '</ul></div>';
|
||||
$('.page-view-comments .page-content').html(template);
|
||||
}
|
||||
}
|
||||
}
|
||||
Common.Utils.addScrollIfNeed('.page-view-comments.page', '.page-view-comments .page-content');
|
||||
return res;
|
||||
},
|
||||
|
||||
renderComments: function (comments) {
|
||||
|
@ -245,6 +252,7 @@ define([
|
|||
items = [];
|
||||
_.each(sortComments, function (comment) {
|
||||
var itemTemplate = [
|
||||
'<% if (!item.hide) { %>',
|
||||
'<li class="comment item-content" data-uid="<%= item.uid %>">',
|
||||
'<div class="item-inner">',
|
||||
'<div class="header-comment"><div class="comment-left">',
|
||||
|
@ -267,6 +275,7 @@ define([
|
|||
'<% if(replys > 0) {%>',
|
||||
'<ul class="list-reply">',
|
||||
'<% _.each(item.replys, function (reply) { %>',
|
||||
'<% if (!reply.hide) { %>',
|
||||
'<li class="reply-item" data-ind="<%= reply.ind %>">',
|
||||
'<div class="header-reply">',
|
||||
'<div class="reply-left">',
|
||||
|
@ -281,11 +290,13 @@ define([
|
|||
'</div>',
|
||||
'<div class="reply-text"><pre><%= reply.reply %></pre></div>',
|
||||
'</li>',
|
||||
'<% } %>',
|
||||
'<% }); %>',
|
||||
'</ul>',
|
||||
'<% } %>',
|
||||
'</div>',
|
||||
'</li>'
|
||||
'</li>',
|
||||
'<% } %>'
|
||||
].join('');
|
||||
items.push(_.template(itemTemplate)({
|
||||
android: Framework7.prototype.device.android,
|
||||
|
|
|
@ -454,7 +454,15 @@ define([
|
|||
},
|
||||
|
||||
onApiShowComment: function(comments) {
|
||||
_isComments = comments && comments.length>0;
|
||||
_isComments = false;
|
||||
if (comments && comments.length > 0) {
|
||||
for (var i = 0; i < comments.length; ++i) {
|
||||
if (this.getApplication().getController('Common.Controllers.Collaboration').findVisibleComment(comments[i])) {
|
||||
_isComments = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onApiHideComment: function() {
|
||||
|
|
|
@ -90,7 +90,15 @@ define([
|
|||
},
|
||||
|
||||
onApiShowComment: function(comments) {
|
||||
_isComments = comments && comments.length>0;
|
||||
_isComments = false;
|
||||
if (comments && comments.length > 0) {
|
||||
for (var i = 0; i < comments.length; ++i) {
|
||||
if (this.getApplication().getController('Common.Controllers.Collaboration').findVisibleComment(comments[i])) {
|
||||
_isComments = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onApiHideComment: function() {
|
||||
|
|
|
@ -54,7 +54,8 @@ define([
|
|||
var _actionSheets = [],
|
||||
_isEdit = false,
|
||||
_canViewComments = true,
|
||||
_isComments = false;
|
||||
_isComments = false,
|
||||
_isVisibleComments = false;
|
||||
|
||||
function openLink(url) {
|
||||
var newDocumentPage = window.open(url, '_blank');
|
||||
|
@ -321,8 +322,18 @@ define([
|
|||
var iscellmenu, isrowmenu, iscolmenu, isallmenu, ischartmenu, isimagemenu, istextshapemenu, isshapemenu, istextchartmenu;
|
||||
var iscelllocked = cellinfo.asc_getLocked(),
|
||||
seltype = cellinfo.asc_getSelectionType(),
|
||||
xfs = cellinfo.asc_getXfs();
|
||||
_isComments = cellinfo.asc_getComments().length>0; //prohibit adding multiple comments in one cell;
|
||||
xfs = cellinfo.asc_getXfs(),
|
||||
comments = cellinfo.asc_getComments();
|
||||
_isComments = comments.length>0; //prohibit adding multiple comments in one cell;
|
||||
_isVisibleComments = false;
|
||||
if (comments && comments.length > 0) {
|
||||
for (var i = 0; i < comments.length; ++i) {
|
||||
if (me.getApplication().getController('Common.Controllers.Collaboration').findVisibleComment(comments[i].asc_getId())) {
|
||||
_isVisibleComments = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (seltype) {
|
||||
case Asc.c_oAscSelectionType.RangeCells: iscellmenu = true; break;
|
||||
|
@ -350,7 +361,7 @@ define([
|
|||
event: 'openlink'
|
||||
});
|
||||
}
|
||||
if (_canViewComments && _isComments) {
|
||||
if (_canViewComments && _isVisibleComments) {
|
||||
arrItems.push({
|
||||
caption: me.menuViewComment,
|
||||
event: 'viewcomment'
|
||||
|
@ -463,12 +474,12 @@ define([
|
|||
}
|
||||
|
||||
if (_canViewComments) {
|
||||
if (_isComments) {
|
||||
if (_isVisibleComments) {
|
||||
arrItems.push({
|
||||
caption: me.menuViewComment,
|
||||
event: 'viewcomment'
|
||||
});
|
||||
} else if (iscellmenu) {
|
||||
} else if (iscellmenu && !_isComments) {
|
||||
arrItems.push({
|
||||
caption: me.menuAddComment,
|
||||
event: 'addcomment'
|
||||
|
|
Loading…
Reference in a new issue