[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) { setMode: function(mode) {
this.appConfig = 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; _userId = mode.user.id;
if (editor === 'DE') { if (editor === 'DE') {
_fileKey = mode.fileKey; _fileKey = mode.fileKey;
@ -822,7 +825,7 @@ define([
'<div class="toolbar toolbar-bottom" style="bottom: 0;">' + '<div class="toolbar toolbar-bottom" style="bottom: 0;">' +
'<div class="toolbar-inner">' + '<div class="toolbar-inner">' +
'<div class="button-left">' + '<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>' +
'<div class="button-right">' + '<div class="button-right">' +
'<a href="#" class="link prev-comment"><i class="icon icon-prev-comment"></i></a>' + '<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 toolbar-bottom" style="bottom: 0;">' +
'<div class="toolbar-inner">' + '<div class="toolbar-inner">' +
'<div class="button-left">' + '<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>' +
'<div class="button-right">' + '<div class="button-right">' +
'<a href="#" class="link prev-comment"><i class="icon icon-prev-comment"></i></a>' + '<a href="#" class="link prev-comment"><i class="icon icon-prev-comment"></i></a>' +
@ -1728,7 +1731,8 @@ define([
date : this.dateToLocaleTimeString(date), date : this.dateToLocaleTimeString(date),
reply : data.asc_getReply(i).asc_getText(), reply : data.asc_getReply(i).asc_getText(),
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)
}); });
} }
} }
@ -1754,7 +1758,8 @@ define([
time : date.getTime(), time : date.getTime(),
replys : [], replys : [],
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)
}; };
if (comment) { if (comment) {
var replies = this.readSDKReplies(data); var replies = this.readSDKReplies(data);
@ -1809,7 +1814,8 @@ define([
date : me.dateToLocaleTimeString(dateReply), date : me.dateToLocaleTimeString(dateReply),
reply : data.asc_getReply(i).asc_getText(), reply : data.asc_getReply(i).asc_getText(),
time : dateReply.getTime(), time : dateReply.getTime(),
userInitials : me.getInitials(username) userInitials : me.getInitials(username),
editable : me.appConfig.canEditComments || (data.asc_getUserId() == _userId)
}); });
} }
comment.replys = replies; comment.replys = replies;

View file

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

View file

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

View file

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

View file

@ -762,7 +762,10 @@ define([
me.appOptions.canHistoryClose = me.editorConfig.canHistoryClose; me.appOptions.canHistoryClose = me.editorConfig.canHistoryClose;
me.appOptions.canUseMailMerge = me.appOptions.canLicense && me.appOptions.canEdit && !me.appOptions.isDesktopApp; 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.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.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.canEditStyles = me.appOptions.canLicense && me.appOptions.canEdit;
me.appOptions.canPrint = (me.permissions.print !== false); me.appOptions.canPrint = (me.permissions.print !== false);

View file

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

View file

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

View file

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