From 583065a6af41fb0ea85cb728dbf1b19b9b6a3d7f Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 10 Dec 2020 14:48:03 +0300 Subject: [PATCH 1/9] [DE] Change name for guest user --- apps/common/main/lib/controller/Comments.js | 13 +- .../main/lib/controller/ReviewChanges.js | 12 +- apps/common/main/lib/util/LocalStorage.js | 12 +- apps/common/main/lib/util/utils.js | 33 ++++- apps/common/main/lib/view/UserNameDialog.js | 136 ++++++++++++++++++ .../main/app/controller/Main.js | 42 +++++- 6 files changed, 224 insertions(+), 24 deletions(-) create mode 100644 apps/common/main/lib/view/UserNameDialog.js diff --git a/apps/common/main/lib/controller/Comments.js b/apps/common/main/lib/controller/Comments.js index 559792187..11fbb89ec 100644 --- a/apps/common/main/lib/controller/Comments.js +++ b/apps/common/main/lib/controller/Comments.js @@ -169,7 +169,6 @@ define([ if (data) { this.currentUserId = data.config.user.id; - this.currentUserName = data.config.user.fullname; this.sdkViewName = data['sdkviewname'] || this.sdkViewName; this.hintmode = data['hintmode'] || false; this.viewmode = data['viewmode'] || false; @@ -217,7 +216,7 @@ define([ comment.asc_putTime(this.utcDateToString(new Date())); comment.asc_putOnlyOfficeTime(this.ooDateToString(new Date())); comment.asc_putUserId(this.currentUserId); - comment.asc_putUserName(this.currentUserName); + comment.asc_putUserName(Common.Utils.UserInfoParser.getCurrentName()); comment.asc_putSolved(false); if (!_.isUndefined(comment.asc_putDocumentFlag)) { @@ -355,7 +354,7 @@ define([ ascComment.asc_putTime(t.utcDateToString(new Date(comment.get('time')))); ascComment.asc_putOnlyOfficeTime(t.ooDateToString(new Date(comment.get('time')))); ascComment.asc_putUserId(t.currentUserId); - ascComment.asc_putUserName(t.currentUserName); + ascComment.asc_putUserName(Common.Utils.UserInfoParser.getCurrentName()); ascComment.asc_putSolved(comment.get('resolved')); ascComment.asc_putGuid(comment.get('guid')); ascComment.asc_putUserData(comment.get('userdata')); @@ -432,7 +431,7 @@ define([ if (reply.get('id') === replyId && !_.isUndefined(replyVal)) { addReply.asc_putText(replyVal); addReply.asc_putUserId(me.currentUserId); - addReply.asc_putUserName(me.currentUserName); + addReply.asc_putUserName(Common.Utils.UserInfoParser.getCurrentName()); } else { addReply.asc_putText(reply.get('reply')); addReply.asc_putUserId(reply.get('userid')); @@ -512,7 +511,7 @@ define([ addReply.asc_putTime(me.utcDateToString(new Date())); addReply.asc_putOnlyOfficeTime(me.ooDateToString(new Date())); addReply.asc_putUserId(me.currentUserId); - addReply.asc_putUserName(me.currentUserName); + addReply.asc_putUserName(Common.Utils.UserInfoParser.getCurrentName()); ascComment.asc_addReply(addReply); @@ -1308,7 +1307,7 @@ define([ time: date.getTime(), date: this.dateToLocaleTimeString(date), userid: this.currentUserId, - username: this.currentUserName, + username: Common.Utils.UserInfoParser.getCurrentName(), usercolor: (user) ? user.get('color') : null, editTextInPopover: true, showReplyInPopover: false, @@ -1372,7 +1371,7 @@ define([ comment.asc_putTime(this.utcDateToString(new Date())); comment.asc_putOnlyOfficeTime(this.ooDateToString(new Date())); comment.asc_putUserId(this.currentUserId); - comment.asc_putUserName(this.currentUserName); + comment.asc_putUserName(Common.Utils.UserInfoParser.getCurrentName()); comment.asc_putSolved(false); if (!_.isUndefined(comment.asc_putDocumentFlag)) diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index 7e8639f33..3fe77ee36 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -118,16 +118,6 @@ define([ if (data) { this.currentUserId = data.config.user.id; - if (this.appConfig && this.appConfig.canUseReviewPermissions) { - var permissions = this.appConfig.customization.reviewPermissions, - arr = [], - groups = Common.Utils.UserInfoParser.getParsedGroups(data.config.user.fullname); - groups && groups.forEach(function(group) { - var item = permissions[group.trim()]; - item && (arr = arr.concat(item)); - }); - this.currentUserGroups = arr; - } this.sdkViewName = data['sdkviewname'] || this.sdkViewName; } return this; @@ -482,7 +472,7 @@ define([ checkUserGroups: function(username) { var groups = Common.Utils.UserInfoParser.getParsedGroups(username); - return this.currentUserGroups && groups && (_.intersection(this.currentUserGroups, (groups.length>0) ? groups : [""]).length>0); + return Common.Utils.UserInfoParser.getCurrentGroups() && groups && (_.intersection(Common.Utils.UserInfoParser.getCurrentGroups(), (groups.length>0) ? groups : [""]).length>0); }, getUserName: function(id){ diff --git a/apps/common/main/lib/util/LocalStorage.js b/apps/common/main/lib/util/LocalStorage.js index 764492111..7c55eba5a 100644 --- a/apps/common/main/lib/util/LocalStorage.js +++ b/apps/common/main/lib/util/LocalStorage.js @@ -98,12 +98,19 @@ define(['gateway'], function () { var value = _getItem(name); defValue = defValue || false; return (value!==null) ? (parseInt(value) != 0) : defValue; - } + }; var _getItemExists = function (name) { var value = _getItem(name); return value !== null; - } + }; + + var _removeItem = function(name) { + if (_lsAllowed) + localStorage.removeItem(name); + else + delete _store[name]; + }; try { var _lsAllowed = !!window.localStorage; @@ -122,6 +129,7 @@ define(['gateway'], function () { getBool: _getItemAsBool, setBool: _setItemAsBool, setItem: _setItem, + removeItem: _removeItem, setKeysFilter: function(value) { _filter = value; }, diff --git a/apps/common/main/lib/util/utils.js b/apps/common/main/lib/util/utils.js index 3b8db6cc7..9c8e56dac 100644 --- a/apps/common/main/lib/util/utils.js +++ b/apps/common/main/lib/util/utils.js @@ -967,8 +967,11 @@ Common.Utils.ModalWindow = new(function() { })(); Common.Utils.UserInfoParser = new(function() { - var parse = false; - var separator = String.fromCharCode(160); + var parse = false, + separator = String.fromCharCode(160), + username = '', + usergroups, + permissions; return { setParser: function(value) { parse = !!value; @@ -994,6 +997,32 @@ Common.Utils.UserInfoParser = new(function() { return groups; } else return undefined; + }, + + setCurrentName: function(name) { + username = name; + this.setReviewPermissions(permissions); + }, + + getCurrentName: function() { + return username; + }, + + setReviewPermissions: function(reviewPermissions) { + if (reviewPermissions) { + var arr = [], + groups = this.getParsedGroups(username); + groups && groups.forEach(function(group) { + var item = reviewPermissions[group.trim()]; + item && (arr = arr.concat(item)); + }); + usergroups = arr; + permissions = reviewPermissions; + } + }, + + getCurrentGroups: function() { + return usergroups; } } })(); \ No newline at end of file diff --git a/apps/common/main/lib/view/UserNameDialog.js b/apps/common/main/lib/view/UserNameDialog.js new file mode 100644 index 000000000..3195d99c6 --- /dev/null +++ b/apps/common/main/lib/view/UserNameDialog.js @@ -0,0 +1,136 @@ +/* + * + * (c) Copyright Ascensio System SIA 2010-2020 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ +/** + * UserNameDialog.js + * + * Created by Julia Radzhabova on 09.12.2020 + * Copyright (c) 2020 Ascensio System SIA. All rights reserved. + * + */ + +define([ + 'common/main/lib/component/Window', + 'common/main/lib/component/InputField' +], function () { 'use strict'; + + Common.Views.UserNameDialog = Common.UI.Window.extend(_.extend({ + options: { + width: 330, + header: false, + modal : false, + cls: 'modal-dlg', + buttons: ['ok', 'cancel'] + }, + + initialize : function(options) { + _.extend(this.options, options || {}); + + this.template = [ + '
', + '
', + '', + '
', + '
', + '
', + '
' + ].join(''); + + this.options.tpl = _.template(this.template)(this.options); + + Common.UI.Window.prototype.initialize.call(this, this.options); + }, + + render: function() { + Common.UI.Window.prototype.render.call(this); + + var me = this; + me.inputLabel = new Common.UI.InputField({ + el : $('#id-dlg-username-caption'), + allowBlank : false, + blankError : me.options.error ? me.options.error : me.textLabelError, + style : 'width: 100%;', + maxLength : 128, + validateOnBlur: false, + validation : me.options.validation || function(value) { + return value ? true : ''; + } + }); + me.inputLabel.setValue(this.options.value || '' ); + + me.chAlwaysUse = new Common.UI.CheckBox({ + el: $('#id-dlg-username-chk-use'), + labelText: this.textUse + }); + + var $window = this.getChild(); + $window.find('.btn').on('click', _.bind(this.onBtnClick, this)); + }, + + show: function() { + Common.UI.Window.prototype.show.apply(this, arguments); + + var me = this; + _.delay(function(){ + me.getChild('input').focus(); + },50); + }, + + onPrimary: function(event) { + this._handleInput('ok'); + return false; + }, + + onBtnClick: function(event) { + this._handleInput(event.currentTarget.attributes['result'].value); + }, + + _handleInput: function(state) { + if (this.options.handler) { + if (state == 'ok') { + if (this.inputLabel.checkValidate() !== true) { + this.inputLabel.cmpEl.find('input').focus(); + return; + } + } + + this.options.handler.call(this, state, {input: this.inputLabel.getValue(), checkbox: this.chAlwaysUse.getValue()=='checked'}); + } + + this.close(); + }, + + textLabel: 'Label:', + textLabelError: 'Label must not be empty.', + textUse: 'Always use this name' + }, Common.Views.UserNameDialog || {})); +}); \ No newline at end of file diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 67e9c141d..f8ddbae86 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -49,6 +49,7 @@ define([ 'common/main/lib/controller/Fonts', 'common/main/lib/collection/TextArt', 'common/main/lib/view/OpenDialog', + 'common/main/lib/view/UserNameDialog', 'common/main/lib/util/LocalStorage', 'documenteditor/main/app/collection/ShapeGroups', 'documenteditor/main/app/collection/EquationGroups' @@ -338,8 +339,9 @@ define([ loadConfig: function(data) { this.editorConfig = $.extend(this.editorConfig, data.config); + var value = Common.localStorage.getItem("guest-username"); this.editorConfig.user = - this.appOptions.user = Common.Utils.fillUserInfo(this.editorConfig.user, this.editorConfig.lang, this.textAnonymous); + this.appOptions.user = Common.Utils.fillUserInfo(this.editorConfig.user, this.editorConfig.lang, value ? (value + ' (' + this.textGuest + ')' ) : 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; @@ -1117,6 +1119,8 @@ define([ $('#editor-container').css('overflow', ''); $('.doc-placeholder').remove(); + + !Common.localStorage.getItem("guest-username") && this.showRenameUserDialog(); }, onLicenseChanged: function(params) { @@ -1281,6 +1285,8 @@ define([ this.appOptions.canUseReviewPermissions = this.appOptions.canLicense && this.editorConfig.customization && this.editorConfig.customization.reviewPermissions && (typeof (this.editorConfig.customization.reviewPermissions) == 'object'); Common.Utils.UserInfoParser.setParser(this.appOptions.canUseReviewPermissions); + Common.Utils.UserInfoParser.setCurrentName(this.appOptions.user.fullname); + this.appOptions.canUseReviewPermissions && Common.Utils.UserInfoParser.setReviewPermissions(this.editorConfig.customization.reviewPermissions); appHeader.setUserName(Common.Utils.UserInfoParser.getParsedName(this.appOptions.user.fullname)); this.appOptions.canRename && appHeader.setCanRename(true); @@ -2356,6 +2362,34 @@ define([ me.api.asc_SetAutoCorrectHyphensWithDash(value); }, + showRenameUserDialog: function() { + var me = this; + var value = Common.localStorage.getItem("guest-username"); + (new Common.Views.UserNameDialog({ + label: this.textRenameLabel, + error: this.textRenameError, + value: value || '', + validation: function(value) { + return value.length<128 ? true : me.textLongName; + }, + handler: function(result, {input: input, checkbox: checkbox}) { + if (result == 'ok') { + var name = input + ' (' + me.textGuest + ')'; + var _user = new Asc.asc_CUserInfo(); + _user.put_FullName(name); + + var docInfo = new Asc.asc_CDocInfo(); + docInfo.put_UserInfo(_user); + me.api.asc_setDocInfo(docInfo); + + Common.Utils.UserInfoParser.setCurrentName(name); + appHeader.setUserName(Common.Utils.UserInfoParser.getParsedName(name)); + checkbox ? Common.localStorage.setItem("guest-username", input) : Common.localStorage.removeItem("guest-username"); + } + } + })).show(); + }, + leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' then \'Save\' to save them. Click \'Leave this Page\' to discard all the unsaved changes.', criticalErrorTitle: 'Error', notcriticalErrorTitle: 'Warning', @@ -2712,7 +2746,11 @@ define([ textRemember: 'Remember my choice', warnLicenseLimitedRenewed: 'License needs to be renewed.
You have a limited access to document editing functionality.
Please contact your administrator to get full access', warnLicenseLimitedNoAccess: 'License expired.
You have no access to document editing functionality.
Please contact your administrator.', - saveErrorTextDesktop: 'This file cannot be saved or created.
Possible reasons are:
1. The file is read-only.
2. The file is being edited by other users.
3. The disk is full or corrupted.' + saveErrorTextDesktop: 'This file cannot be saved or created.
Possible reasons are:
1. The file is read-only.
2. The file is being edited by other users.
3. The disk is full or corrupted.', + textRenameLabel: 'Enter a name to be used for collaboration', + textRenameError: 'User name must not be empty.', + textLongName: 'Enter a name that is less than 128 characters.', + textGuest: 'Guest' } })(), DE.Controllers.Main || {})) }); \ No newline at end of file From 2be4649d631e9d5e6f4fc977582142cd94365f29 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 11 Dec 2020 13:08:13 +0300 Subject: [PATCH 2/9] [DE] Set name for guest user --- apps/common/main/lib/util/utils.js | 1 + apps/common/main/lib/view/Header.js | 9 +++++++- apps/common/main/lib/view/UserNameDialog.js | 12 +++++------ apps/common/main/resources/less/header.less | 5 +++++ .../main/app/controller/Main.js | 21 ++++++++++++++----- 5 files changed, 36 insertions(+), 12 deletions(-) diff --git a/apps/common/main/lib/util/utils.js b/apps/common/main/lib/util/utils.js index 9c8e56dac..81c4755f2 100644 --- a/apps/common/main/lib/util/utils.js +++ b/apps/common/main/lib/util/utils.js @@ -714,6 +714,7 @@ Common.Utils.fillUserInfo = function(info, lang, defname) { !_user.id && (_user.id = ('uid-' + Date.now())); _user.fullname = _.isEmpty(_user.name) ? defname : _user.name; _user.group && (_user.fullname = (_user.group).toString() + Common.Utils.UserInfoParser.getSeparator() + _user.fullname); + _user.guest = _.isEmpty(_user.name); return _user; }; diff --git a/apps/common/main/lib/view/Header.js b/apps/common/main/lib/view/Header.js index edc32f215..4f3472f30 100644 --- a/apps/common/main/lib/view/Header.js +++ b/apps/common/main/lib/view/Header.js @@ -118,7 +118,7 @@ define([ '
' + '
' + - '' + + '' + ''; function onResetUsers(collection, opts) { @@ -273,6 +273,13 @@ define([ $panelUsers[(editingUsers > 1 || editingUsers > 0 && !appConfig.isEdit && !appConfig.isRestrictedEdit || !mode.isOffline && (mode.sharingSettingsUrl && mode.sharingSettingsUrl.length || mode.canRequestSharingSettings)) ? 'show' : 'hide'](); } + if (me.labelUserName && appConfig.user.guest) { + me.labelUserName.addClass('clickable'); + me.labelUserName.on('click', function (e) { + Common.NotificationCenter.trigger('user:rename'); + }); + } + if ( me.btnPrint ) { me.btnPrint.updateHint(me.tipPrint + Common.Utils.String.platformKey('Ctrl+P')); me.btnPrint.on('click', function (e) { diff --git a/apps/common/main/lib/view/UserNameDialog.js b/apps/common/main/lib/view/UserNameDialog.js index 3195d99c6..05534a06e 100644 --- a/apps/common/main/lib/view/UserNameDialog.js +++ b/apps/common/main/lib/view/UserNameDialog.js @@ -76,8 +76,7 @@ define([ var me = this; me.inputLabel = new Common.UI.InputField({ el : $('#id-dlg-username-caption'), - allowBlank : false, - blankError : me.options.error ? me.options.error : me.textLabelError, + allowBlank : true, style : 'width: 100%;', maxLength : 128, validateOnBlur: false, @@ -87,9 +86,10 @@ define([ }); me.inputLabel.setValue(this.options.value || '' ); - me.chAlwaysUse = new Common.UI.CheckBox({ + me.chDontShow = new Common.UI.CheckBox({ el: $('#id-dlg-username-chk-use'), - labelText: this.textUse + labelText: this.textDontShow, + value: this.options.check }); var $window = this.getChild(); @@ -123,7 +123,7 @@ define([ } } - this.options.handler.call(this, state, {input: this.inputLabel.getValue(), checkbox: this.chAlwaysUse.getValue()=='checked'}); + this.options.handler.call(this, state, {input: this.inputLabel.getValue(), checkbox: this.chDontShow.getValue()=='checked'}); } this.close(); @@ -131,6 +131,6 @@ define([ textLabel: 'Label:', textLabelError: 'Label must not be empty.', - textUse: 'Always use this name' + textDontShow: 'Don\'t ask me again' }, Common.Views.UserNameDialog || {})); }); \ No newline at end of file diff --git a/apps/common/main/resources/less/header.less b/apps/common/main/resources/less/header.less index de6cd9579..9da7f823c 100644 --- a/apps/common/main/resources/less/header.less +++ b/apps/common/main/resources/less/header.less @@ -401,6 +401,11 @@ height: 100%; padding: 0 12px; line-height: @height-title; + pointer-events: none; + &.clickable { + cursor: pointer; + pointer-events: auto; + } } .lr-separator { diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index f8ddbae86..89daacf96 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -340,6 +340,7 @@ define([ this.editorConfig = $.extend(this.editorConfig, data.config); var value = Common.localStorage.getItem("guest-username"); + Common.Utils.InternalSettings.set("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.isDesktopApp = this.editorConfig.targetApp == 'desktop'; @@ -375,6 +376,8 @@ 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)); + appHeader = this.getApplication().getController('Viewport').getView('Common.Views.Header'); appHeader.setCanBack(this.appOptions.canBackToFolder === true, (this.appOptions.canBackToFolder) ? this.editorConfig.customization.goback.text : ''); @@ -1120,7 +1123,7 @@ define([ $('#editor-container').css('overflow', ''); $('.doc-placeholder').remove(); - !Common.localStorage.getItem("guest-username") && this.showRenameUserDialog(); + this.appOptions.user.guest && (Common.Utils.InternalSettings.get("guest-username")===null) && this.showRenameUserDialog(); }, onLicenseChanged: function(params) { @@ -2363,18 +2366,21 @@ define([ }, showRenameUserDialog: function() { + if (this._renameDialog) return; + var me = this; - var value = Common.localStorage.getItem("guest-username"); - (new Common.Views.UserNameDialog({ + var value = Common.Utils.InternalSettings.get("guest-username"); + this._renameDialog = new Common.Views.UserNameDialog({ label: this.textRenameLabel, error: this.textRenameError, value: value || '', + check: (value!==null), validation: function(value) { return value.length<128 ? true : me.textLongName; }, handler: function(result, {input: input, checkbox: checkbox}) { if (result == 'ok') { - var name = input + ' (' + me.textGuest + ')'; + var name = input ? input + ' (' + me.textGuest + ')' : me.textAnonymous; var _user = new Asc.asc_CUserInfo(); _user.put_FullName(name); @@ -2385,9 +2391,14 @@ define([ Common.Utils.UserInfoParser.setCurrentName(name); appHeader.setUserName(Common.Utils.UserInfoParser.getParsedName(name)); checkbox ? Common.localStorage.setItem("guest-username", input) : Common.localStorage.removeItem("guest-username"); + Common.Utils.InternalSettings.set("guest-username", input); } } - })).show(); + }); + this._renameDialog.on('close', function() { + me._renameDialog = undefined; + }); + this._renameDialog.show(Common.Utils.innerWidth() - this._renameDialog.options.width - 15, 30); }, leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' then \'Save\' to save them. Click \'Leave this Page\' to discard all the unsaved changes.', From e8dcb54c788761cb80d9a03e1c71315f8b8fec5b Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 18 Dec 2020 13:23:14 +0300 Subject: [PATCH 3/9] Fix changing user name --- apps/common/main/lib/controller/Chat.js | 1 + .../main/app/controller/Main.js | 4 +- .../mobile/app/controller/DocumentHolder.js | 1 + .../main/app/controller/Main.js | 56 +++++++++++++++++-- .../main/app/controller/Main.js | 54 +++++++++++++++++- 5 files changed, 107 insertions(+), 9 deletions(-) diff --git a/apps/common/main/lib/controller/Chat.js b/apps/common/main/lib/controller/Chat.js index 5731e4721..aa895823d 100644 --- a/apps/common/main/lib/controller/Chat.js +++ b/apps/common/main/lib/controller/Chat.js @@ -169,6 +169,7 @@ define([ })); } else { user.set({online: change.asc_getState()}); + user.set({username: change.asc_getUserName()}); } } }, diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 89daacf96..7483f8d41 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -393,7 +393,7 @@ define([ $('#editor-container').append('
' + '
'.repeat(20) + '
'); } - var value = Common.localStorage.getItem("de-macros-mode"); + value = Common.localStorage.getItem("de-macros-mode"); if (value === null) { value = this.editorConfig.customization ? this.editorConfig.customization.macrosMode : 'warn'; value = (value == 'enable') ? 1 : (value == 'disable' ? 2 : 0); @@ -2386,7 +2386,7 @@ define([ var docInfo = new Asc.asc_CDocInfo(); docInfo.put_UserInfo(_user); - me.api.asc_setDocInfo(docInfo); + me.api.asc_changeDocInfo(docInfo); Common.Utils.UserInfoParser.setCurrentName(name); appHeader.setUserName(Common.Utils.UserInfoParser.getParsedName(name)); diff --git a/apps/documenteditor/mobile/app/controller/DocumentHolder.js b/apps/documenteditor/mobile/app/controller/DocumentHolder.js index 4684d4a32..3370f19f3 100644 --- a/apps/documenteditor/mobile/app/controller/DocumentHolder.js +++ b/apps/documenteditor/mobile/app/controller/DocumentHolder.js @@ -439,6 +439,7 @@ define([ })); } else { user.set({online: change.asc_getState()}); + user.set({username: change.asc_getUserName()}); } } }, diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index af7ee014f..67621ed1d 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -49,6 +49,7 @@ define([ 'common/main/lib/controller/Fonts', 'common/main/lib/collection/TextArt', 'common/main/lib/view/OpenDialog', + 'common/main/lib/view/UserNameDialog', 'common/main/lib/util/LocalStorage', 'presentationeditor/main/app/collection/ShapeGroups', 'presentationeditor/main/app/collection/SlideLayouts', @@ -303,8 +304,10 @@ 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); this.editorConfig.user = - this.appOptions.user = Common.Utils.fillUserInfo(data.config.user, this.editorConfig.lang, this.textAnonymous); + this.appOptions.user = Common.Utils.fillUserInfo(data.config.user, this.editorConfig.lang, value ? (value + ' (' + this.textGuest + ')' ) : 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; @@ -332,6 +335,8 @@ 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)); + appHeader = this.getApplication().getController('Viewport').getView('Common.Views.Header'); appHeader.setCanBack(this.appOptions.canBackToFolder === true, (this.appOptions.canBackToFolder) ? this.editorConfig.customization.goback.text : ''); @@ -346,7 +351,7 @@ define([ $('#editor-container').append('
'); } - var value = Common.localStorage.getItem("pe-macros-mode"); + value = Common.localStorage.getItem("pe-macros-mode"); if (value === null) { value = this.editorConfig.customization ? this.editorConfig.customization.macrosMode : 'warn'; value = (value == 'enable') ? 1 : (value == 'disable' ? 2 : 0); @@ -841,6 +846,7 @@ define([ Common.Gateway.documentReady(); $('.doc-placeholder').remove(); + this.appOptions.user.guest && (Common.Utils.InternalSettings.get("guest-username")===null) && this.showRenameUserDialog(); }, onLicenseChanged: function(params) { @@ -983,6 +989,8 @@ define([ this.appOptions.canUseReviewPermissions = this.appOptions.canLicense && this.editorConfig.customization && this.editorConfig.customization.reviewPermissions && (typeof (this.editorConfig.customization.reviewPermissions) == 'object'); Common.Utils.UserInfoParser.setParser(this.appOptions.canUseReviewPermissions); + Common.Utils.UserInfoParser.setCurrentName(this.appOptions.user.fullname); + this.appOptions.canUseReviewPermissions && Common.Utils.UserInfoParser.setReviewPermissions(this.editorConfig.customization.reviewPermissions); appHeader.setUserName(Common.Utils.UserInfoParser.getParsedName(this.appOptions.user.fullname)); this.appOptions.canRename && appHeader.setCanRename(true); @@ -1998,7 +2006,43 @@ define([ me.api.asc_SetAutoCorrectHyphensWithDash(value); }, - + + showRenameUserDialog: function() { + if (this._renameDialog) return; + + var me = this; + var value = Common.Utils.InternalSettings.get("guest-username"); + this._renameDialog = new Common.Views.UserNameDialog({ + label: this.textRenameLabel, + error: this.textRenameError, + value: value || '', + check: (value!==null), + validation: function(value) { + return value.length<128 ? true : me.textLongName; + }, + handler: function(result, {input: input, checkbox: checkbox}) { + if (result == 'ok') { + var name = input ? input + ' (' + me.textGuest + ')' : me.textAnonymous; + var _user = new Asc.asc_CUserInfo(); + _user.put_FullName(name); + + var docInfo = new Asc.asc_CDocInfo(); + docInfo.put_UserInfo(_user); + me.api.asc_changeDocInfo(docInfo); + + Common.Utils.UserInfoParser.setCurrentName(name); + appHeader.setUserName(Common.Utils.UserInfoParser.getParsedName(name)); + checkbox ? Common.localStorage.setItem("guest-username", input) : Common.localStorage.removeItem("guest-username"); + Common.Utils.InternalSettings.set("guest-username", input); + } + } + }); + this._renameDialog.on('close', function() { + me._renameDialog = undefined; + }); + this._renameDialog.show(Common.Utils.innerWidth() - this._renameDialog.options.width - 15, 30); + }, + // Translation leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' then \'Save\' to save them. Click \'Leave this Page\' to discard all the unsaved changes.', criticalErrorTitle: 'Error', @@ -2355,7 +2399,11 @@ define([ textRemember: 'Remember my choice', warnLicenseLimitedRenewed: 'License needs to be renewed.
You have a limited access to document editing functionality.
Please contact your administrator to get full access', warnLicenseLimitedNoAccess: 'License expired.
You have no access to document editing functionality.
Please contact your administrator.', - saveErrorTextDesktop: 'This file cannot be saved or created.
Possible reasons are:
1. The file is read-only.
2. The file is being edited by other users.
3. The disk is full or corrupted.' + saveErrorTextDesktop: 'This file cannot be saved or created.
Possible reasons are:
1. The file is read-only.
2. The file is being edited by other users.
3. The disk is full or corrupted.', + textRenameLabel: 'Enter a name to be used for collaboration', + textRenameError: 'User name must not be empty.', + textLongName: 'Enter a name that is less than 128 characters.', + textGuest: 'Guest' } })(), PE.Controllers.Main || {})) }); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index a8fcf876e..3b5dca8ad 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -49,6 +49,7 @@ define([ 'common/main/lib/controller/Fonts', 'common/main/lib/collection/TextArt', 'common/main/lib/view/OpenDialog', + 'common/main/lib/view/UserNameDialog', 'common/main/lib/util/LanguageInfo', 'common/main/lib/util/LocalStorage', 'spreadsheeteditor/main/app/collection/ShapeGroups', @@ -326,8 +327,10 @@ define([ this.appOptions = {}; + var value = Common.localStorage.getItem("guest-username"); + Common.Utils.InternalSettings.set("guest-username", value); this.editorConfig.user = - this.appOptions.user = Common.Utils.fillUserInfo(this.editorConfig.user, this.editorConfig.lang, this.textAnonymous); + this.appOptions.user = Common.Utils.fillUserInfo(this.editorConfig.user, this.editorConfig.lang, value ? (value + ' (' + this.textGuest + ')' ) : 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; @@ -362,6 +365,8 @@ 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.headerView = this.getApplication().getController('Viewport').getView('Common.Views.Header'); this.headerView.setCanBack(this.appOptions.canBackToFolder === true, (this.appOptions.canBackToFolder) ? this.editorConfig.customization.goback.text : ''); @@ -386,7 +391,7 @@ define([ this.api.asc_setLocale(reg, decimal, group); } - var value = Common.localStorage.getBool("sse-settings-r1c1"); + value = Common.localStorage.getBool("sse-settings-r1c1"); Common.Utils.InternalSettings.set("sse-settings-r1c1", value); this.api.asc_setR1C1Mode(value); @@ -906,6 +911,7 @@ define([ } else checkWarns(); Common.Gateway.documentReady(); + this.appOptions.user.guest && (Common.Utils.InternalSettings.get("guest-username")===null) && this.showRenameUserDialog(); }, onLicenseChanged: function(params) { @@ -1039,6 +1045,8 @@ define([ this.appOptions.canRename && this.headerView.setCanRename(true); this.appOptions.canUseReviewPermissions = this.appOptions.canLicense && this.editorConfig.customization && this.editorConfig.customization.reviewPermissions && (typeof (this.editorConfig.customization.reviewPermissions) == 'object'); Common.Utils.UserInfoParser.setParser(this.appOptions.canUseReviewPermissions); + Common.Utils.UserInfoParser.setCurrentName(this.appOptions.user.fullname); + this.appOptions.canUseReviewPermissions && Common.Utils.UserInfoParser.setReviewPermissions(this.editorConfig.customization.reviewPermissions); this.headerView.setUserName(Common.Utils.UserInfoParser.getParsedName(this.appOptions.user.fullname)); } else this.appOptions.canModifyFilter = true; @@ -2315,6 +2323,42 @@ define([ me.api.asc_setIncludeNewRowColTable(value); }, + showRenameUserDialog: function() { + if (this._renameDialog) return; + + var me = this; + var value = Common.Utils.InternalSettings.get("guest-username"); + this._renameDialog = new Common.Views.UserNameDialog({ + label: this.textRenameLabel, + error: this.textRenameError, + value: value || '', + check: (value!==null), + validation: function(value) { + return value.length<128 ? true : me.textLongName; + }, + handler: function(result, {input: input, checkbox: checkbox}) { + if (result == 'ok') { + var name = input ? input + ' (' + me.textGuest + ')' : me.textAnonymous; + var _user = new Asc.asc_CUserInfo(); + _user.put_FullName(name); + + var docInfo = new Asc.asc_CDocInfo(); + docInfo.put_UserInfo(_user); + me.api.asc_changeDocInfo(docInfo); + + Common.Utils.UserInfoParser.setCurrentName(name); + appHeader.setUserName(Common.Utils.UserInfoParser.getParsedName(name)); + checkbox ? Common.localStorage.setItem("guest-username", input) : Common.localStorage.removeItem("guest-username"); + Common.Utils.InternalSettings.set("guest-username", input); + } + } + }); + this._renameDialog.on('close', function() { + me._renameDialog = undefined; + }); + this._renameDialog.show(Common.Utils.innerWidth() - this._renameDialog.options.width - 15, 30); + }, + leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' then \'Save\' to save them. Click \'Leave this Page\' to discard all the unsaved changes.', criticalErrorTitle: 'Error', notcriticalErrorTitle: 'Warning', @@ -2694,7 +2738,11 @@ define([ errorChangeFilteredRange: 'This will change a filtered range on your worksheet.
To complete this task, please remove AutoFilters.', warnLicenseLimitedRenewed: 'License needs to be renewed.
You have a limited access to document editing functionality.
Please contact your administrator to get full access', warnLicenseLimitedNoAccess: 'License expired.
You have no access to document editing functionality.
Please contact your administrator.', - saveErrorTextDesktop: 'This file cannot be saved or created.
Possible reasons are:
1. The file is read-only.
2. The file is being edited by other users.
3. The disk is full or corrupted.' + saveErrorTextDesktop: 'This file cannot be saved or created.
Possible reasons are:
1. The file is read-only.
2. The file is being edited by other users.
3. The disk is full or corrupted.', + textRenameLabel: 'Enter a name to be used for collaboration', + textRenameError: 'User name must not be empty.', + textLongName: 'Enter a name that is less than 128 characters.', + textGuest: 'Guest' } })(), SSE.Controllers.Main || {})) }); From e7877564d6c5d11427eadda63eaf6df53e74577d Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 18 Dec 2020 19:20:31 +0300 Subject: [PATCH 4/9] Fix set name for ie11 --- apps/documenteditor/main/app/controller/Main.js | 8 ++++---- apps/presentationeditor/main/app/controller/Main.js | 8 ++++---- apps/spreadsheeteditor/main/app/controller/Main.js | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 7483f8d41..cc083ef8f 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -2378,9 +2378,9 @@ define([ validation: function(value) { return value.length<128 ? true : me.textLongName; }, - handler: function(result, {input: input, checkbox: checkbox}) { + handler: function(result, settings) { if (result == 'ok') { - var name = input ? input + ' (' + me.textGuest + ')' : me.textAnonymous; + var name = settings.input ? settings.input + ' (' + me.textGuest + ')' : me.textAnonymous; var _user = new Asc.asc_CUserInfo(); _user.put_FullName(name); @@ -2390,8 +2390,8 @@ define([ Common.Utils.UserInfoParser.setCurrentName(name); appHeader.setUserName(Common.Utils.UserInfoParser.getParsedName(name)); - checkbox ? Common.localStorage.setItem("guest-username", input) : Common.localStorage.removeItem("guest-username"); - Common.Utils.InternalSettings.set("guest-username", input); + settings.checkbox ? Common.localStorage.setItem("guest-username", settings.input) : Common.localStorage.removeItem("guest-username"); + Common.Utils.InternalSettings.set("guest-username", settings.input); } } }); diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 67621ed1d..7fc8d4a66 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -2020,9 +2020,9 @@ define([ validation: function(value) { return value.length<128 ? true : me.textLongName; }, - handler: function(result, {input: input, checkbox: checkbox}) { + handler: function(result, settings) { if (result == 'ok') { - var name = input ? input + ' (' + me.textGuest + ')' : me.textAnonymous; + var name = settings.input ? settings.input + ' (' + me.textGuest + ')' : me.textAnonymous; var _user = new Asc.asc_CUserInfo(); _user.put_FullName(name); @@ -2032,8 +2032,8 @@ define([ Common.Utils.UserInfoParser.setCurrentName(name); appHeader.setUserName(Common.Utils.UserInfoParser.getParsedName(name)); - checkbox ? Common.localStorage.setItem("guest-username", input) : Common.localStorage.removeItem("guest-username"); - Common.Utils.InternalSettings.set("guest-username", input); + settings.checkbox ? Common.localStorage.setItem("guest-username", settings.input) : Common.localStorage.removeItem("guest-username"); + Common.Utils.InternalSettings.set("guest-username", settings.input); } } }); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 3b5dca8ad..cfbcaa2b0 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -2336,9 +2336,9 @@ define([ validation: function(value) { return value.length<128 ? true : me.textLongName; }, - handler: function(result, {input: input, checkbox: checkbox}) { + handler: function(result, settings) { if (result == 'ok') { - var name = input ? input + ' (' + me.textGuest + ')' : me.textAnonymous; + var name = settings.input ? settings.input + ' (' + me.textGuest + ')' : me.textAnonymous; var _user = new Asc.asc_CUserInfo(); _user.put_FullName(name); @@ -2348,8 +2348,8 @@ define([ Common.Utils.UserInfoParser.setCurrentName(name); appHeader.setUserName(Common.Utils.UserInfoParser.getParsedName(name)); - checkbox ? Common.localStorage.setItem("guest-username", input) : Common.localStorage.removeItem("guest-username"); - Common.Utils.InternalSettings.set("guest-username", input); + settings.checkbox ? Common.localStorage.setItem("guest-username", settings.input) : Common.localStorage.removeItem("guest-username"); + Common.Utils.InternalSettings.set("guest-username", settings.input); } } }); From 88eb04e0d329c79fb20b0bb797a23bfc1b3739ea Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Sun, 20 Dec 2020 12:22:46 +0300 Subject: [PATCH 5/9] Fix changing guest name --- .../main/app/controller/Main.js | 28 +++++++++++++++---- .../main/app/controller/Main.js | 28 +++++++++++++++---- .../main/app/controller/Main.js | 28 +++++++++++++++---- 3 files changed, 69 insertions(+), 15 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index cc083ef8f..e6e95f472 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -341,6 +341,7 @@ define([ var 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.isDesktopApp = this.editorConfig.targetApp == 'desktop'; @@ -1334,6 +1335,7 @@ define([ this.api.asc_registerCallback('asc_onDownloadUrl', _.bind(this.onDownloadUrl, this)); this.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(this.onAuthParticipantsChanged, this)); this.api.asc_registerCallback('asc_onParticipantsChanged', _.bind(this.onAuthParticipantsChanged, this)); + this.api.asc_registerCallback('asc_onConnectionStateChanged', _.bind(this.onUserConnection, this)); this.api.asc_registerCallback('asc_onDocumentModifiedChanged', _.bind(this.onDocumentModifiedChanged, this)); }, @@ -2167,6 +2169,24 @@ define([ this._state.usersCount = length; }, + onUserConnection: function(change){ + if (change && this.appOptions.user.guest && (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); + appHeader.setUserName(Common.Utils.UserInfoParser.getParsedName(name)); + + var idx1 = name.lastIndexOf('('), + idx2 = name.lastIndexOf(')'), + str = (idx1>0) && (idx10) && (idx10) && (idx1 Date: Mon, 21 Dec 2020 17:38:32 +0300 Subject: [PATCH 6/9] Refactoring --- apps/documenteditor/main/app/controller/Main.js | 2 +- apps/presentationeditor/main/app/controller/Main.js | 2 +- apps/spreadsheeteditor/main/app/controller/Main.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index e6e95f472..ff032ddff 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -1291,7 +1291,7 @@ define([ Common.Utils.UserInfoParser.setParser(this.appOptions.canUseReviewPermissions); Common.Utils.UserInfoParser.setCurrentName(this.appOptions.user.fullname); this.appOptions.canUseReviewPermissions && Common.Utils.UserInfoParser.setReviewPermissions(this.editorConfig.customization.reviewPermissions); - appHeader.setUserName(Common.Utils.UserInfoParser.getParsedName(this.appOptions.user.fullname)); + appHeader.setUserName(Common.Utils.UserInfoParser.getParsedName(Common.Utils.UserInfoParser.getCurrentName())); this.appOptions.canRename && appHeader.setCanRename(true); this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins); diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index a15fef931..36e8fb325 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -992,7 +992,7 @@ define([ Common.Utils.UserInfoParser.setParser(this.appOptions.canUseReviewPermissions); Common.Utils.UserInfoParser.setCurrentName(this.appOptions.user.fullname); this.appOptions.canUseReviewPermissions && Common.Utils.UserInfoParser.setReviewPermissions(this.editorConfig.customization.reviewPermissions); - appHeader.setUserName(Common.Utils.UserInfoParser.getParsedName(this.appOptions.user.fullname)); + appHeader.setUserName(Common.Utils.UserInfoParser.getParsedName(Common.Utils.UserInfoParser.getCurrentName())); this.appOptions.canRename && appHeader.setCanRename(true); this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 4675d2d2d..57e9d92fe 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1048,7 +1048,7 @@ define([ Common.Utils.UserInfoParser.setParser(this.appOptions.canUseReviewPermissions); Common.Utils.UserInfoParser.setCurrentName(this.appOptions.user.fullname); this.appOptions.canUseReviewPermissions && Common.Utils.UserInfoParser.setReviewPermissions(this.editorConfig.customization.reviewPermissions); - this.headerView.setUserName(Common.Utils.UserInfoParser.getParsedName(this.appOptions.user.fullname)); + this.headerView.setUserName(Common.Utils.UserInfoParser.getParsedName(Common.Utils.UserInfoParser.getCurrentName())); } else this.appOptions.canModifyFilter = true; From 45a69f519262bff5f39ef299a67d0a36230a5405 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 21 Dec 2020 17:44:28 +0300 Subject: [PATCH 7/9] [Mobile] Use and update guest name --- .../mobile/lib/controller/Collaboration.js | 16 +++++++------- .../mobile/app/controller/Main.js | 22 ++++++++++++++++--- .../mobile/app/controller/Main.js | 22 ++++++++++++++++--- .../mobile/app/controller/Main.js | 22 ++++++++++++++++--- 4 files changed, 65 insertions(+), 17 deletions(-) diff --git a/apps/common/mobile/lib/controller/Collaboration.js b/apps/common/mobile/lib/controller/Collaboration.js index 0043bdb77..699d94a15 100644 --- a/apps/common/mobile/lib/controller/Collaboration.js +++ b/apps/common/mobile/lib/controller/Collaboration.js @@ -119,7 +119,7 @@ define([ if (mode && mode.canUseReviewPermissions) { var permissions = mode.customization.reviewPermissions, arr = [], - groups = Common.Utils.UserInfoParser.getParsedGroups(mode.user.fullname); + groups = Common.Utils.UserInfoParser.getParsedGroups(Common.Utils.UserInfoParser.getCurrentName()); groups && groups.forEach(function(group) { var item = permissions[group.trim()]; item && (arr = arr.concat(item)); @@ -264,14 +264,11 @@ define([ }, getUsersInfo: function() { + var me = this; var usersArray = []; _.each(editUsers, function(item){ 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(); - } + var initials = me.getInitials(name); if((item.asc_getState()!==false) && !item.asc_getView()) { var userAttr = { color: item.asc_getColor(), @@ -791,8 +788,11 @@ define([ getInitials: function(name) { 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(); + for (var i=fio.length-1; i>0; i--) { + if (fio[i][0]!=='(' && fio[i][0]!==')') { + initials += fio[i].substring(0, 1).toUpperCase(); + break; + } } return initials; }, diff --git a/apps/documenteditor/mobile/app/controller/Main.js b/apps/documenteditor/mobile/app/controller/Main.js index 885b392df..8c15d1b3b 100644 --- a/apps/documenteditor/mobile/app/controller/Main.js +++ b/apps/documenteditor/mobile/app/controller/Main.js @@ -198,8 +198,11 @@ 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.editorConfig.user = - me.appOptions.user = Common.Utils.fillUserInfo(me.editorConfig.user, me.editorConfig.lang, me.textAnonymous); + me.appOptions.user = Common.Utils.fillUserInfo(me.editorConfig.user, me.editorConfig.lang, value ? (value + ' (' + me.textGuest + ')' ) : 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; @@ -226,7 +229,7 @@ define([ if (!me.editorConfig.customization || !(me.editorConfig.customization.loaderName || me.editorConfig.customization.loaderLogo)) $('#editor-container').append('
'); - var value = Common.localStorage.getItem("de-mobile-macros-mode"); + value = Common.localStorage.getItem("de-mobile-macros-mode"); if (value === null) { value = this.editorConfig.customization ? this.editorConfig.customization.macrosMode : 'warn'; value = (value == 'enable') ? 1 : (value == 'disable' ? 2 : 0); @@ -818,6 +821,8 @@ define([ 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); + Common.Utils.UserInfoParser.setCurrentName(me.appOptions.user.fullname); + me.appOptions.canUseReviewPermissions && Common.Utils.UserInfoParser.setReviewPermissions(this.editorConfig.customization.reviewPermissions); me.applyModeCommonElements(); me.applyModeEditorElements(); @@ -855,6 +860,7 @@ define([ me.api.asc_registerCallback('asc_onDownloadUrl', _.bind(me.onDownloadUrl, me)); me.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(me.onAuthParticipantsChanged, me)); me.api.asc_registerCallback('asc_onParticipantsChanged', _.bind(me.onAuthParticipantsChanged, me)); + me.api.asc_registerCallback('asc_onConnectionStateChanged', _.bind(me.onUserConnection, me)); } }, @@ -1355,6 +1361,15 @@ define([ this._state.usersCount = length; }, + onUserConnection: function(change){ + if (change && this.appOptions.user.guest && (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); + } + } + }, + onDocumentName: function(name) { // this.getApplication().getController('Viewport').getView('Common.Views.Header').setDocumentCaption(name); this.updateWindowTitle(true); @@ -1595,7 +1610,8 @@ define([ errorSessionIdle: 'The document has not been edited for quite a long time. Please reload the page.', errorSessionToken: 'The connection to the server has been interrupted. Please reload the page.', warnLicenseLimitedRenewed: 'License needs to be renewed.
You have a limited access to document editing functionality.
Please contact your administrator to get full access', - warnLicenseLimitedNoAccess: 'License expired.
You have no access to document editing functionality.
Please contact your administrator.' + warnLicenseLimitedNoAccess: 'License expired.
You have no access to document editing functionality.
Please contact your administrator.', + textGuest: 'Guest' } })(), DE.Controllers.Main || {})) }); \ No newline at end of file diff --git a/apps/presentationeditor/mobile/app/controller/Main.js b/apps/presentationeditor/mobile/app/controller/Main.js index 3b0ab4822..f3c021438 100644 --- a/apps/presentationeditor/mobile/app/controller/Main.js +++ b/apps/presentationeditor/mobile/app/controller/Main.js @@ -201,8 +201,11 @@ 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.editorConfig.user = - me.appOptions.user = Common.Utils.fillUserInfo(me.editorConfig.user, me.editorConfig.lang, me.textAnonymous); + me.appOptions.user = Common.Utils.fillUserInfo(me.editorConfig.user, me.editorConfig.lang, value ? (value + ' (' + me.textGuest + ')' ) : 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; @@ -229,7 +232,7 @@ define([ if (!me.editorConfig.customization || !(me.editorConfig.customization.loaderName || me.editorConfig.customization.loaderLogo)) $('#editor_sdk').append('
'); - var value = Common.localStorage.getItem("pe-mobile-macros-mode"); + value = Common.localStorage.getItem("pe-mobile-macros-mode"); if (value === null) { value = this.editorConfig.customization ? this.editorConfig.customization.macrosMode : 'warn'; value = (value == 'enable') ? 1 : (value == 'disable' ? 2 : 0); @@ -744,6 +747,8 @@ define([ 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); + Common.Utils.UserInfoParser.setCurrentName(me.appOptions.user.fullname); + me.appOptions.canUseReviewPermissions && Common.Utils.UserInfoParser.setReviewPermissions(me.editorConfig.customization.reviewPermissions); me.applyModeCommonElements(); me.applyModeEditorElements(); @@ -781,6 +786,7 @@ define([ me.api.asc_registerCallback('asc_onDownloadUrl', _.bind(me.onDownloadUrl, me)); me.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(me.onAuthParticipantsChanged, me)); me.api.asc_registerCallback('asc_onParticipantsChanged', _.bind(me.onAuthParticipantsChanged, me)); + me.api.asc_registerCallback('asc_onConnectionStateChanged', _.bind(me.onUserConnection, me)); } }, @@ -1248,6 +1254,15 @@ define([ this._state.usersCount = length; }, + onUserConnection: function(change){ + if (change && this.appOptions.user.guest && (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); + } + } + }, + onDocumentName: function(name) { // this.getApplication().getController('Viewport').getView('Common.Views.Header').setDocumentCaption(name); this.updateWindowTitle(true); @@ -1536,7 +1551,8 @@ define([ errorSessionIdle: 'The document has not been edited for quite a long time. Please reload the page.', errorSessionToken: 'The connection to the server has been interrupted. Please reload the page.', warnLicenseLimitedRenewed: 'License needs to be renewed.
You have a limited access to document editing functionality.
Please contact your administrator to get full access', - warnLicenseLimitedNoAccess: 'License expired.
You have no access to document editing functionality.
Please contact your administrator.' + warnLicenseLimitedNoAccess: 'License expired.
You have no access to document editing functionality.
Please contact your administrator.', + textGuest: 'Guest' } })(), PE.Controllers.Main || {})) }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/app/controller/Main.js b/apps/spreadsheeteditor/mobile/app/controller/Main.js index 9c3384547..2584b2408 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/Main.js +++ b/apps/spreadsheeteditor/mobile/app/controller/Main.js @@ -204,8 +204,11 @@ 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.editorConfig.user = - me.appOptions.user = Common.Utils.fillUserInfo(me.editorConfig.user, me.editorConfig.lang, me.textAnonymous); + me.appOptions.user = Common.Utils.fillUserInfo(me.editorConfig.user, me.editorConfig.lang, value ? (value + ' (' + me.textGuest + ')' ) : 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; @@ -227,7 +230,7 @@ define([ me.appOptions.canPlugins = false; me.plugins = me.editorConfig.plugins; - var value = Common.localStorage.getItem("sse-settings-regional"); + value = Common.localStorage.getItem("sse-settings-regional"); if (value!==null) this.api.asc_setLocale(parseInt(value)); else { @@ -756,6 +759,8 @@ define([ 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); + Common.Utils.UserInfoParser.setCurrentName(me.appOptions.user.fullname); + me.appOptions.canUseReviewPermissions && Common.Utils.UserInfoParser.setReviewPermissions(me.editorConfig.customization.reviewPermissions); } me.appOptions.canRequestEditRights = me.editorConfig.canRequestEditRights; @@ -803,6 +808,7 @@ define([ } me.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(me.onAuthParticipantsChanged, me)); me.api.asc_registerCallback('asc_onParticipantsChanged', _.bind(me.onAuthParticipantsChanged, me)); + me.api.asc_registerCallback('asc_onConnectionStateChanged', _.bind(me.onUserConnection, me)); }, applyModeEditorElements: function() { @@ -1455,6 +1461,15 @@ define([ this._state.usersCount = length; }, + onUserConnection: function(change){ + if (change && this.appOptions.user.guest && (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); + } + } + }, + applySettings: function() { if (this.appOptions.isEdit && this.appOptions.canLicense && !this.appOptions.isOffline && this.appOptions.canCoAuthoring) { var value = Common.localStorage.getItem("sse-settings-coauthmode"), @@ -1754,7 +1769,8 @@ define([ errorFrmlMaxLength: 'You cannot add this formula as its length exceeded the allowed number of characters.
Please edit it and try again.', errorFrmlMaxReference: 'You cannot enter this formula because it has too many values,
cell references, and/or names.', warnLicenseLimitedRenewed: 'License needs to be renewed.
You have a limited access to document editing functionality.
Please contact your administrator to get full access', - warnLicenseLimitedNoAccess: 'License expired.
You have no access to document editing functionality.
Please contact your administrator.' + warnLicenseLimitedNoAccess: 'License expired.
You have no access to document editing functionality.
Please contact your administrator.', + textGuest: 'Guest' } })(), SSE.Controllers.Main || {})) }); \ No newline at end of file From d6e183b52fbfc6bc854e9652dbbeb26909e774ec Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 29 Dec 2020 10:39:00 +0300 Subject: [PATCH 8/9] Compact toolbar: add user button to header for changing guest name --- apps/common/main/lib/view/Header.js | 42 +++++++++++++++--- apps/common/main/lib/view/UserNameDialog.js | 6 +-- .../resources/img/toolbar/1.25x/btn-user.png | Bin 0 -> 552 bytes .../resources/img/toolbar/1.5x/btn-user.png | Bin 0 -> 748 bytes .../resources/img/toolbar/1.75x/btn-user.png | Bin 0 -> 830 bytes .../resources/img/toolbar/1x/btn-user.png | Bin 0 -> 462 bytes .../resources/img/toolbar/2x/btn-user.png | Bin 0 -> 1009 bytes apps/common/main/resources/less/header.less | 32 +++++++++++++ apps/common/main/resources/less/toolbar.less | 10 +++++ 9 files changed, 81 insertions(+), 9 deletions(-) create mode 100644 apps/common/main/resources/img/toolbar/1.25x/btn-user.png create mode 100644 apps/common/main/resources/img/toolbar/1.5x/btn-user.png create mode 100644 apps/common/main/resources/img/toolbar/1.75x/btn-user.png create mode 100644 apps/common/main/resources/img/toolbar/1x/btn-user.png create mode 100644 apps/common/main/resources/img/toolbar/2x/btn-user.png diff --git a/apps/common/main/lib/view/Header.js b/apps/common/main/lib/view/Header.js index 4f3472f30..8f3dcfd34 100644 --- a/apps/common/main/lib/view/Header.js +++ b/apps/common/main/lib/view/Header.js @@ -100,6 +100,12 @@ define([ '
' + '
' + '' + + '
' + + '
' + + '' + + '
' + '' + ''; @@ -273,11 +279,18 @@ define([ $panelUsers[(editingUsers > 1 || editingUsers > 0 && !appConfig.isEdit && !appConfig.isRestrictedEdit || !mode.isOffline && (mode.sharingSettingsUrl && mode.sharingSettingsUrl.length || mode.canRequestSharingSettings)) ? 'show' : 'hide'](); } - if (me.labelUserName && appConfig.user.guest) { - me.labelUserName.addClass('clickable'); - me.labelUserName.on('click', function (e) { - Common.NotificationCenter.trigger('user:rename'); - }); + + if (appConfig.user.guest) { + if (me.labelUserName) { + me.labelUserName.addClass('clickable'); + me.labelUserName.on('click', function (e) { + Common.NotificationCenter.trigger('user:rename'); + }); + } else if (me.btnUserName) { + me.btnUserName.on('click', function (e) { + Common.NotificationCenter.trigger('user:rename'); + }); + } } if ( me.btnPrint ) { @@ -482,6 +495,16 @@ define([ } me.btnOptions.render($html.find('#slot-btn-options')); + if (!config.isEdit || config.customization && !!config.customization.compactHeader) { + if (config.user.guest) + me.btnUserName = createTitleButton('toolbar__icon icon--inverse btn-user', $html.findById('#slot-btn-user-name')); + else { + me.elUserName = $html.find('.btn-current-user'); + me.elUserName.removeClass('hidden'); + } + me.setUserName(me.options.userName); + } + $userList = $html.find('.cousers-list'); $panelUsers = $html.find('.box-cousers'); $btnUsers = $html.find('.btn-users'); @@ -629,6 +652,15 @@ define([ } else this.labelUserName.hide(); } else { this.options.userName = name; + if ( this.btnUserName ) { + this.btnUserName.updateHint(name); + } else if (this.elUserName) { + this.elUserName.tooltip({ + title: name, + placement: 'cursor', + html: true + }); + } } return this; diff --git a/apps/common/main/lib/view/UserNameDialog.js b/apps/common/main/lib/view/UserNameDialog.js index 05534a06e..5076d9bd0 100644 --- a/apps/common/main/lib/view/UserNameDialog.js +++ b/apps/common/main/lib/view/UserNameDialog.js @@ -57,11 +57,9 @@ define([ this.template = [ '
', - '
', - '', - '
', + '
' + (this.options.label ? this.options.label : this.textLabel) + '
', '
', - '
', + '
', '
' ].join(''); diff --git a/apps/common/main/resources/img/toolbar/1.25x/btn-user.png b/apps/common/main/resources/img/toolbar/1.25x/btn-user.png new file mode 100644 index 0000000000000000000000000000000000000000..21d84e54ab4160b7ff9eb338bcab6de76e1b10b5 GIT binary patch literal 552 zcmV+@0@wYCP)X1ONa4*WraIh(}fl)V&!Hkl;b+j6ny& z2t~jd;$oe0+&3i4qtjzPuu#N(Ls*Q^Lq60w6@NTlywjEqIw(#M@X!M`68Q0|`Nye1 z=I?8M5+yW^0x|+WPyjPB0uiB+ij`J^?#3!)4E3yX&u*of3+yHdZcvah=%Ki0o@vL0 zv-Az3Y^OhUOv@jTZ;GF3w+WCRMtR)a9rLkcmRz6QEp z=Hhy%YDgi*B9<}6pvPQXj8qRPzUAxg)b)#4d_8_=_w{!u`b8{UkKfrbG3M(gv%qEB zKQS=|H_X6h`!SQklapO}v_<>xND zA}c>G_F`S$qjC>m@!VxsgyI2P?oqWVlEk<1A>OG>HILV(Ai=ls0T0E524SdUmFI~c zfzPt*1c7jvUB-}Iq}dObz&ojOE4xV33=bzMyt0W-`LTH-gQPb8tA>jQn=u0L=%IKye`H-V2rxu9T%FqgM*=hkICC5_fxQ@gkmgx|952)jOYAB)+=b5|KYDX0IP!(h$t zRLcEnTY_}QwkMjCfB)JyYwz_MxxM$9{J(Er|33TiUcH{Lb*~j{s+IE?`sN)Ib?4uE zaXZ7><)Wr+AM!q`9j(#Mw_^YB=ZSCY&vknv&+pqPv6pdWfww+G=4)P$)@ZYu?NT53 zPD!a8*mcx;LhHE;-}{7^)ZQ1)-giCefZj>7!fPklkGa3RAvkmH%wExJb2e5)CzaZE zg*<$GbHRbODRHk?T{BaW*Ll{VcSho5;GQ+do|n1nTGoocxLI{&lC{{1_3egPo+WIr z4<6I?oRfIyqq=L9LNPK0Ez$^KmcJtM38L+iUajR#AC1Zo&&nc zpd`pIm_ZRX)+VY^x`SW&FCxU&zwHid4X0x0Wnmdy=#L`9_BQleV%;E!leeTJBG- z;Sfn%3GLZ5E$qiDt5U96jX&0l_xJ@j zX$kx<{eH1B)?sGhb!lfi#dhTtM{aXG**$fCqu*ZddakS$#w(*P+&uayY+b=Z<206g zv$=x~If*aw5j>RIqB#9yh(Ph8=`X~eo_@Zpb6=<0uT}$}j-7pyvwdnBjK)wAA$R`STbZ|?b=6P){=o0N_34MK8%@H= z+zZ$s_$T>r6Xz@G#IH9z<_IR{Z7TWh=8^R3ioMzFJ1aij5IR&E{3uztS#N#iG{aeC q9Gwnl7Y2EC6`lXz)2Ly<#bEPCooW9O9YbKEWAJqKb6Mw<&;$Vfv5y7- literal 0 HcmV?d00001 diff --git a/apps/common/main/resources/img/toolbar/1x/btn-user.png b/apps/common/main/resources/img/toolbar/1x/btn-user.png new file mode 100644 index 0000000000000000000000000000000000000000..bc693d9c34fdcf10685141271cd76a25515265a7 GIT binary patch literal 462 zcmV;<0WtoGP)k+!F-d@ZsD@qzREIjC}*sEQO_5HZF zAxnE-!_ugn*D~#7DQn1c_7oMBb$rG8n$5#2Q^ylUnY&bux|<7qkjNUVx8B7nX_Bk> z&CbyW2`d$gqmm}2vgu5y;Xe6v*3gR1mGojahRW2Tvxb(bBa!zDx43MEb}+vTy^DP_ zY%H6hoy@w^?}lu%6wA$d8_UkM@3PMl1&5{VT>I|fh%q6HijE3?H#CNfq8xOG-PlLv zK8?6Y+m3X;H~T_6Ql)EB#_PsMC_K^3;T}&O720$nCRrha>zg_`9hKBHMt^fc407*qoM6N<$ Eg4+q%{{R30 literal 0 HcmV?d00001 diff --git a/apps/common/main/resources/img/toolbar/2x/btn-user.png b/apps/common/main/resources/img/toolbar/2x/btn-user.png new file mode 100644 index 0000000000000000000000000000000000000000..6eb464375f69ded4a32a87342f978af18aa30f0a GIT binary patch literal 1009 zcmeAS@N?(olHy`uVBq!ia0vp^0YI$5!3-qh_VpSAsTBb}A+A8$!NI}R)z#VA*#!pN z+}!?S10Eh8KxGgah*}^Qs2#{gQw}r`C=OQ)F&{z#RYKH5WFc%g>Ez@DQ~;C$x&g=r ziUV~4K^jBhLZDkMN`m}?83YpMpMU>99!e=pP?*raKi|LsOx#ykaDRcp{RQjS*VhLG zG&K187Zeo42PCYYpTDE7=@&1 zpX05>-SP0t>A&mM7-wHpf5`aHJYVBHzta(e5Aq^^SY(fSdQDL)^maCW>({|rCoOei zm!{~E$jQ6ql%Dn1epO=cw^aHTvUazkVDB;Eze>v=3kvd71V011;+fxWD8dN?xATn_j(=`Ou_CvpY^?l$C9qzDq&F zP~ySv*%Aro)*cIBTzu5c>3x2ZmvXk<)r604vK&$tx;%ZsD17s(!x5)$slbp`Kbmt^ zyxab-qb~5H`ptm*`F}f;Hn3O-Sg+}mxX~%j%ISNQZ?&*$*&|oRmPfD8+zmDUqjR+V zz>-I=gG`pH9$mgBr}EC-o8ke@lI!lSj*-hx@msLGjmILqvUAV=@N1us@!mZ+ZS~Vh zt?L<+>ZaM>nKV;FQ7ZOHzt>5|bqgjs?$i{{NQufi<#z1YQCVqrN$K(ps=-D77wS&_ za#J$r_2g`!sV)- zWv=LbP0 Hl+XkKXuRe- literal 0 HcmV?d00001 diff --git a/apps/common/main/resources/less/header.less b/apps/common/main/resources/less/header.less index 9da7f823c..353a07aa0 100644 --- a/apps/common/main/resources/less/header.less +++ b/apps/common/main/resources/less/header.less @@ -206,6 +206,38 @@ } } +.btn-current-user { + display: flex; + align-items: center; + height: 100%; + width: 40px; + padding: 0 10px; + + .icon { + width: 20px; + height: 20px; + display: inline-block; + background-repeat: no-repeat; + padding: 0; + + &.icon--inverse { + background-position-x: -20px; + } + } + + svg.icon { + vertical-align: middle; + + @media + only screen and (-webkit-min-device-pixel-ratio: 1.5), + only screen and (min-resolution: 1.5dppx), + only screen and (min-resolution: 144dpi) { + width:calc(~"28px/1.5"); + height:calc(~"28px/1.5"); + } + } +} + .cousers-menu { position: fixed; top: @height-tabs - 8px; diff --git a/apps/common/main/resources/less/toolbar.less b/apps/common/main/resources/less/toolbar.less index a8f7639d5..63461d4c2 100644 --- a/apps/common/main/resources/less/toolbar.less +++ b/apps/common/main/resources/less/toolbar.less @@ -413,6 +413,16 @@ } } + .btn-current-user { + .icon--inverse { + background-position-x: 0; + } + + svg.icon { + fill: @gray-deep; + } + } + #rib-doc-name { color: @gray-deep; } From fc9530d91926fe8f21baf37d4d82fe677873991c Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 29 Dec 2020 23:48:47 +0300 Subject: [PATCH 9/9] Add customization parameter for setting anonymous name. --- apps/api/documents/api.js | 4 +++ apps/common/main/lib/view/Header.js | 4 +-- .../main/app/controller/Main.js | 25 ++++++++++++------- .../mobile/app/controller/Main.js | 19 +++++++++----- .../main/app/controller/Main.js | 23 +++++++++++------ .../mobile/app/controller/Main.js | 19 +++++++++----- .../main/app/controller/Main.js | 23 +++++++++++------ .../mobile/app/controller/Main.js | 19 +++++++++----- 8 files changed, 91 insertions(+), 45 deletions(-) diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index 222bef8d3..13dcb1f88 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -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, diff --git a/apps/common/main/lib/view/Header.js b/apps/common/main/lib/view/Header.js index 8f3dcfd34..d85ae4fca 100644 --- a/apps/common/main/lib/view/Header.js +++ b/apps/common/main/lib/view/Header.js @@ -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'); diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index ff032ddff..d8a706166 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -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); diff --git a/apps/documenteditor/mobile/app/controller/Main.js b/apps/documenteditor/mobile/app/controller/Main.js index 8c15d1b3b..fa0b58c42 100644 --- a/apps/documenteditor/mobile/app/controller/Main.js +++ b/apps/documenteditor/mobile/app/controller/Main.js @@ -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); diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 36e8fb325..264ba4980 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -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); diff --git a/apps/presentationeditor/mobile/app/controller/Main.js b/apps/presentationeditor/mobile/app/controller/Main.js index f3c021438..53916e3bb 100644 --- a/apps/presentationeditor/mobile/app/controller/Main.js +++ b/apps/presentationeditor/mobile/app/controller/Main.js @@ -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); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 57e9d92fe..6a598a5d8 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -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); diff --git a/apps/spreadsheeteditor/mobile/app/controller/Main.js b/apps/spreadsheeteditor/mobile/app/controller/Main.js index 2584b2408..87e6b1a8c 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/Main.js +++ b/apps/spreadsheeteditor/mobile/app/controller/Main.js @@ -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);