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