Add customization parameter for setting anonymous name.

This commit is contained in:
Julia Radzhabova 2020-12-29 23:48:47 +03:00
parent d6e183b52f
commit fc9530d919
8 changed files with 91 additions and 45 deletions

View file

@ -124,6 +124,10 @@
"Group2": ["Group1", "Group2"] // users from Group2 can accept/reject review changes made by users from Group1 and Group2
"Group3": [""] // users from Group3 can accept/reject review changes made by users without a group
},
anonymous: { // set name for anonymous user
request: bool (default: true), // enable set name
label: string (default: "Guest") // postfix for user name
}
chat: true,
comments: true,
zoom: 100,

View file

@ -280,7 +280,7 @@ define([
}
if (appConfig.user.guest) {
if (appConfig.user.guest && appConfig.canRenameAnonymous) {
if (me.labelUserName) {
me.labelUserName.addClass('clickable');
me.labelUserName.on('click', function (e) {
@ -496,7 +496,7 @@ define([
me.btnOptions.render($html.find('#slot-btn-options'));
if (!config.isEdit || config.customization && !!config.customization.compactHeader) {
if (config.user.guest)
if (config.user.guest && config.canRenameAnonymous)
me.btnUserName = createTitleButton('toolbar__icon icon--inverse btn-user', $html.findById('#slot-btn-user-name'));
else {
me.elUserName = $html.find('.btn-current-user');

View file

@ -339,11 +339,19 @@ define([
loadConfig: function(data) {
this.editorConfig = $.extend(this.editorConfig, data.config);
var value = Common.localStorage.getItem("guest-username");
Common.Utils.InternalSettings.set("guest-username", value);
Common.Utils.InternalSettings.set("save-guest-username", !!value);
this.appOptions.customization = this.editorConfig.customization;
this.appOptions.canRenameAnonymous = !((typeof (this.appOptions.customization) == 'object') && (typeof (this.appOptions.customization.anonymous) == 'object') && (this.appOptions.customization.anonymous.request===false));
this.appOptions.guestName = (typeof (this.appOptions.customization) == 'object') && (typeof (this.appOptions.customization.anonymous) == 'object') &&
(typeof (this.appOptions.customization.anonymous.label) == 'string') && this.appOptions.customization.anonymous.label.trim()!=='' ?
Common.Utils.String.htmlEncode(this.appOptions.customization.anonymous.label) : this.textGuest;
var value;
if (this.appOptions.canRenameAnonymous) {
value = Common.localStorage.getItem("guest-username");
Common.Utils.InternalSettings.set("guest-username", value);
Common.Utils.InternalSettings.set("save-guest-username", !!value);
}
this.editorConfig.user =
this.appOptions.user = Common.Utils.fillUserInfo(this.editorConfig.user, this.editorConfig.lang, value ? (value + ' (' + this.textGuest + ')' ) : this.textAnonymous);
this.appOptions.user = Common.Utils.fillUserInfo(this.editorConfig.user, this.editorConfig.lang, value ? (value + ' (' + this.appOptions.guestName + ')' ) : this.textAnonymous);
this.appOptions.isDesktopApp = this.editorConfig.targetApp == 'desktop';
this.appOptions.canCreateNew = this.editorConfig.canRequestCreateNew || !_.isEmpty(this.editorConfig.createUrl);
this.appOptions.canOpenRecent = this.editorConfig.recent !== undefined && !this.appOptions.isDesktopApp;
@ -359,7 +367,6 @@ define([
this.appOptions.saveAsUrl = this.editorConfig.saveAsUrl;
this.appOptions.canAnalytics = false;
this.appOptions.canRequestClose = this.editorConfig.canRequestClose;
this.appOptions.customization = this.editorConfig.customization;
this.appOptions.canBackToFolder = (this.editorConfig.canBackToFolder!==false) && (typeof (this.editorConfig.customization) == 'object') && (typeof (this.editorConfig.customization.goback) == 'object')
&& (!_.isEmpty(this.editorConfig.customization.goback.url) || this.editorConfig.customization.goback.requestClose && this.appOptions.canRequestClose);
this.appOptions.canBack = this.appOptions.canBackToFolder === true;
@ -377,7 +384,7 @@ define([
this.appOptions.canFeatureContentControl = !!this.api.asc_isSupportFeature("content-controls");
this.appOptions.mentionShare = !((typeof (this.appOptions.customization) == 'object') && (this.appOptions.customization.mentionShare==false));
this.appOptions.user.guest && Common.NotificationCenter.on('user:rename', _.bind(this.showRenameUserDialog, this));
this.appOptions.user.guest && this.appOptions.canRenameAnonymous && Common.NotificationCenter.on('user:rename', _.bind(this.showRenameUserDialog, this));
appHeader = this.getApplication().getController('Viewport').getView('Common.Views.Header');
appHeader.setCanBack(this.appOptions.canBackToFolder === true, (this.appOptions.canBackToFolder) ? this.editorConfig.customization.goback.text : '');
@ -1124,7 +1131,7 @@ define([
$('#editor-container').css('overflow', '');
$('.doc-placeholder').remove();
this.appOptions.user.guest && (Common.Utils.InternalSettings.get("guest-username")===null) && this.showRenameUserDialog();
this.appOptions.user.guest && this.appOptions.canRenameAnonymous && (Common.Utils.InternalSettings.get("guest-username")===null) && this.showRenameUserDialog();
},
onLicenseChanged: function(params) {
@ -2170,7 +2177,7 @@ define([
},
onUserConnection: function(change){
if (change && this.appOptions.user.guest && (change.asc_getIdOriginal() == this.appOptions.user.id)) { // change name of the current user
if (change && this.appOptions.user.guest && this.appOptions.canRenameAnonymous && (change.asc_getIdOriginal() == this.appOptions.user.id)) { // change name of the current user
var name = change.asc_getUserName();
if (name && name !== Common.Utils.UserInfoParser.getCurrentName() ) {
Common.Utils.UserInfoParser.setCurrentName(name);
@ -2399,7 +2406,7 @@ define([
},
handler: function(result, settings) {
if (result == 'ok') {
var name = settings.input ? settings.input + ' (' + me.textGuest + ')' : me.textAnonymous;
var name = settings.input ? settings.input + ' (' + me.appOptions.guestName + ')' : me.textAnonymous;
var _user = new Asc.asc_CUserInfo();
_user.put_FullName(name);

View file

@ -198,11 +198,19 @@ define([
me.editorConfig = $.extend(me.editorConfig, data.config);
var value = Common.localStorage.getItem("guest-username");
Common.Utils.InternalSettings.set("guest-username", value);
Common.Utils.InternalSettings.set("save-guest-username", !!value);
me.appOptions.customization = me.editorConfig.customization;
me.appOptions.canRenameAnonymous = !((typeof (me.appOptions.customization) == 'object') && (typeof (me.appOptions.customization.anonymous) == 'object') && (me.appOptions.customization.anonymous.request===false));
me.appOptions.guestName = (typeof (me.appOptions.customization) == 'object') && (typeof (me.appOptions.customization.anonymous) == 'object') &&
(typeof (me.appOptions.customization.anonymous.label) == 'string') && me.appOptions.customization.anonymous.label.trim()!=='' ?
Common.Utils.String.htmlEncode(me.appOptions.customization.anonymous.label) : me.textGuest;
var value;
if (me.appOptions.canRenameAnonymous) {
value = Common.localStorage.getItem("guest-username");
Common.Utils.InternalSettings.set("guest-username", value);
Common.Utils.InternalSettings.set("save-guest-username", !!value);
}
me.editorConfig.user =
me.appOptions.user = Common.Utils.fillUserInfo(me.editorConfig.user, me.editorConfig.lang, value ? (value + ' (' + me.textGuest + ')' ) : me.textAnonymous);
me.appOptions.user = Common.Utils.fillUserInfo(me.editorConfig.user, me.editorConfig.lang, value ? (value + ' (' + me.appOptions.guestName + ')' ) : me.textAnonymous);
me.appOptions.isDesktopApp = me.editorConfig.targetApp == 'desktop';
me.appOptions.canCreateNew = !_.isEmpty(me.editorConfig.createUrl) && !me.appOptions.isDesktopApp;
me.appOptions.canOpenRecent = me.editorConfig.recent !== undefined && !me.appOptions.isDesktopApp;
@ -216,7 +224,6 @@ define([
me.appOptions.mergeFolderUrl = me.editorConfig.mergeFolderUrl;
me.appOptions.canAnalytics = false;
me.appOptions.canRequestClose = me.editorConfig.canRequestClose;
me.appOptions.customization = me.editorConfig.customization;
me.appOptions.canBackToFolder = (me.editorConfig.canBackToFolder!==false) && (typeof (me.editorConfig.customization) == 'object') && (typeof (me.editorConfig.customization.goback) == 'object')
&& (!_.isEmpty(me.editorConfig.customization.goback.url) || me.editorConfig.customization.goback.requestClose && me.appOptions.canRequestClose);
me.appOptions.canBack = me.appOptions.canBackToFolder === true;
@ -1362,7 +1369,7 @@ define([
},
onUserConnection: function(change){
if (change && this.appOptions.user.guest && (change.asc_getIdOriginal() == this.appOptions.user.id)) { // change name of the current user
if (change && this.appOptions.user.guest && this.appOptions.canRenameAnonymous && (change.asc_getIdOriginal() == this.appOptions.user.id)) { // change name of the current user
var name = change.asc_getUserName();
if (name && name !== Common.Utils.UserInfoParser.getCurrentName() ) {
Common.Utils.UserInfoParser.setCurrentName(name);

View file

@ -304,11 +304,19 @@ define([
loadConfig: function(data) {
this.editorConfig = $.extend(this.editorConfig, data.config);
var value = Common.localStorage.getItem("guest-username");
Common.Utils.InternalSettings.set("guest-username", value);
Common.Utils.InternalSettings.set("save-guest-username", !!value);
this.appOptions.customization = this.editorConfig.customization;
this.appOptions.canRenameAnonymous = !((typeof (this.appOptions.customization) == 'object') && (typeof (this.appOptions.customization.anonymous) == 'object') && (this.appOptions.customization.anonymous.request===false));
this.appOptions.guestName = (typeof (this.appOptions.customization) == 'object') && (typeof (this.appOptions.customization.anonymous) == 'object') &&
(typeof (this.appOptions.customization.anonymous.label) == 'string') && this.appOptions.customization.anonymous.label.trim()!=='' ?
Common.Utils.String.htmlEncode(this.appOptions.customization.anonymous.label) : this.textGuest;
var value;
if (this.appOptions.canRenameAnonymous) {
value = Common.localStorage.getItem("guest-username");
Common.Utils.InternalSettings.set("guest-username", value);
Common.Utils.InternalSettings.set("save-guest-username", !!value);
}
this.editorConfig.user =
this.appOptions.user = Common.Utils.fillUserInfo(data.config.user, this.editorConfig.lang, value ? (value + ' (' + this.textGuest + ')' ) : this.textAnonymous);
this.appOptions.user = Common.Utils.fillUserInfo(data.config.user, this.editorConfig.lang, value ? (value + ' (' + this.appOptions.guestName + ')' ) : this.textAnonymous);
this.appOptions.isDesktopApp = this.editorConfig.targetApp == 'desktop';
this.appOptions.canCreateNew = this.editorConfig.canRequestCreateNew || !_.isEmpty(this.editorConfig.createUrl);
this.appOptions.canOpenRecent = this.editorConfig.recent !== undefined && !this.appOptions.isDesktopApp;
@ -323,7 +331,6 @@ define([
this.appOptions.fileChoiceUrl = this.editorConfig.fileChoiceUrl;
this.appOptions.canAnalytics = false;
this.appOptions.canRequestClose = this.editorConfig.canRequestClose;
this.appOptions.customization = this.editorConfig.customization;
this.appOptions.canBackToFolder = (this.editorConfig.canBackToFolder!==false) && (typeof (this.editorConfig.customization) == 'object') && (typeof (this.editorConfig.customization.goback) == 'object')
&& (!_.isEmpty(this.editorConfig.customization.goback.url) || this.editorConfig.customization.goback.requestClose && this.appOptions.canRequestClose);
this.appOptions.canBack = this.appOptions.canBackToFolder === true;
@ -336,7 +343,7 @@ define([
this.appOptions.canRequestSharingSettings = this.editorConfig.canRequestSharingSettings;
this.appOptions.mentionShare = !((typeof (this.appOptions.customization) == 'object') && (this.appOptions.customization.mentionShare==false));
this.appOptions.user.guest && Common.NotificationCenter.on('user:rename', _.bind(this.showRenameUserDialog, this));
this.appOptions.user.guest && this.appOptions.canRenameAnonymous && Common.NotificationCenter.on('user:rename', _.bind(this.showRenameUserDialog, this));
appHeader = this.getApplication().getController('Viewport').getView('Common.Views.Header');
appHeader.setCanBack(this.appOptions.canBackToFolder === true, (this.appOptions.canBackToFolder) ? this.editorConfig.customization.goback.text : '');
@ -847,7 +854,7 @@ define([
Common.Gateway.documentReady();
$('.doc-placeholder').remove();
this.appOptions.user.guest && (Common.Utils.InternalSettings.get("guest-username")===null) && this.showRenameUserDialog();
this.appOptions.user.guest && this.appOptions.canRenameAnonymous && (Common.Utils.InternalSettings.get("guest-username")===null) && this.showRenameUserDialog();
},
onLicenseChanged: function(params) {
@ -1821,7 +1828,7 @@ define([
},
onUserConnection: function(change){
if (change && this.appOptions.user.guest && (change.asc_getIdOriginal() == this.appOptions.user.id)) { // change name of the current user
if (change && this.appOptions.user.guest && this.appOptions.canRenameAnonymous && (change.asc_getIdOriginal() == this.appOptions.user.id)) { // change name of the current user
var name = change.asc_getUserName();
if (name && name !== Common.Utils.UserInfoParser.getCurrentName() ) {
Common.Utils.UserInfoParser.setCurrentName(name);

View file

@ -201,11 +201,19 @@ define([
me.editorConfig = $.extend(me.editorConfig, data.config);
var value = Common.localStorage.getItem("guest-username");
Common.Utils.InternalSettings.set("guest-username", value);
Common.Utils.InternalSettings.set("save-guest-username", !!value);
me.appOptions.customization = me.editorConfig.customization;
me.appOptions.canRenameAnonymous = !((typeof (me.appOptions.customization) == 'object') && (typeof (me.appOptions.customization.anonymous) == 'object') && (me.appOptions.customization.anonymous.request===false));
me.appOptions.guestName = (typeof (me.appOptions.customization) == 'object') && (typeof (me.appOptions.customization.anonymous) == 'object') &&
(typeof (me.appOptions.customization.anonymous.label) == 'string') && me.appOptions.customization.anonymous.label.trim()!=='' ?
Common.Utils.String.htmlEncode(me.appOptions.customization.anonymous.label) : me.textGuest;
var value;
if (me.appOptions.canRenameAnonymous) {
value = Common.localStorage.getItem("guest-username");
Common.Utils.InternalSettings.set("guest-username", value);
Common.Utils.InternalSettings.set("save-guest-username", !!value);
}
me.editorConfig.user =
me.appOptions.user = Common.Utils.fillUserInfo(me.editorConfig.user, me.editorConfig.lang, value ? (value + ' (' + me.textGuest + ')' ) : me.textAnonymous);
me.appOptions.user = Common.Utils.fillUserInfo(me.editorConfig.user, me.editorConfig.lang, value ? (value + ' (' + me.appOptions.guestName + ')' ) : me.textAnonymous);
me.appOptions.isDesktopApp = me.editorConfig.targetApp == 'desktop';
me.appOptions.canCreateNew = !_.isEmpty(me.editorConfig.createUrl) && !me.appOptions.isDesktopApp;
me.appOptions.canOpenRecent = me.editorConfig.recent !== undefined && !me.appOptions.isDesktopApp;
@ -219,7 +227,6 @@ define([
me.appOptions.mergeFolderUrl = me.editorConfig.mergeFolderUrl;
me.appOptions.canAnalytics = false;
me.appOptions.canRequestClose = me.editorConfig.canRequestClose;
me.appOptions.customization = me.editorConfig.customization;
me.appOptions.canBackToFolder = (me.editorConfig.canBackToFolder!==false) && (typeof (me.editorConfig.customization) == 'object') && (typeof (me.editorConfig.customization.goback) == 'object')
&& (!_.isEmpty(me.editorConfig.customization.goback.url) || me.editorConfig.customization.goback.requestClose && me.appOptions.canRequestClose);
me.appOptions.canBack = me.appOptions.canBackToFolder === true;
@ -1255,7 +1262,7 @@ define([
},
onUserConnection: function(change){
if (change && this.appOptions.user.guest && (change.asc_getIdOriginal() == this.appOptions.user.id)) { // change name of the current user
if (change && this.appOptions.user.guest && this.appOptions.canRenameAnonymous && (change.asc_getIdOriginal() == this.appOptions.user.id)) { // change name of the current user
var name = change.asc_getUserName();
if (name && name !== Common.Utils.UserInfoParser.getCurrentName() ) {
Common.Utils.UserInfoParser.setCurrentName(name);

View file

@ -327,11 +327,19 @@ define([
this.appOptions = {};
var value = Common.localStorage.getItem("guest-username");
Common.Utils.InternalSettings.set("guest-username", value);
Common.Utils.InternalSettings.set("save-guest-username", !!value);
this.appOptions.customization = this.editorConfig.customization;
this.appOptions.canRenameAnonymous = !((typeof (this.appOptions.customization) == 'object') && (typeof (this.appOptions.customization.anonymous) == 'object') && (this.appOptions.customization.anonymous.request===false));
this.appOptions.guestName = (typeof (this.appOptions.customization) == 'object') && (typeof (this.appOptions.customization.anonymous) == 'object') &&
(typeof (this.appOptions.customization.anonymous.label) == 'string') && this.appOptions.customization.anonymous.label.trim()!=='' ?
Common.Utils.String.htmlEncode(this.appOptions.customization.anonymous.label) : this.textGuest;
var value;
if (this.appOptions.canRenameAnonymous) {
value = Common.localStorage.getItem("guest-username");
Common.Utils.InternalSettings.set("guest-username", value);
Common.Utils.InternalSettings.set("save-guest-username", !!value);
}
this.editorConfig.user =
this.appOptions.user = Common.Utils.fillUserInfo(this.editorConfig.user, this.editorConfig.lang, value ? (value + ' (' + this.textGuest + ')' ) : this.textAnonymous);
this.appOptions.user = Common.Utils.fillUserInfo(this.editorConfig.user, this.editorConfig.lang, value ? (value + ' (' + this.appOptions.guestName + ')' ) : this.textAnonymous);
this.appOptions.isDesktopApp = this.editorConfig.targetApp == 'desktop';
this.appOptions.canCreateNew = this.editorConfig.canRequestCreateNew || !_.isEmpty(this.editorConfig.createUrl);
this.appOptions.canOpenRecent = this.editorConfig.recent !== undefined && !this.appOptions.isDesktopApp;
@ -350,7 +358,6 @@ define([
this.appOptions.isEditDiagram = this.editorConfig.mode == 'editdiagram';
this.appOptions.isEditMailMerge = this.editorConfig.mode == 'editmerge';
this.appOptions.canRequestClose = this.editorConfig.canRequestClose;
this.appOptions.customization = this.editorConfig.customization;
this.appOptions.canBackToFolder = (this.editorConfig.canBackToFolder!==false) && (typeof (this.editorConfig.customization) == 'object') && (typeof (this.editorConfig.customization.goback) == 'object')
&& (!_.isEmpty(this.editorConfig.customization.goback.url) || this.editorConfig.customization.goback.requestClose && this.appOptions.canRequestClose);
this.appOptions.canBack = this.appOptions.canBackToFolder === true;
@ -366,7 +373,7 @@ define([
this.appOptions.canFeaturePivot = true;
this.appOptions.canFeatureViews = !!this.api.asc_isSupportFeature("sheet-views");
this.appOptions.user.guest && Common.NotificationCenter.on('user:rename', _.bind(this.showRenameUserDialog, this));
this.appOptions.user.guest && this.appOptions.canRenameAnonymous && Common.NotificationCenter.on('user:rename', _.bind(this.showRenameUserDialog, this));
this.headerView = this.getApplication().getController('Viewport').getView('Common.Views.Header');
this.headerView.setCanBack(this.appOptions.canBackToFolder === true, (this.appOptions.canBackToFolder) ? this.editorConfig.customization.goback.text : '');
@ -912,7 +919,7 @@ define([
} else checkWarns();
Common.Gateway.documentReady();
this.appOptions.user.guest && (Common.Utils.InternalSettings.get("guest-username")===null) && this.showRenameUserDialog();
this.appOptions.user.guest && this.appOptions.canRenameAnonymous && (Common.Utils.InternalSettings.get("guest-username")===null) && this.showRenameUserDialog();
},
onLicenseChanged: function(params) {
@ -2181,7 +2188,7 @@ define([
},
onUserConnection: function(change){
if (change && this.appOptions.user.guest && (change.asc_getIdOriginal() == this.appOptions.user.id)) { // change name of the current user
if (change && this.appOptions.user.guest && this.appOptions.canRenameAnonymous && (change.asc_getIdOriginal() == this.appOptions.user.id)) { // change name of the current user
var name = change.asc_getUserName();
if (name && name !== Common.Utils.UserInfoParser.getCurrentName() ) {
Common.Utils.UserInfoParser.setCurrentName(name);

View file

@ -204,11 +204,19 @@ define([
me.editorConfig = $.extend(me.editorConfig, data.config);
var value = Common.localStorage.getItem("guest-username");
Common.Utils.InternalSettings.set("guest-username", value);
Common.Utils.InternalSettings.set("save-guest-username", !!value);
me.appOptions.customization = me.editorConfig.customization;
me.appOptions.canRenameAnonymous = !((typeof (me.appOptions.customization) == 'object') && (typeof (me.appOptions.customization.anonymous) == 'object') && (me.appOptions.customization.anonymous.request===false));
me.appOptions.guestName = (typeof (me.appOptions.customization) == 'object') && (typeof (me.appOptions.customization.anonymous) == 'object') &&
(typeof (me.appOptions.customization.anonymous.label) == 'string') && me.appOptions.customization.anonymous.label.trim()!=='' ?
Common.Utils.String.htmlEncode(me.appOptions.customization.anonymous.label) : me.textGuest;
var value;
if (me.appOptions.canRenameAnonymous) {
value = Common.localStorage.getItem("guest-username");
Common.Utils.InternalSettings.set("guest-username", value);
Common.Utils.InternalSettings.set("save-guest-username", !!value);
}
me.editorConfig.user =
me.appOptions.user = Common.Utils.fillUserInfo(me.editorConfig.user, me.editorConfig.lang, value ? (value + ' (' + me.textGuest + ')' ) : me.textAnonymous);
me.appOptions.user = Common.Utils.fillUserInfo(me.editorConfig.user, me.editorConfig.lang, value ? (value + ' (' + me.appOptions.guestName + ')' ) : me.textAnonymous);
me.appOptions.isDesktopApp = me.editorConfig.targetApp == 'desktop';
me.appOptions.canCreateNew = !_.isEmpty(me.editorConfig.createUrl) && !me.appOptions.isDesktopApp;
me.appOptions.canOpenRecent = me.editorConfig.recent !== undefined && !me.appOptions.isDesktopApp;
@ -223,7 +231,6 @@ define([
me.appOptions.mergeFolderUrl = me.editorConfig.mergeFolderUrl;
me.appOptions.canAnalytics = false;
me.appOptions.canRequestClose = me.editorConfig.canRequestClose;
me.appOptions.customization = me.editorConfig.customization;
me.appOptions.canBackToFolder = (me.editorConfig.canBackToFolder!==false) && (typeof (me.editorConfig.customization) == 'object') && (typeof (me.editorConfig.customization.goback) == 'object')
&& (!_.isEmpty(me.editorConfig.customization.goback.url) || me.editorConfig.customization.goback.requestClose && me.appOptions.canRequestClose);
me.appOptions.canBack = me.appOptions.canBackToFolder === true;
@ -1462,7 +1469,7 @@ define([
},
onUserConnection: function(change){
if (change && this.appOptions.user.guest && (change.asc_getIdOriginal() == this.appOptions.user.id)) { // change name of the current user
if (change && this.appOptions.user.guest && this.appOptions.canRenameAnonymous && (change.asc_getIdOriginal() == this.appOptions.user.id)) { // change name of the current user
var name = change.asc_getUserName();
if (name && name !== Common.Utils.UserInfoParser.getCurrentName() ) {
Common.Utils.UserInfoParser.setCurrentName(name);