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.',