diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index 34d676abc..d102b7506 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -235,6 +235,19 @@ define([ this.showHistory(); } break; + case 'rename': + var me = this, + documentCaption = me.api.asc_getDocumentName(); + (new Common.Views.RenameDialog({ + filename: documentCaption, + handler: function(result, value) { + if (result == 'ok' && !_.isEmpty(value.trim()) && documentCaption !== value.trim()) { + Common.Gateway.requestRename(value); + } + Common.NotificationCenter.trigger('edit:complete', me); + } + })).show(); + break; default: close_menu = false; } diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 5002066cb..61835263f 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -971,6 +971,7 @@ define([ this.appOptions.canChat = this.appOptions.canLicense && !this.appOptions.isOffline && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.chat===false); this.appOptions.canEditStyles = this.appOptions.canLicense && this.appOptions.canEdit; this.appOptions.canPrint = (this.permissions.print !== false); + this.appOptions.canRename = !!this.permissions.rename; var type = /^(?:(pdf|djvu|xps))$/.exec(this.document.fileType); this.appOptions.canDownloadOrigin = !this.appOptions.nativeApp && this.permissions.download !== false && (type && typeof type[1] === 'string'); @@ -984,7 +985,7 @@ define([ headerView.setBranding(this.editorConfig.customization); params.asc_getTrial() && headerView.setDeveloperMode(true); - this.permissions.rename && headerView.setCanRename(true); + this.appOptions.canRename && headerView.setCanRename(true); this.applyModeCommonElements(); this.applyModeEditorElements(); @@ -1281,6 +1282,7 @@ define([ onCoAuthoringDisconnect: function() { this.getApplication().getController('Viewport').getView('Viewport').setMode({isDisconnected:true}); this.getApplication().getController('Viewport').getView('Common.Views.Header').setCanRename(false); + this.appOptions.canRename = false; this._state.isDisconnected = true; }, diff --git a/apps/documenteditor/main/app/template/FileMenu.template b/apps/documenteditor/main/app/template/FileMenu.template index 7ae80e486..d1ed92b31 100644 --- a/apps/documenteditor/main/app/template/FileMenu.template +++ b/apps/documenteditor/main/app/template/FileMenu.template @@ -7,6 +7,7 @@
+ diff --git a/apps/documenteditor/main/app/view/FileMenu.js b/apps/documenteditor/main/app/view/FileMenu.js index ff406b26e..a72af2cb7 100644 --- a/apps/documenteditor/main/app/view/FileMenu.js +++ b/apps/documenteditor/main/app/view/FileMenu.js @@ -121,6 +121,12 @@ define([ caption : this.btnPrintCaption, canFocused: false }), + new Common.UI.MenuItem({ + el : $('#fm-btn-rename',this.el), + action : 'rename', + caption : this.btnRenameCaption, + canFocused: false + }), new Common.UI.MenuItem({ el : $('#fm-btn-recent',this.el), action : 'recent', @@ -208,9 +214,10 @@ define([ applyMode: function() { this.items[5][this.mode.canPrint?'show':'hide'](); - this.items[6][this.mode.canOpenRecent?'show':'hide'](); - this.items[7][this.mode.canCreateNew?'show':'hide'](); - this.items[7].$el.find('+.devider')[this.mode.canCreateNew?'show':'hide'](); + this.items[6][(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide'](); + this.items[7][this.mode.canOpenRecent?'show':'hide'](); + this.items[8][this.mode.canCreateNew?'show':'hide'](); + this.items[8].$el.find('+.devider')[this.mode.canCreateNew?'show':'hide'](); this.items[3][((this.mode.canDownload || this.mode.canDownloadOrigin) && (!this.mode.isDesktopApp || !this.mode.isOffline))?'show':'hide'](); this.items[4][((this.mode.canDownload || this.mode.canDownloadOrigin) && this.mode.isDesktopApp && this.mode.isOffline)?'show':'hide'](); @@ -219,7 +226,7 @@ define([ this.items[1][this.mode.isEdit?'show':'hide'](); this.items[2][!this.mode.isEdit && this.mode.canEdit && this.mode.canRequestEditRights ?'show':'hide'](); - this.items[9][(!this.mode.isOffline && !this.mode.isReviewOnly && this.document&&this.document.info && + this.items[10][(!this.mode.isOffline && !this.mode.isReviewOnly && this.document&&this.document.info && (this.document.info.sharingSettings&&this.document.info.sharingSettings.length>0 || this.mode.sharingSettingsUrl&&this.mode.sharingSettingsUrl.length))?'show':'hide'](); @@ -232,7 +239,7 @@ define([ if ( this.mode.canCreateNew ) { if (this.mode.templates && this.mode.templates.length) { - $('a',this.items[7].$el).text(this.btnCreateNewCaption + '...'); + $('a',this.items[8].$el).text(this.btnCreateNewCaption + '...'); this.panels['new'] = ((new DE.Views.FileMenuPanels.CreateNew({menu: this, docs: this.mode.templates})).render()); } } @@ -254,8 +261,8 @@ define([ this.panels['help'].setLangConfig(this.mode.lang); - this.items[10][this.mode.canUseHistory?'show':'hide'](); - this.items[10].setDisabled(this.mode.isDisconnected); + this.items[11][this.mode.canUseHistory?'show':'hide'](); + this.items[11].setDisabled(this.mode.isDisconnected); }, setMode: function(mode, delay) { @@ -263,6 +270,7 @@ define([ this.mode.canEdit = this.mode.isEdit = false; this.mode.canOpenRecent = this.mode.canCreateNew = false; this.mode.isDisconnected = mode.isDisconnected; + this.mode.canRename = false; } else { this.mode = mode; } @@ -303,6 +311,7 @@ define([ SetDisabled: function(disable) { this.items[1][(disable || !this.mode.isEdit)?'hide':'show'](); + this.items[6][(disable || !this.mode.canRename || this.mode.isDesktopApp) ?'hide':'show'](); }, btnSaveCaption : 'Save', @@ -319,6 +328,7 @@ define([ btnSettingsCaption : 'Advanced Settings...', btnHistoryCaption : 'Versions History', btnSaveAsCaption : 'Save as', - textDownload : 'Download' + textDownload : 'Download', + btnRenameCaption : 'Rename...' }, DE.Views.FileMenu || {})); }); diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 80c37c408..d0863b14c 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -875,6 +875,7 @@ "DE.Views.FileMenu.btnInfoCaption": "Document Info...", "DE.Views.FileMenu.btnPrintCaption": "Print", "DE.Views.FileMenu.btnRecentFilesCaption": "Open Recent...", + "DE.Views.FileMenu.btnRenameCaption": "Rename...", "DE.Views.FileMenu.btnReturnCaption": "Back to Document", "DE.Views.FileMenu.btnRightsCaption": "Access Rights...", "DE.Views.FileMenu.btnSaveAsCaption": "Save as", diff --git a/apps/presentationeditor/main/app/controller/LeftMenu.js b/apps/presentationeditor/main/app/controller/LeftMenu.js index 134c6021a..f8794b990 100644 --- a/apps/presentationeditor/main/app/controller/LeftMenu.js +++ b/apps/presentationeditor/main/app/controller/LeftMenu.js @@ -196,6 +196,19 @@ define([ if ( isopts ) close_menu = false; else this.onCreateNew(undefined, 'blank'); break; + case 'rename': + var me = this, + documentCaption = me.api.asc_getDocumentName(); + (new Common.Views.RenameDialog({ + filename: documentCaption, + handler: function(result, value) { + if (result == 'ok' && !_.isEmpty(value.trim()) && documentCaption !== value.trim()) { + Common.Gateway.requestRename(value); + } + Common.NotificationCenter.trigger('edit:complete', me); + } + })).show(); + break; default: close_menu = false; } diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index adf033e4a..eeda5f90e 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -739,6 +739,7 @@ define([ this.appOptions.canComments = this.appOptions.canLicense && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.comments===false); this.appOptions.canChat = this.appOptions.canLicense && !this.appOptions.isOffline && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.chat===false); this.appOptions.canPrint = (this.permissions.print !== false); + this.appOptions.canRename = !!this.permissions.rename; this._state.licenseWarning = (licType===Asc.c_oLicenseResult.Connections) && this.appOptions.canEdit && this.editorConfig.mode !== 'view'; @@ -748,7 +749,7 @@ define([ headerView.setBranding(this.editorConfig.customization); params.asc_getTrial() && headerView.setDeveloperMode(true); - this.permissions.rename && headerView.setCanRename(true); + this.appOptions.canRename && headerView.setCanRename(true); this.applyModeCommonElements(); this.applyModeEditorElements(); @@ -1034,6 +1035,7 @@ define([ // TODO: Disable all except 'Download As' and 'Print' this.getApplication().getController('Viewport').getView('Viewport').setMode({isDisconnected:true}); this.getApplication().getController('Viewport').getView('Common.Views.Header').setCanRename(false); + this.appOptions.canRename = false; this._state.isDisconnected = true; // this.getFileMenu().setMode({isDisconnected:true}); }, diff --git a/apps/presentationeditor/main/app/template/FileMenu.template b/apps/presentationeditor/main/app/template/FileMenu.template index 14b6ae939..53e645328 100644 --- a/apps/presentationeditor/main/app/template/FileMenu.template +++ b/apps/presentationeditor/main/app/template/FileMenu.template @@ -7,6 +7,7 @@ + diff --git a/apps/presentationeditor/main/app/view/FileMenu.js b/apps/presentationeditor/main/app/view/FileMenu.js index 3a22ac9b8..5a1b07935 100644 --- a/apps/presentationeditor/main/app/view/FileMenu.js +++ b/apps/presentationeditor/main/app/view/FileMenu.js @@ -124,6 +124,12 @@ define([ caption : this.btnPrintCaption, canFocused: false }), + new Common.UI.MenuItem({ + el : $('#fm-btn-rename',this.el), + action : 'rename', + caption : this.btnRenameCaption, + canFocused: false + }), new Common.UI.MenuItem({ el : $('#fm-btn-recent',this.el), action : 'recent', @@ -205,9 +211,10 @@ define([ applyMode: function() { this.items[5][this.mode.canPrint?'show':'hide'](); - this.items[6][this.mode.canOpenRecent?'show':'hide'](); - this.items[7][this.mode.canCreateNew?'show':'hide'](); - this.items[7].$el.find('+.devider')[this.mode.canCreateNew?'show':'hide'](); + this.items[6][(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide'](); + this.items[7][this.mode.canOpenRecent?'show':'hide'](); + this.items[8][this.mode.canCreateNew?'show':'hide'](); + this.items[8].$el.find('+.devider')[this.mode.canCreateNew?'show':'hide'](); this.items[3][(this.mode.canDownload && (!this.mode.isDesktopApp || !this.mode.isOffline))?'show':'hide'](); this.items[4][(this.mode.canDownload && this.mode.isDesktopApp && this.mode.isOffline)?'show':'hide'](); @@ -217,7 +224,7 @@ define([ this.items[1][this.mode.isEdit?'show':'hide'](); this.items[2][!this.mode.isEdit && this.mode.canEdit && this.mode.canRequestEditRights ?'show':'hide'](); - this.items[9][(!this.mode.isOffline && this.document&&this.document.info&&(this.document.info.sharingSettings&&this.document.info.sharingSettings.length>0 || + this.items[10][(!this.mode.isOffline && this.document&&this.document.info&&(this.document.info.sharingSettings&&this.document.info.sharingSettings.length>0 || this.mode.sharingSettingsUrl&&this.mode.sharingSettingsUrl.length))?'show':'hide'](); this.mode.canBack ? this.$el.find('#fm-btn-back').show().prev().show() : @@ -229,7 +236,7 @@ define([ if ( this.mode.canCreateNew ) { if (this.mode.templates && this.mode.templates.length) { - $('a',this.items[7].$el).text(this.btnCreateNewCaption + '...'); + $('a',this.items[8].$el).text(this.btnCreateNewCaption + '...'); this.panels['new'] = ((new PE.Views.FileMenuPanels.CreateNew({menu: this, docs: this.mode.templates})).render()); } } @@ -251,6 +258,7 @@ define([ if (mode.isDisconnected) { this.mode.canEdit = this.mode.isEdit = false; this.mode.canOpenRecent = this.mode.canCreateNew = false; + this.mode.canRename = false; } else { this.mode = mode; } @@ -315,6 +323,7 @@ define([ btnToEditCaption : 'Edit Document', btnBackCaption : 'Go to Documents', btnSettingsCaption : 'Advanced Settings...', - btnSaveAsCaption : 'Save as' + btnSaveAsCaption : 'Save as', + btnRenameCaption : 'Rename...' }, PE.Views.FileMenu || {})); }); diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json index 8a1d4470f..ce72e24fc 100644 --- a/apps/presentationeditor/main/locale/en.json +++ b/apps/presentationeditor/main/locale/en.json @@ -344,6 +344,7 @@ "PE.Views.FileMenu.btnInfoCaption": "Presentation Info...", "PE.Views.FileMenu.btnPrintCaption": "Print", "PE.Views.FileMenu.btnRecentFilesCaption": "Open Recent...", + "PE.Views.FileMenu.btnRenameCaption": "Rename...", "PE.Views.FileMenu.btnReturnCaption": "Back to Presentation", "PE.Views.FileMenu.btnRightsCaption": "Access Rights...", "PE.Views.FileMenu.btnSaveAsCaption": "Save as", diff --git a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js index 9fa4d3598..e5482dcbc 100644 --- a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js @@ -205,6 +205,19 @@ define([ if ( isopts ) close_menu = false; else this.onCreateNew(undefined, 'blank'); break; + case 'rename': + var me = this, + documentCaption = me.api.asc_getDocumentName(); + (new Common.Views.RenameDialog({ + filename: documentCaption, + handler: function(result, value) { + if (result == 'ok' && !_.isEmpty(value.trim()) && documentCaption !== value.trim()) { + Common.Gateway.requestRename(value); + } + Common.NotificationCenter.trigger('edit:complete', me); + } + })).show(); + break; default: close_menu = false; } diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 61be069d9..c6e57cea0 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -759,13 +759,14 @@ define([ /** coauthoring end **/ this.appOptions.canComments = this.appOptions.canLicense && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.comments===false); this.appOptions.canChat = this.appOptions.canLicense && !this.appOptions.isOffline && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.chat===false); + this.appOptions.canRename = !!this.permissions.rename; this.appOptions.canBranding = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object'); if (this.appOptions.canBranding) this.headerView.setBranding(this.editorConfig.customization); params.asc_getTrial() && this.headerView.setDeveloperMode(true); - this.permissions.rename && this.headerView.setCanRename(true); + this.appOptions.canRename && this.headerView.setCanRename(true); } this.appOptions.canRequestEditRights = this.editorConfig.canRequestEditRights; @@ -1186,6 +1187,7 @@ define([ onCoAuthoringDisconnect: function() { this.getApplication().getController('Viewport').getView('Viewport').setMode({isDisconnected:true}); this.getApplication().getController('Viewport').getView('Common.Views.Header').setCanRename(false); + this.appOptions.canRename = false; this._state.isDisconnected = true; }, diff --git a/apps/spreadsheeteditor/main/app/template/FileMenu.template b/apps/spreadsheeteditor/main/app/template/FileMenu.template index 14b6ae939..53e645328 100644 --- a/apps/spreadsheeteditor/main/app/template/FileMenu.template +++ b/apps/spreadsheeteditor/main/app/template/FileMenu.template @@ -7,6 +7,7 @@ + diff --git a/apps/spreadsheeteditor/main/app/view/FileMenu.js b/apps/spreadsheeteditor/main/app/view/FileMenu.js index e66a24df5..5772c7d6c 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenu.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenu.js @@ -111,6 +111,12 @@ define([ caption : this.btnPrintCaption, canFocused: false }), + new Common.UI.MenuItem({ + el : $('#fm-btn-rename',this.el), + action : 'rename', + caption : this.btnRenameCaption, + canFocused: false + }), new Common.UI.MenuItem({ el : $('#fm-btn-recent',this.el), action : 'recent', @@ -191,9 +197,10 @@ define([ applyMode: function() { this.items[5][this.mode.canPrint?'show':'hide'](); - this.items[6][this.mode.canOpenRecent?'show':'hide'](); - this.items[7][this.mode.canCreateNew?'show':'hide'](); - this.items[7].$el.find('+.devider')[this.mode.canCreateNew?'show':'hide'](); + this.items[6][(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide'](); + this.items[7][this.mode.canOpenRecent?'show':'hide'](); + this.items[8][this.mode.canCreateNew?'show':'hide'](); + this.items[8].$el.find('+.devider')[this.mode.canCreateNew?'show':'hide'](); this.items[3][(this.mode.canDownload && (!this.mode.isDesktopApp || !this.mode.isOffline))?'show':'hide'](); this.items[4][(this.mode.canDownload && this.mode.isDesktopApp && this.mode.isOffline)?'show':'hide'](); @@ -202,11 +209,11 @@ define([ this.items[1][this.mode.isEdit?'show':'hide'](); this.items[2][!this.mode.isEdit && this.mode.canEdit && this.mode.canRequestEditRights ?'show':'hide'](); - this.items[9][(!this.mode.isOffline && this.document&&this.document.info&&(this.document.info.sharingSettings&&this.document.info.sharingSettings.length>0 || + this.items[10][(!this.mode.isOffline && this.document&&this.document.info&&(this.document.info.sharingSettings&&this.document.info.sharingSettings.length>0 || this.mode.sharingSettingsUrl&&this.mode.sharingSettingsUrl.length))?'show':'hide'](); - this.items[10][this.mode.isEdit?'show':'hide'](); - this.items[10].$el.find('+.devider')[this.mode.isEdit?'show':'hide'](); + this.items[11][this.mode.isEdit?'show':'hide'](); + this.items[11].$el.find('+.devider')[this.mode.isEdit?'show':'hide'](); this.mode.canBack ? this.$el.find('#fm-btn-back').show().prev().show() : this.$el.find('#fm-btn-back').hide().prev().hide(); @@ -217,7 +224,7 @@ define([ if ( this.mode.canCreateNew ) { if (this.mode.templates && this.mode.templates.length) { - $('a',this.items[7].$el).text(this.btnCreateNewCaption + '...'); + $('a',this.items[8].$el).text(this.btnCreateNewCaption + '...'); this.panels['new'] = ((new SSE.Views.FileMenuPanels.CreateNew({menu: this, docs: this.mode.templates})).render()); } } @@ -235,6 +242,7 @@ define([ if (mode.isDisconnected) { this.mode.canEdit = this.mode.isEdit = false; this.mode.canOpenRecent = this.mode.canCreateNew = false; + this.mode.canRename = false; } else { this.mode = mode; } @@ -291,6 +299,7 @@ define([ btnToEditCaption : 'Edit Document', btnBackCaption : 'Go to Documents', btnSettingsCaption : 'Advanced Settings...', - btnSaveAsCaption : 'Save as' + btnSaveAsCaption : 'Save as', + btnRenameCaption : 'Rename...' }, SSE.Views.FileMenu || {})); }); diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index c3d89c0b1..51cc67dd2 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -532,6 +532,7 @@ "SSE.Views.FileMenu.btnInfoCaption": "Spreadsheet Info...", "SSE.Views.FileMenu.btnPrintCaption": "Print", "SSE.Views.FileMenu.btnRecentFilesCaption": "Open Recent...", + "SSE.Views.FileMenu.btnRenameCaption": "Rename...", "SSE.Views.FileMenu.btnReturnCaption": "Back to Spreadsheet", "SSE.Views.FileMenu.btnRightsCaption": "Access Rights...", "SSE.Views.FileMenu.btnSaveAsCaption": "Save as",