[Mobile] Add parameter to api config: customization.reviewPermissions (user name must be prefixed)
This commit is contained in:
parent
5439ce930c
commit
3e0aaa0449
|
@ -63,7 +63,8 @@ define([
|
|||
canViewReview,
|
||||
arrChangeReview = [],
|
||||
dateChange = [],
|
||||
_fileKey;
|
||||
_fileKey,
|
||||
_currentUserGroups;
|
||||
|
||||
|
||||
return {
|
||||
|
@ -113,6 +114,18 @@ define([
|
|||
if (editor === 'DE') {
|
||||
_fileKey = mode.fileKey;
|
||||
}
|
||||
|
||||
if (mode && mode.canUseReviewPermissions) {
|
||||
var permissions = mode.customization.reviewPermissions,
|
||||
arr = [],
|
||||
groups = Common.Utils.UserInfoParser.getParsedGroups(mode.user.fullname);
|
||||
groups && groups.forEach(function(group) {
|
||||
var item = permissions[group.trim()];
|
||||
item && (arr = arr.concat(item));
|
||||
});
|
||||
_currentUserGroups = arr;
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
|
@ -231,7 +244,8 @@ define([
|
|||
getUsersInfo: function() {
|
||||
var usersArray = [];
|
||||
_.each(editUsers, function(item){
|
||||
var fio = item.asc_getUserName().split(' ');
|
||||
var name = Common.Utils.UserInfoParser.getParsedName(item.asc_getUserName());
|
||||
var fio = name.split(' ');
|
||||
var initials = fio[0].substring(0, 1).toUpperCase();
|
||||
if (fio.length > 1) {
|
||||
initials += fio[fio.length - 1].substring(0, 1).toUpperCase();
|
||||
|
@ -241,7 +255,7 @@ define([
|
|||
color: item.asc_getColor(),
|
||||
id: item.asc_getId(),
|
||||
idOriginal: item.asc_getIdOriginal(),
|
||||
name: item.asc_getUserName(),
|
||||
name: name,
|
||||
view: item.asc_getView(),
|
||||
initial: initials
|
||||
};
|
||||
|
@ -300,6 +314,10 @@ define([
|
|||
$('#settings-accept-all').hide();
|
||||
$('#settings-reject-all').hide();
|
||||
}
|
||||
if (this.appConfig.canUseReviewPermissions) {
|
||||
$('#settings-accept-all').hide();
|
||||
$('#settings-reject-all').hide();
|
||||
}
|
||||
},
|
||||
|
||||
onTrackChanges: function(e) {
|
||||
|
@ -407,6 +425,11 @@ define([
|
|||
$('.accept-reject').html('<a href="#" id="btn-delete-change" class="link">' + this.textDelete + '</a>');
|
||||
$('#btn-delete-change').single('click', _.bind(this.onDeleteChange, this));
|
||||
}
|
||||
} else {
|
||||
if(arrChangeReview.length != 0 && !arrChangeReview[0].editable) {
|
||||
$('#btn-accept-change').addClass('disabled');
|
||||
$('#btn-reject-change').addClass('disabled');
|
||||
}
|
||||
}
|
||||
if(displayMode == "final" || displayMode == "original") {
|
||||
$('#btn-accept-change').addClass('disabled');
|
||||
|
@ -663,9 +686,7 @@ define([
|
|||
userColor = item.get_UserColor(),
|
||||
goto = (item.get_MoveType() == Asc.c_oAscRevisionsMove.MoveTo || item.get_MoveType() == Asc.c_oAscRevisionsMove.MoveFrom);
|
||||
date = me.dateToLocaleTimeString(date);
|
||||
var editable = (item.get_UserId() == _userId);
|
||||
|
||||
|
||||
var editable = me.appConfig.isReviewOnly && (item.get_UserId() == _userId) || !me.appConfig.isReviewOnly && (!me.appConfig.canUseReviewPermissions || me.checkUserGroups(item.get_UserName()));
|
||||
arr.push({date: date, user: user, usercolor: userColor, changetext: changetext, goto: goto, editable: editable});
|
||||
});
|
||||
arrChangeReview = arr;
|
||||
|
@ -677,6 +698,11 @@ define([
|
|||
this.updateInfoChange();
|
||||
},
|
||||
|
||||
checkUserGroups: function(username) {
|
||||
var groups = Common.Utils.UserInfoParser.getParsedGroups(username);
|
||||
return _currentUserGroups && groups && (_.intersection(_currentUserGroups, groups).length>0);
|
||||
},
|
||||
|
||||
dateToLocaleTimeString: function (date) {
|
||||
function format(date) {
|
||||
var strTime,
|
||||
|
@ -736,7 +762,7 @@ define([
|
|||
},
|
||||
|
||||
getInitials: function(name) {
|
||||
var fio = name.split(' ');
|
||||
var fio = Common.Utils.UserInfoParser.getParsedName(name).split(' ');
|
||||
var initials = fio[0].substring(0, 1).toUpperCase();
|
||||
if (fio.length > 1) {
|
||||
initials += fio[fio.length - 1].substring(0, 1).toUpperCase();
|
||||
|
|
|
@ -177,7 +177,7 @@ define([
|
|||
if (isAndroid) {
|
||||
template += '<div class="initials-comment" style="background-color: ' + comment.usercolor + ';">' + comment.userInitials + '</div><div>';
|
||||
}
|
||||
template += '<div class="user-name">' + comment.username + '</div>' +
|
||||
template += '<div class="user-name">' + me.getUserName(comment.username) + '</div>' +
|
||||
'<div class="comment-date">' + comment.date + '</div>';
|
||||
if (isAndroid) {
|
||||
template += '</div>';
|
||||
|
@ -202,7 +202,7 @@ define([
|
|||
if (isAndroid) {
|
||||
template += '<div class="initials-reply" style="background-color: ' + reply.usercolor + ';">' + reply.userInitials + '</div><div>'
|
||||
}
|
||||
template += '<div class="user-name">' + reply.username + '</div>' +
|
||||
template += '<div class="user-name">' + me.getUserName(reply.username) + '</div>' +
|
||||
'<div class="reply-date">' + reply.date + '</div>' +
|
||||
'</div>';
|
||||
if (isAndroid) {
|
||||
|
@ -249,7 +249,7 @@ define([
|
|||
'<div class="item-inner">',
|
||||
'<div class="header-comment"><div class="comment-left">',
|
||||
'<% if (android) { %><div class="initials-comment" style="background-color:<%= item.usercolor %> "> <%= item.userInitials %></div><div><% } %>',
|
||||
'<div class="user-name"><%= item.username %></div>',
|
||||
'<div class="user-name"><%= scope.getUserName(item.username) %></div>',
|
||||
'<div class="comment-date"><%= item.date %></div>',
|
||||
'<% if (android) { %></div><% } %>',
|
||||
'</div>',
|
||||
|
@ -271,7 +271,7 @@ define([
|
|||
'<div class="header-reply">',
|
||||
'<div class="reply-left">',
|
||||
'<% if (android) { %><div class="initials-reply" style="background-color: <%= reply.usercolor %>;"><%= reply.userInitials %></div><div><% } %>',
|
||||
'<div class="user-name"><%= reply.username %></div>',
|
||||
'<div class="user-name"><%= scope.getUserName(reply.username) %></div>',
|
||||
'<div class="reply-date"><%= reply.date %></div>',
|
||||
'</div>',
|
||||
'<% if (android) { %></div><% } %>',
|
||||
|
@ -292,7 +292,8 @@ define([
|
|||
item: comment,
|
||||
replys: comment.replys.length,
|
||||
viewmode: me.viewmode,
|
||||
quote: me.sliceQuote(comment.quote)
|
||||
quote: me.sliceQuote(comment.quote),
|
||||
scope: me
|
||||
}));
|
||||
});
|
||||
$listComments.html(items.join(''));
|
||||
|
@ -304,7 +305,7 @@ define([
|
|||
var isAndroid = Framework7.prototype.device.android === true;
|
||||
var template = '<div class="wrap-comment">' +
|
||||
(isAndroid ? '<div class="header-comment"><div class="initials-comment" style="background-color: ' + comment.usercolor + ';">' + comment.userInitials + '</div><div>' : '') +
|
||||
'<div class="user-name">' + comment.username + '</div>' +
|
||||
'<div class="user-name">' + this.getUserName(comment.username) + '</div>' +
|
||||
'<div class="comment-date">' + comment.date + '</div>' +
|
||||
(isAndroid ? '</div></div>' : '') +
|
||||
'<div><textarea id="comment-text" class="comment-textarea">' + comment.comment + '</textarea></div>' +
|
||||
|
@ -317,7 +318,7 @@ define([
|
|||
var isAndroid = Framework7.prototype.device.android === true;
|
||||
var template = '<div class="wrap-reply">' +
|
||||
(isAndroid ? '<div class="header-comment"><div class="initials-comment" style="background-color: ' + color + ';">' + initials + '</div><div>' : '') +
|
||||
'<div class="user-name">' + name + '</div>' +
|
||||
'<div class="user-name">' + this.getUserName(name) + '</div>' +
|
||||
'<div class="comment-date">' + date + '</div>' +
|
||||
(isAndroid ? '</div></div>' : '') +
|
||||
'<div><textarea class="reply-textarea" placeholder="' + this.textAddReply + '">' + '</textarea></div>' +
|
||||
|
@ -330,7 +331,7 @@ define([
|
|||
var isAndroid = Framework7.prototype.device.android === true;
|
||||
var template = '<div class="wrap-comment">' +
|
||||
(isAndroid ? '<div class="header-comment"><div class="initials-comment" style="background-color: ' + reply.usercolor + ';">' + reply.userInitials + '</div><div>' : '') +
|
||||
'<div class="user-name">' + reply.username + '</div>' +
|
||||
'<div class="user-name">' + this.getUserName(reply.username) + '</div>' +
|
||||
'<div class="comment-date">' + reply.date + '</div>' +
|
||||
(isAndroid ? '</div></div>' : '') +
|
||||
'<div><textarea id="comment-text" class="edit-reply-textarea">' + reply.reply + '</textarea></div>' +
|
||||
|
@ -354,7 +355,7 @@ define([
|
|||
'<div class="page-content">' +
|
||||
'<div class="wrap-reply">' +
|
||||
(isAndroid ? '<div class="header-comment"><div class="initials-comment" style="background-color: ' + color + ';">' + initial + '</div><div>' : '') +
|
||||
'<div class="user-name">' + name + '</div>' +
|
||||
'<div class="user-name">' + this.getUserName(name) + '</div>' +
|
||||
'<div class="comment-date">' + date + '</div>' +
|
||||
(isAndroid ? '</div></div>' : '') +
|
||||
'<div><textarea class="reply-textarea" placeholder="' + this.textAddReply + '"></textarea></div>' +
|
||||
|
@ -401,7 +402,7 @@ define([
|
|||
'<div class="page-content">' +
|
||||
'<div class="wrap-comment">' +
|
||||
(isAndroid ? '<div class="header-comment"><div class="initials-comment" style="background-color: ' + comment.usercolor + ';">' + comment.userInitials + '</div><div>' : '') +
|
||||
'<div class="user-name">' + comment.username + '</div>' +
|
||||
'<div class="user-name">' + this.getUserName(comment.username) + '</div>' +
|
||||
'<div class="comment-date">' + comment.date + '</div>' +
|
||||
(isAndroid ? '</div></div>' : '') +
|
||||
'<div><textarea id="comment-text" class="comment-textarea">' + comment.comment + '</textarea></div>' +
|
||||
|
@ -427,7 +428,7 @@ define([
|
|||
'<div class="page-content">' +
|
||||
'<div class="wrap-comment">' +
|
||||
(isAndroid ? '<div class="header-comment"><div class="initials-comment" style="background-color: ' + reply.usercolor + ';">' + reply.userInitials + '</div><div>' : '') +
|
||||
'<div class="user-name">' + reply.username + '</div>' +
|
||||
'<div class="user-name">' + this.getUserName(reply.username) + '</div>' +
|
||||
'<div class="comment-date">' + reply.date + '</div>' +
|
||||
(isAndroid ? '</div></div>' : '') +
|
||||
'<div><textarea id="comment-text" class="edit-reply-textarea">' + reply.reply + '</textarea></div>' +
|
||||
|
@ -442,13 +443,17 @@ define([
|
|||
renderChangeReview: function(change) {
|
||||
var isAndroid = Framework7.prototype.device.android === true;
|
||||
var template = (isAndroid ? '<div class="header-change"><div class="initials-change" style="background-color: #' + change.color + ';">' + change.initials + '</div><div>' : '') +
|
||||
'<div id="user-name">' + change.user + '</div>' +
|
||||
'<div id="user-name">' + this.getUserName(change.user) + '</div>' +
|
||||
'<div id="date-change">' + change.date + '</div>' +
|
||||
(isAndroid ? '</div></div>' : '') +
|
||||
'<div id="text-change">' + change.text + '</div>';
|
||||
$('#current-change').html(_.template(template));
|
||||
},
|
||||
|
||||
getUserName: function (username) {
|
||||
return Common.Utils.String.htmlEncode(Common.Utils.UserInfoParser.getParsedName(username));
|
||||
},
|
||||
|
||||
textCollaboration: 'Collaboration',
|
||||
textReviewing: 'Review',
|
||||
textСomments: 'Сomments',
|
||||
|
|
|
@ -126,5 +126,32 @@ define([
|
|||
new IScroll(targetSelector);
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Common.Utils.UserInfoParser = new(function() {
|
||||
var parse = false;
|
||||
return {
|
||||
setParser: function(value) {
|
||||
parse = !!value;
|
||||
},
|
||||
|
||||
getParsedName: function(username) {
|
||||
if (parse && username) {
|
||||
return username.substring(username.indexOf(':')+1);
|
||||
} else
|
||||
return username;
|
||||
},
|
||||
|
||||
getParsedGroups: function(username) {
|
||||
if (parse && username) {
|
||||
var idx = username.indexOf(':'),
|
||||
groups = (idx>-1) ? username.substring(0, idx).split(',') : [];
|
||||
for (var i=0; i<groups.length; i++)
|
||||
groups[i] = groups[i].trim();
|
||||
return groups;
|
||||
} else
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
})();
|
||||
});
|
||||
|
|
|
@ -346,7 +346,7 @@ define([
|
|||
if (usersStore){
|
||||
var rec = usersStore.findUser(id);
|
||||
if (rec)
|
||||
return rec.get('username');
|
||||
return Common.Utils.UserInfoParser.getParsedName(rec.get('username'));
|
||||
}
|
||||
return me.textGuest;
|
||||
};
|
||||
|
|
|
@ -800,6 +800,9 @@ define([
|
|||
me.appOptions.canUseHistory = me.appOptions.canReview = me.appOptions.isReviewOnly = false;
|
||||
}
|
||||
|
||||
me.appOptions.canUseReviewPermissions = me.appOptions.canLicense && me.editorConfig.customization && me.editorConfig.customization.reviewPermissions && (typeof (me.editorConfig.customization.reviewPermissions) == 'object');
|
||||
Common.Utils.UserInfoParser.setParser(me.appOptions.canUseReviewPermissions);
|
||||
|
||||
me.applyModeCommonElements();
|
||||
me.applyModeEditorElements();
|
||||
|
||||
|
|
|
@ -456,7 +456,7 @@ define([
|
|||
value = props.asc_getModified();
|
||||
value ? $('#settings-doc-last-mod').html(value.toLocaleString(_lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(_lang, {timeStyle: 'short'})) : $('.display-last-mode').remove();
|
||||
value = props.asc_getLastModifiedBy();
|
||||
value ? $('#settings-doc-mod-by').html(value) : $('.display-mode-by').remove();
|
||||
value ? $('#settings-doc-mod-by').html(Common.Utils.UserInfoParser.getParsedName(value)) : $('.display-mode-by').remove();
|
||||
value = props.asc_getCreated();
|
||||
value ? $('#settings-doc-date').html(value.toLocaleString(_lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(_lang, {timeStyle: 'short'})) : $('.display-created-date').remove();
|
||||
value = props.asc_getCreator();
|
||||
|
|
|
@ -177,7 +177,7 @@ define([
|
|||
var $commentInfo = $('#comment-info');
|
||||
var template = [
|
||||
'<% if (android) { %><div class="header-comment"><div class="initials-comment" style="background-color: <%= comment.usercolor %>;"><%= comment.userInitials %></div><div><% } %>',
|
||||
'<div class="user-name"><%= comment.username %></div>',
|
||||
'<div class="user-name"><%= scope.getUserName(comment.username) %></div>',
|
||||
'<div class="comment-date"><%= comment.date %></div>',
|
||||
'<% if (android) { %></div></div><% } %>',
|
||||
'<div class="wrap-textarea"><textarea id="comment-text" class="comment-textarea" placeholder="<%= textAddComment %>" autofocus></textarea></div>'
|
||||
|
@ -185,7 +185,8 @@ define([
|
|||
var insert = _.template(template)({
|
||||
android: Framework7.prototype.device.android,
|
||||
comment: comment,
|
||||
textAddComment: me.textAddComment
|
||||
textAddComment: me.textAddComment,
|
||||
scope: me
|
||||
});
|
||||
$commentInfo.html(insert);
|
||||
_.defer(function () {
|
||||
|
@ -207,6 +208,10 @@ define([
|
|||
}, 100);
|
||||
},
|
||||
|
||||
getUserName: function (username) {
|
||||
return Common.Utils.String.htmlEncode(Common.Utils.UserInfoParser.getParsedName(username));
|
||||
},
|
||||
|
||||
renderNumFormat: function (dataFormat, selectFormat) {
|
||||
var $listFormat = $('#list-format-footnote ul'),
|
||||
items = [];
|
||||
|
|
|
@ -730,6 +730,9 @@ define([
|
|||
me.appOptions.canBranding = params.asc_getCustomization();
|
||||
me.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof me.editorConfig.customization == 'object');
|
||||
|
||||
me.appOptions.canUseReviewPermissions = me.appOptions.canLicense && me.editorConfig.customization && me.editorConfig.customization.reviewPermissions && (typeof (me.editorConfig.customization.reviewPermissions) == 'object');
|
||||
Common.Utils.UserInfoParser.setParser(me.appOptions.canUseReviewPermissions);
|
||||
|
||||
me.applyModeCommonElements();
|
||||
me.applyModeEditorElements();
|
||||
|
||||
|
|
|
@ -241,7 +241,7 @@ define([
|
|||
value = props.asc_getModified();
|
||||
value ? $('#settings-pe-last-mod').html(value.toLocaleString(_lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(_lang, {timeStyle: 'short'})) : $('.display-last-mode').remove();
|
||||
value = props.asc_getLastModifiedBy();
|
||||
value ? $('#settings-pe-mod-by').html(value) : $('.display-mode-by').remove();
|
||||
value ? $('#settings-pe-mod-by').html(Common.Utils.UserInfoParser.getParsedName(value)) : $('.display-mode-by').remove();
|
||||
value = props.asc_getCreated();
|
||||
value ? $('#settings-pe-date').html(value.toLocaleString(_lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(_lang, {timeStyle: 'short'})) : $('.display-created-date').remove();
|
||||
value = props.asc_getCreator();
|
||||
|
|
|
@ -143,7 +143,7 @@ define([
|
|||
var $commentInfo = $('#comment-info');
|
||||
var template = [
|
||||
'<% if (android) { %><div class="header-comment"><div class="initials-comment" style="background-color: <%= comment.usercolor %>;"><%= comment.userInitials %></div><div><% } %>',
|
||||
'<div class="user-name"><%= comment.username %></div>',
|
||||
'<div class="user-name"><%= scope.getUserName(comment.username) %></div>',
|
||||
'<div class="comment-date"><%= comment.date %></div>',
|
||||
'<% if (android) { %></div></div><% } %>',
|
||||
'<div class="wrap-textarea"><textarea id="comment-text" class="comment-textarea" placeholder="<%= textAddComment %>" autofocus></textarea></div>'
|
||||
|
@ -151,7 +151,8 @@ define([
|
|||
var insert = _.template(template)({
|
||||
android: Framework7.prototype.device.android,
|
||||
comment: comment,
|
||||
textAddComment: me.textAddComment
|
||||
textAddComment: me.textAddComment,
|
||||
scope: me
|
||||
});
|
||||
$commentInfo.html(insert);
|
||||
_.defer(function () {
|
||||
|
@ -173,6 +174,10 @@ define([
|
|||
}, 100);
|
||||
},
|
||||
|
||||
getUserName: function (username) {
|
||||
return Common.Utils.String.htmlEncode(Common.Utils.UserInfoParser.getParsedName(username));
|
||||
},
|
||||
|
||||
showPageTable: function() {
|
||||
this.showPage('#addother-insert-table');
|
||||
this.renderTableStyles();
|
||||
|
|
|
@ -743,6 +743,9 @@ define([
|
|||
|
||||
me.appOptions.canBranding = params.asc_getCustomization();
|
||||
me.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof me.editorConfig.customization == 'object');
|
||||
|
||||
me.appOptions.canUseReviewPermissions = me.appOptions.canLicense && me.editorConfig.customization && me.editorConfig.customization.reviewPermissions && (typeof (me.editorConfig.customization.reviewPermissions) == 'object');
|
||||
Common.Utils.UserInfoParser.setParser(me.appOptions.canUseReviewPermissions);
|
||||
}
|
||||
|
||||
me.appOptions.canRequestEditRights = me.editorConfig.canRequestEditRights;
|
||||
|
|
|
@ -310,7 +310,7 @@ define([
|
|||
value = props.asc_getModified();
|
||||
value ? $('#settings-sse-last-mod').html(value.toLocaleString(_lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(_lang, {timeStyle: 'short'})) : $('.display-last-mode').remove();
|
||||
value = props.asc_getLastModifiedBy();
|
||||
value ? $('#settings-sse-mod-by').html(value) : $('.display-mode-by').remove();
|
||||
value ? $('#settings-sse-mod-by').html(Common.Utils.UserInfoParser.getParsedName(value)) : $('.display-mode-by').remove();
|
||||
value = props.asc_getCreated();
|
||||
value ? $('#settings-sse-date').html(value.toLocaleString(_lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(_lang, {timeStyle: 'short'})) : $('.display-created-date').remove();
|
||||
value = props.asc_getCreator();
|
||||
|
|
|
@ -217,7 +217,7 @@ define([
|
|||
var $commentInfo = $('#comment-info');
|
||||
var template = [
|
||||
'<% if (android) { %><div class="header-comment"><div class="initials-comment" style="background-color: <%= comment.usercolor %>;"><%= comment.userInitials %></div><div><% } %>',
|
||||
'<div class="user-name"><%= comment.username %></div>',
|
||||
'<div class="user-name"><%= scope.getUserName(comment.username) %></div>',
|
||||
'<div class="comment-date"><%= comment.date %></div>',
|
||||
'<% if (android) { %></div></div><% } %>',
|
||||
'<div class="wrap-textarea"><textarea id="comment-text" class="comment-textarea" placeholder="<%= textAddComment %>" autofocus></textarea></div>'
|
||||
|
@ -225,7 +225,8 @@ define([
|
|||
var insert = _.template(template)({
|
||||
android: Framework7.prototype.device.android,
|
||||
comment: comment,
|
||||
textAddComment: me.textAddComment
|
||||
textAddComment: me.textAddComment,
|
||||
scope: me
|
||||
});
|
||||
$commentInfo.html(insert);
|
||||
_.defer(function () {
|
||||
|
@ -247,6 +248,10 @@ define([
|
|||
}, 100);
|
||||
},
|
||||
|
||||
getUserName: function (username) {
|
||||
return Common.Utils.String.htmlEncode(Common.Utils.UserInfoParser.getParsedName(username));
|
||||
},
|
||||
|
||||
showInsertImage: function () {
|
||||
this.showPage('#addother-insimage');
|
||||
|
||||
|
|
Loading…
Reference in a new issue