Add new parameters to "permissions" section of config: editCommentAuthorOnly (can edit your own comments only if true), deleteCommentAuthorOnly (can delete your own comments only if true).

Deprecate customization.commentAuthorOnly parameter.
This commit is contained in:
Julia Radzhabova 2021-02-04 12:39:56 +03:00
parent 254a57b834
commit 60cbd47725
14 changed files with 89 additions and 29 deletions

View file

@ -49,7 +49,9 @@
modifyFilter: <can add, remove and save filter in the spreadsheet> // default = true
modifyContentControl: <can modify content controls in documenteditor> // default = true
fillForms: <can edit forms in view mode> // default = edit || review,
copy: <can copy data> // default = true
copy: <can copy data> // default = true,
editCommentAuthorOnly: <can edit your own comments only> // default = false
deleteCommentAuthorOnly: <can delete your own comments only> // default = false
}
},
editorConfig: {
@ -140,7 +142,7 @@
statusBar: true,
autosave: true,
forcesave: false,
commentAuthorOnly: false,
commentAuthorOnly: false, // must be deprecated. use permissions.editCommentAuthorOnly and permissions.deleteCommentAuthorOnly instead
showReviewChanges: false,
help: true,
compactHeader: false,

View file

@ -237,7 +237,7 @@ define([
},
onRemoveComments: function (type) {
if (this.api) {
this.api.asc_RemoveAllComments(type=='my' || !this.mode.canEditComments, type=='current');// 1 param = true if remove only my comments, 2 param - remove current comments
this.api.asc_RemoveAllComments(type=='my' || !this.mode.canDeleteComments, type=='current');// 1 param = true if remove only my comments, 2 param - remove current comments
}
},
onResolveComment: function (uid) {
@ -776,6 +776,8 @@ define([
comment.set('userdata', data.asc_getUserData());
comment.set('time', date.getTime());
comment.set('date', t.dateToLocaleTimeString(date));
comment.set('editable', t.mode.canEditComments || (data.asc_getUserId() == t.currentUserId));
comment.set('removable', t.mode.canDeleteComments || (data.asc_getUserId() == t.currentUserId));
replies = _.clone(comment.get('replys'));
@ -801,7 +803,8 @@ define([
editTextInPopover : false,
showReplyInPopover : false,
scope : t.view,
editable : t.mode.canEditComments || (data.asc_getReply(i).asc_getUserId() == t.currentUserId)
editable : t.mode.canEditComments || (data.asc_getReply(i).asc_getUserId() == t.currentUserId),
removable : t.mode.canDeleteComments || (data.asc_getReply(i).asc_getUserId() == t.currentUserId)
}));
}
@ -1241,6 +1244,7 @@ define([
hideAddReply : !_.isUndefined(this.hidereply) ? this.hidereply : (this.showPopover ? true : false),
scope : this.view,
editable : this.mode.canEditComments || (data.asc_getUserId() == this.currentUserId),
removable : this.mode.canDeleteComments || (data.asc_getUserId() == this.currentUserId),
hint : !this.mode.canComments,
groupName : (groupname && groupname.length>1) ? groupname[1] : null
});
@ -1277,7 +1281,8 @@ define([
editTextInPopover : false,
showReplyInPopover : false,
scope : this.view,
editable : this.mode.canEditComments || (data.asc_getReply(i).asc_getUserId() == this.currentUserId)
editable : this.mode.canEditComments || (data.asc_getReply(i).asc_getUserId() == this.currentUserId),
removable : this.mode.canDeleteComments || (data.asc_getReply(i).asc_getUserId() == this.currentUserId)
}));
}
}
@ -1438,7 +1443,7 @@ define([
for (i = 0; i < comments.length; ++i) {
comment = this.findComment(comments[i].asc_getId());
if (comment) {
comment.set('editTextInPopover', t.mode.canEditComments);// dont't edit comment when customization->commentAuthorOnly is true
comment.set('editTextInPopover', t.mode.canEditComments);// dont't edit comment when customization->commentAuthorOnly is true or when permissions.editCommentAuthorOnly is true
comment.set('hint', false);
this.popoverComments.push(comment);
}

View file

@ -79,7 +79,8 @@ define([
hide : false,
hint : false,
dummy : undefined,
editable : true
editable : true,
removable : true
}
});
Common.Models.Reply = Backbone.Model.extend({
@ -96,7 +97,8 @@ define([
editText : false,
editTextInPopover : false,
scope : null,
editable : true
editable : true,
removable : true
}
});
});

View file

@ -36,6 +36,8 @@
<div class="btns-reply-ct">
<% if (item.get("editable")) { %>
<div class="btn-edit img-commonctrl" data-value="<%=item.get("id")%>"></div>
<% } %>
<% if (item.get("removable")) { %>
<div class="btn-delete img-commonctrl" data-value="<%=item.get("id")%>"></div>
<% } %>
</div>
@ -67,6 +69,8 @@
<div class="edit-ct">
<% if (editable) { %>
<div class="btn-edit img-commonctrl"></div>
<% } %>
<% if (removable) { %>
<div class="btn-delete img-commonctrl"></div>
<% } %>
<% if (resolved) { %>

View file

@ -36,7 +36,9 @@
<div class="btns-reply-ct">
<% if (item.get("editable")) { %>
<div class="btn-edit img-commonctrl" data-value="<%=item.get("id")%>"></div>
<div class="btn-delete img-commonctrl" data-value="<%=item.get("id")%>"></div>
<%}%>
<% if (item.get("removable")) { %>
<div class="btn-delete img-commonctrl" data-value="<%=item.get("id")%>"></div>
<%}%>
</div>
<%}%>
@ -68,6 +70,8 @@
<div class="edit-ct">
<% if (editable) { %>
<div class="btn-edit img-commonctrl"></div>
<% } %>
<% if (removable) { %>
<div class="btn-delete img-commonctrl"></div>
<% } %>
<% if (resolved) { %>

View file

@ -457,7 +457,7 @@ define([
if (me.btnCommentRemove) {
var items = [
{
caption: config.canEditComments ? me.txtCommentRemCurrent : me.txtCommentRemMyCurrent,
caption: config.canDeleteComments ? me.txtCommentRemCurrent : me.txtCommentRemMyCurrent,
value: 'current'
},
{
@ -465,7 +465,7 @@ define([
value: 'my'
}
];
if (config.canEditComments)
if (config.canDeleteComments)
items.push({
caption: me.txtCommentRemAll,
value: 'all'

View file

@ -1144,7 +1144,7 @@ define([
var me = this;
_.delay(function () {
var _menuItems = [];
_menuItems.push({
comment.editable && _menuItems.push({
caption: me.textEdit,
event: 'edit'
});
@ -1165,7 +1165,7 @@ define([
event: 'addreply'
});
}
_menuItems.push({
comment.removable && _menuItems.push({
caption: me.textDeleteComment,
event: 'delete',
color: 'red'
@ -1203,13 +1203,15 @@ define([
if (_.isNumber(idComment)) {
idComment = idComment.toString();
}
_.delay(function () {
var comment = this.findComment(idComment);
var reply = comment && comment.replys ? comment.replys[ind] : null;
reply && _.delay(function () {
var _menuItems = [];
_menuItems.push({
reply.editable && _menuItems.push({
caption: me.textEdit,
event: 'editreply'
});
_menuItems.push({
reply.removable && _menuItems.push({
caption: me.textDeleteReply,
event: 'deletereply',
color: 'red'
@ -1555,7 +1557,8 @@ define([
reply : data.asc_getReply(i).asc_getText(),
time : date.getTime(),
userInitials : this.getInitials(username),
editable : this.appConfig.canEditComments || (data.asc_getReply(i).asc_getUserId() == _userId)
editable : this.appConfig.canEditComments || (data.asc_getReply(i).asc_getUserId() == _userId),
removable : this.appConfig.canDeleteComments || (data.asc_getReply(i).asc_getUserId() == _userId)
});
}
}
@ -1584,7 +1587,8 @@ define([
replys : [],
groupName : (groupname && groupname.length>1) ? groupname[1] : null,
userInitials : this.getInitials(username),
editable : this.appConfig.canEditComments || (data.asc_getUserId() == _userId)
editable : this.appConfig.canEditComments || (data.asc_getUserId() == _userId),
removable : this.appConfig.canDeleteComments || (data.asc_getUserId() == _userId)
};
if (comment) {
var replies = this.readSDKReplies(data);
@ -1620,6 +1624,8 @@ define([
comment.quote = data.asc_getQuoteText();
comment.time = date.getTime();
comment.date = me.dateToLocaleTimeString(date);
comment.editable = me.appConfig.canEditComments || (data.asc_getUserId() == _userId);
comment.removable = me.appConfig.canDeleteComments || (data.asc_getUserId() == _userId);
replies = _.clone(comment.replys);
@ -1644,7 +1650,8 @@ define([
reply : data.asc_getReply(i).asc_getText(),
time : dateReply.getTime(),
userInitials : me.getInitials(username),
editable : me.appConfig.canEditComments || (data.asc_getUserId() == _userId)
editable : me.appConfig.canEditComments || (data.asc_getReply(i).asc_getUserId() == _userId),
removable : me.appConfig.canDeleteComments || (data.asc_getReply(i).asc_getUserId() == _userId)
});
}
comment.replys = replies;

View file

@ -183,7 +183,7 @@ define([
template += '</div>';
}
template += '</div>';
if (comment.editable && !me.viewmode) {
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>' +
@ -208,7 +208,7 @@ define([
if (isAndroid) {
template += '</div>';
}
if (reply.editable && !me.viewmode) {
if ((reply.editable || reply.removable) && !me.viewmode) {
template += '<div class="reply-menu"><i class="icon icon-menu-comment"></i></div>';
}
template += '</div>' +
@ -253,7 +253,7 @@ define([
'<div class="comment-date"><%= item.date %></div>',
'<% if (android) { %></div><% } %>',
'</div>',
'<% if (item.editable && !viewmode) { %>',
'<% if (!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>',
@ -275,7 +275,7 @@ define([
'<div class="reply-date"><%= reply.date %></div>',
'</div>',
'<% if (android) { %></div><% } %>',
'<% if (reply.editable && !viewmode) { %>',
'<% if ((reply.editable || reply.removable) && !viewmode) { %>',
'<div class="reply-menu"><i class="icon icon-menu-comment"></i></div>',
'<% } %>',
'</div>',

View file

@ -1277,7 +1277,13 @@ define([
this.appOptions.buildVersion = params.asc_getBuildVersion();
this.appOptions.canForcesave = this.appOptions.isEdit && !this.appOptions.isOffline && (typeof (this.editorConfig.customization) == 'object' && !!this.editorConfig.customization.forcesave);
this.appOptions.forcesave = this.appOptions.canForcesave;
this.appOptions.canEditComments= this.appOptions.isOffline || !(typeof (this.editorConfig.customization) == 'object' && this.editorConfig.customization.commentAuthorOnly);
this.appOptions.canEditComments= this.appOptions.isOffline || !this.permissions.editCommentAuthorOnly;
this.appOptions.canDeleteComments= this.appOptions.isOffline || !this.permissions.deleteCommentAuthorOnly;
if ((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.commentAuthorOnly===true) {
console.log("Obsolete: The 'commentAuthorOnly' parameter of the 'customization' section is deprecated. Please use 'editCommentAuthorOnly' and 'deleteCommentAuthorOnly' parameters in the permissions instead.");
if (this.permissions.editCommentAuthorOnly===undefined && this.permissions.deleteCommentAuthorOnly===undefined)
this.appOptions.canEditComments = this.appOptions.canDeleteComments = this.appOptions.isOffline;
}
this.appOptions.trialMode = params.asc_getLicenseMode();
this.appOptions.isBeta = params.asc_getIsBeta();
this.appOptions.isSignatureSupport= this.appOptions.isEdit && this.appOptions.isDesktopApp && this.appOptions.isOffline && this.api.asc_isSignaturesSupport();

View file

@ -812,7 +812,13 @@ define([
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.canEditComments= me.appOptions.isOffline || !me.permissions.editCommentAuthorOnly;
me.appOptions.canDeleteComments= me.appOptions.isOffline || !me.permissions.deleteCommentAuthorOnly;
if ((typeof (me.editorConfig.customization) == 'object') && me.editorConfig.customization.commentAuthorOnly===true) {
console.log("Obsolete: The 'commentAuthorOnly' parameter of the 'customization' section is deprecated. Please use 'editCommentAuthorOnly' and 'deleteCommentAuthorOnly' parameters in the permissions instead.");
if (me.permissions.editCommentAuthorOnly===undefined && me.permissions.deleteCommentAuthorOnly===undefined)
me.appOptions.canEditComments = me.appOptions.canDeleteComments = me.appOptions.isOffline;
}
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

@ -1002,7 +1002,13 @@ define([
this.appOptions.canRename = this.editorConfig.canRename;
this.appOptions.canForcesave = this.appOptions.isEdit && !this.appOptions.isOffline && (typeof (this.editorConfig.customization) == 'object' && !!this.editorConfig.customization.forcesave);
this.appOptions.forcesave = this.appOptions.canForcesave;
this.appOptions.canEditComments= this.appOptions.isOffline || !(typeof (this.editorConfig.customization) == 'object' && this.editorConfig.customization.commentAuthorOnly);
this.appOptions.canEditComments= this.appOptions.isOffline || !this.permissions.editCommentAuthorOnly;
this.appOptions.canDeleteComments= this.appOptions.isOffline || !this.permissions.deleteCommentAuthorOnly;
if ((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.commentAuthorOnly===true) {
console.log("Obsolete: The 'commentAuthorOnly' parameter of the 'customization' section is deprecated. Please use 'editCommentAuthorOnly' and 'deleteCommentAuthorOnly' parameters in the permissions instead.");
if (this.permissions.editCommentAuthorOnly===undefined && this.permissions.deleteCommentAuthorOnly===undefined)
this.appOptions.canEditComments = this.appOptions.canDeleteComments = this.appOptions.isOffline;
}
this.appOptions.buildVersion = params.asc_getBuildVersion();
this.appOptions.trialMode = params.asc_getLicenseMode();
this.appOptions.isBeta = params.asc_getIsBeta();

View file

@ -739,7 +739,13 @@ define([
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.canEditComments= me.appOptions.isOffline || !me.permissions.editCommentAuthorOnly;
me.appOptions.canDeleteComments= me.appOptions.isOffline || !me.permissions.deleteCommentAuthorOnly;
if ((typeof (this.editorConfig.customization) == 'object') && me.editorConfig.customization.commentAuthorOnly===true) {
console.log("Obsolete: The 'commentAuthorOnly' parameter of the 'customization' section is deprecated. Please use 'editCommentAuthorOnly' and 'deleteCommentAuthorOnly' parameters in the permissions instead.");
if (me.permissions.editCommentAuthorOnly===undefined && me.permissions.deleteCommentAuthorOnly===undefined)
me.appOptions.canEditComments = me.appOptions.canDeleteComments = me.appOptions.isOffline;
}
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

@ -1087,7 +1087,13 @@ define([
this.appOptions.canForcesave = this.appOptions.isEdit && !this.appOptions.isOffline && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge) &&
(typeof (this.editorConfig.customization) == 'object' && !!this.editorConfig.customization.forcesave);
this.appOptions.forcesave = this.appOptions.canForcesave;
this.appOptions.canEditComments= this.appOptions.isOffline || !(typeof (this.editorConfig.customization) == 'object' && this.editorConfig.customization.commentAuthorOnly);
this.appOptions.canEditComments= this.appOptions.isOffline || !this.permissions.editCommentAuthorOnly;
this.appOptions.canDeleteComments= this.appOptions.isOffline || !this.permissions.deleteCommentAuthorOnly;
if ((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.commentAuthorOnly===true) {
console.log("Obsolete: The 'commentAuthorOnly' parameter of the 'customization' section is deprecated. Please use 'editCommentAuthorOnly' and 'deleteCommentAuthorOnly' parameters in the permissions instead.");
if (this.permissions.editCommentAuthorOnly===undefined && this.permissions.deleteCommentAuthorOnly===undefined)
this.appOptions.canEditComments = this.appOptions.canDeleteComments = this.appOptions.isOffline;
}
this.appOptions.isSignatureSupport= this.appOptions.isEdit && this.appOptions.isDesktopApp && this.appOptions.isOffline && this.api.asc_isSignaturesSupport() && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge);
this.appOptions.isPasswordSupport = this.appOptions.isEdit && this.api.asc_isProtectionSupport() && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge);
this.appOptions.canProtect = (this.appOptions.isSignatureSupport || this.appOptions.isPasswordSupport);

View file

@ -757,7 +757,13 @@ define([
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.canEditComments= me.appOptions.isOffline || !me.permissions.editCommentAuthorOnly;
me.appOptions.canDeleteComments= me.appOptions.isOffline || !me.permissions.deleteCommentAuthorOnly;
if ((typeof (this.editorConfig.customization) == 'object') && me.editorConfig.customization.commentAuthorOnly===true) {
console.log("Obsolete: The 'commentAuthorOnly' parameter of the 'customization' section is deprecated. Please use 'editCommentAuthorOnly' and 'deleteCommentAuthorOnly' parameters in the permissions instead.");
if (me.permissions.editCommentAuthorOnly===undefined && me.permissions.deleteCommentAuthorOnly===undefined)
me.appOptions.canEditComments = me.appOptions.canDeleteComments = me.appOptions.isOffline;
}
me.appOptions.canChat = me.appOptions.canLicense && !me.appOptions.isOffline && !((typeof (me.editorConfig.customization) == 'object') && me.editorConfig.customization.chat===false);
me.appOptions.trialMode = params.asc_getLicenseMode();