[DE mobile] Comments (add check of appOptions: canComments, canViewComments, canEditComments)

This commit is contained in:
JuliaSvinareva 2020-04-09 20:51:04 +03:00
parent 61193b2f6a
commit 9dea0c8fae
8 changed files with 62 additions and 21 deletions

View file

@ -106,6 +106,9 @@ define([
setMode: function(mode) {
this.appConfig = mode;
this.view = this.getView('Common.Views.Collaboration');
this.view.viewmode = !mode.canComments;
this.view.canViewComments = mode.canViewComments;
_userId = mode.user.id;
if (editor === 'DE') {
_fileKey = mode.fileKey;
@ -822,7 +825,7 @@ define([
'<div class="toolbar toolbar-bottom" style="bottom: 0;">' +
'<div class="toolbar-inner">' +
'<div class="button-left">' +
'<a href="#" class="link add-reply">' + me.textAddReply + '</a>' +
(!me.view.viewmode ? '<a href="#" class="link add-reply">' + me.textAddReply + '</a>' : '') +
'</div>' +
'<div class="button-right">' +
'<a href="#" class="link prev-comment"><i class="icon icon-prev-comment"></i></a>' +
@ -856,7 +859,7 @@ define([
'<div class="toolbar toolbar-bottom" style="bottom: 0;">' +
'<div class="toolbar-inner">' +
'<div class="button-left">' +
'<a href="#" class="link add-reply">' + me.textAddReply + '</a>' +
(!me.view.viewmode ? '<a href="#" class="link add-reply">' + me.textAddReply + '</a>' : '') +
'</div>' +
'<div class="button-right">' +
'<a href="#" class="link prev-comment"><i class="icon icon-prev-comment"></i></a>' +
@ -1728,7 +1731,8 @@ define([
date : this.dateToLocaleTimeString(date),
reply : data.asc_getReply(i).asc_getText(),
time : date.getTime(),
userInitials : this.getInitials(username)
userInitials : this.getInitials(username),
editable : this.appConfig.canEditComments || (data.asc_getReply(i).asc_getUserId() == _userId)
});
}
}
@ -1754,7 +1758,8 @@ define([
time : date.getTime(),
replys : [],
groupName : (groupname && groupname.length>1) ? groupname[1] : null,
userInitials : this.getInitials(username)
userInitials : this.getInitials(username),
editable : this.appConfig.canEditComments || (data.asc_getUserId() == _userId)
};
if (comment) {
var replies = this.readSDKReplies(data);
@ -1809,7 +1814,8 @@ define([
date : me.dateToLocaleTimeString(dateReply),
reply : data.asc_getReply(i).asc_getText(),
time : dateReply.getTime(),
userInitials : me.getInitials(username)
userInitials : me.getInitials(username),
editable : me.appConfig.canEditComments || (data.asc_getUserId() == _userId)
});
}
comment.replys = replies;

View file

@ -20,7 +20,7 @@
</div>
</a>
</li>
<li>
<li id="item-comments">
<a id="comments-settings" class="item-link" data-page="#comments-view">
<div class="item-content">
<div class="item-inner">

View file

@ -116,6 +116,9 @@ define([
if (this.layout) {
var $layour = this.layout.find('#collaboration-root-view'),
isPhone = Common.SharedSettings.get('phone');
if (!this.canViewComments) {
$layour.find('#item-comments').remove();
}
return $layour.html();
}
@ -150,6 +153,7 @@ define([
renderViewComments: function(comments, indCurComment) {
var isAndroid = Framework7.prototype.device.android === true;
var me = this;
if ($('.view-comment .page-content').length > 0) {
var template = '';
if (comments && comments.length > 0) {
@ -168,11 +172,13 @@ define([
template += '</div>';
}
template += '</div>';
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>' +
'</div>';
if (comment.editable && !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 += '<p class="comment-quote" data-ind="' + comment.uid + '">' + comment.quote + '</p>';
template += '<div class="comment-text"><span>' + comment.comment + '</span></div>';
@ -191,8 +197,10 @@ define([
if (isAndroid) {
template += '</div>';
}
template += '<div class="reply-menu"><i class="icon icon-menu-comment"></i></div>' +
'</div>' +
if (reply.editable && !me.viewmode) {
template += '<div class="reply-menu"><i class="icon icon-menu-comment"></i></div>';
}
template += '</div>' +
'<p class="reply-text">' + reply.reply + '</p>' +
'</li>';
});
@ -209,6 +217,7 @@ define([
},
renderComments: function (comments) {
var me = this;
var $pageComments = $('.page-comments .page-content');
if (!comments) {
if ($('.comment').length > 0) {
@ -233,10 +242,12 @@ define([
'<p class="comment-date"><%= item.date %></p>',
'<% if (android) { %></div><% } %>',
'</div>',
'<% if (item.editable && !viewmode) { %>',
'<div class="comment-right">',
'<div class="comment-resolve"><i class="icon icon-resolve-comment <% if (item.resolved) { %> check <% } %>"></i></div>',
'<div class="comment-menu"><i class="icon icon-menu-comment"></i></div>',
'</div>',
'<% } %>',
'</div>',
'<% if(item.quote) {%>',
'<p class="comment-quote" data-id="<%= item.uid %>"><%= item.quote %></p>',
@ -253,7 +264,9 @@ define([
'<p class="reply-date"><%= reply.date %></p>',
'</div>',
'<% if (android) { %></div><% } %>',
'<% if (reply.editable && !viewmode) { %>',
'<div class="reply-menu"><i class="icon icon-menu-comment"></i></div>',
'<% } %>',
'</div>',
'<p class="reply-text"><%= reply.reply %></p>',
'</li>',
@ -267,6 +280,7 @@ define([
android: Framework7.prototype.device.android,
item: comment,
replys: comment.replys.length,
viewmode: me.viewmode
}));
});
$listComments.html(items.join(''));

View file

@ -62,7 +62,8 @@ define([
_inRevisionChange = false,
_isComments = false,
_menuPos = [],
_timer = 0;
_timer = 0,
_canViewComments = true;
return {
models: [],
@ -104,6 +105,7 @@ define([
setMode: function (mode) {
_isEdit = mode.isEdit;
_canReview = mode.canReview;
_canViewComments = mode.canViewComments;
},
// When our application is ready, lets get started
@ -434,6 +436,12 @@ define([
icon: 'icon-copy'
});
}
if (_canViewComments && _isComments && !_isEdit) {
arrItems.push({
caption: me.menuViewComment,
event: 'viewcomment'
});
}
var isText = false,
isTable = false,
@ -556,17 +564,19 @@ define([
}
}
if (_isComments) {
if (_isComments && _canViewComments) {
arrItems.push({
caption: me.menuViewComment,
event: 'viewcomment'
});
}
arrItems.push({
caption: me.menuAddComment,
event: 'addcomment'
});
if (_canViewComments) {
arrItems.push({
caption: me.menuAddComment,
event: 'addcomment'
});
}
}
}

View file

@ -762,7 +762,10 @@ define([
me.appOptions.canHistoryClose = me.editorConfig.canHistoryClose;
me.appOptions.canUseMailMerge = me.appOptions.canLicense && me.appOptions.canEdit && !me.appOptions.isDesktopApp;
me.appOptions.canSendEmailAddresses = me.appOptions.canLicense && me.editorConfig.canSendEmailAddresses && me.appOptions.canEdit && me.appOptions.canCoAuthoring;
me.appOptions.canComments = me.appOptions.canLicense && !((typeof (me.editorConfig.customization) == 'object') && me.editorConfig.customization.comments===false);
me.appOptions.canComments = me.appOptions.canLicense && (me.permissions.comment===undefined ? me.appOptions.isEdit : me.permissions.comment) && (me.editorConfig.mode !== 'view');
me.appOptions.canComments = me.appOptions.canComments && !((typeof (me.editorConfig.customization) == 'object') && me.editorConfig.customization.comments===false);
me.appOptions.canViewComments = me.appOptions.canComments || !((typeof (me.editorConfig.customization) == 'object') && me.editorConfig.customization.comments===false);
me.appOptions.canEditComments = me.appOptions.isOffline || !(typeof (me.editorConfig.customization) == 'object' && me.editorConfig.customization.commentAuthorOnly);
me.appOptions.canChat = me.appOptions.canLicense && !me.appOptions.isOffline && !((typeof (me.editorConfig.customization) == 'object') && me.editorConfig.customization.chat===false);
me.appOptions.canEditStyles = me.appOptions.canLicense && me.appOptions.canEdit;
me.appOptions.canPrint = (me.permissions.print !== false);

View file

@ -81,6 +81,11 @@ define([
me.api = api;
},
setMode: function (mode) {
this.view = this.getView('AddOther');
this.view.canViewComments = mode.canViewComments;
},
onLaunch: function () {
this.createView('AddOther').render();
},

View file

@ -2,7 +2,7 @@
<div id="addother-root-view">
<div class="list-block">
<ul>
<li>
<li id='item-comment'>
<a id="add-other-comment" class="item-link">
<div class="item-content">
<div class="item-media">

View file

@ -88,6 +88,9 @@ define([
rootLayout: function () {
if (this.layout) {
if (!this.canViewComments) {
this.layout.find('#addother-root-view #item-comment').remove();
}
return this.layout
.find('#addother-root-view')
.html();