diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index 50848e08f..455f8d4d7 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -202,6 +202,7 @@ _config.editorConfig.canRequestUsers = _config.events && !!_config.events.onRequestUsers; _config.editorConfig.canRequestSendNotify = _config.events && !!_config.events.onRequestSendNotify; _config.editorConfig.mergeFolderUrl = _config.editorConfig.mergeFolderUrl || _config.editorConfig.saveAsUrl; + _config.editorConfig.canRequestSaveAs = _config.events && !!_config.events.onRequestSaveAs; _config.frameEditorId = placeholderId; _config.events && !!_config.events.onReady && console.log("Obsolete: The onReady event is deprecated. Please use onAppReady instead."); diff --git a/apps/common/Gateway.js b/apps/common/Gateway.js index 373c41e58..53c0b1e65 100644 --- a/apps/common/Gateway.js +++ b/apps/common/Gateway.js @@ -250,6 +250,16 @@ if (Common === undefined) { }); }, + requestSaveAs: function(url, title) { + _postMessage({ + event: 'onRequestSaveAs', + data: { + url: url, + title: title + } + }); + }, + collaborativeChanges: function() { _postMessage({event: 'onCollaborativeChanges'}); }, diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index e5089cf80..e361dca68 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -400,27 +400,31 @@ define([ defFileName = defFileName.substring(0, idx) + this.isFromFileDownloadAs; } - me._saveCopyDlg = new Common.Views.SaveAsDlg({ - saveFolderUrl: me.mode.saveAsUrl, - saveFileUrl: url, - defFileName: defFileName - }); - me._saveCopyDlg.on('saveaserror', function(obj, err){ - var config = { - closable: false, - title: me.notcriticalErrorTitle, - msg: err, - iconCls: 'warn', - buttons: ['ok'], - callback: function(btn){ - Common.NotificationCenter.trigger('edit:complete', me); - } - }; - Common.UI.alert(config); - }).on('close', function(obj){ - me._saveCopyDlg = undefined; - }); - me._saveCopyDlg.show(); + if (me.mode.canRequestSaveAs) { + Common.Gateway.requestSaveAs(url, defFileName); + } else { + me._saveCopyDlg = new Common.Views.SaveAsDlg({ + saveFolderUrl: me.mode.saveAsUrl, + saveFileUrl: url, + defFileName: defFileName + }); + me._saveCopyDlg.on('saveaserror', function(obj, err){ + var config = { + closable: false, + title: me.notcriticalErrorTitle, + msg: err, + iconCls: 'warn', + buttons: ['ok'], + callback: function(btn){ + Common.NotificationCenter.trigger('edit:complete', me); + } + }; + Common.UI.alert(config); + }).on('close', function(obj){ + me._saveCopyDlg = undefined; + }); + me._saveCopyDlg.show(); + } } this.isFromFileDownloadAs = false; }, diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index ebcb64a20..b02214660 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -349,6 +349,7 @@ define([ this.appOptions.canMakeActionLink = this.editorConfig.canMakeActionLink; this.appOptions.canRequestUsers = this.editorConfig.canRequestUsers; this.appOptions.canRequestSendNotify = this.editorConfig.canRequestSendNotify; + this.appOptions.canRequestSaveAs = this.editorConfig.canRequestSaveAs; appHeader = this.getApplication().getController('Viewport').getView('Common.Views.Header'); appHeader.setCanBack(this.appOptions.canBackToFolder === true, (this.appOptions.canBackToFolder) ? this.editorConfig.customization.goback.text : '') diff --git a/apps/documenteditor/main/app/view/FileMenu.js b/apps/documenteditor/main/app/view/FileMenu.js index 42b20e6ba..ef6aa6879 100644 --- a/apps/documenteditor/main/app/view/FileMenu.js +++ b/apps/documenteditor/main/app/view/FileMenu.js @@ -259,7 +259,7 @@ define([ this.miNew.$el.find('+.devider')[this.mode.canCreateNew?'show':'hide'](); this.miDownload[((this.mode.canDownload || this.mode.canDownloadOrigin) && (!this.mode.isDesktopApp || !this.mode.isOffline))?'show':'hide'](); - this.miSaveCopyAs[((this.mode.canDownload || this.mode.canDownloadOrigin) && (!this.mode.isDesktopApp || !this.mode.isOffline)) && this.mode.saveAsUrl ?'show':'hide'](); + this.miSaveCopyAs[((this.mode.canDownload || this.mode.canDownloadOrigin) && (!this.mode.isDesktopApp || !this.mode.isOffline)) && (this.mode.canRequestSaveAs || this.mode.saveAsUrl) ?'show':'hide'](); this.miSaveAs[((this.mode.canDownload || this.mode.canDownloadOrigin) && this.mode.isDesktopApp && this.mode.isOffline)?'show':'hide'](); // this.hkSaveAs[this.mode.canDownload?'enable':'disable'](); @@ -306,7 +306,7 @@ define([ } else if (this.mode.canDownloadOrigin) $('a',this.miDownload.$el).text(this.textDownload); - if (this.mode.canDownload && this.mode.saveAsUrl) { + if (this.mode.canDownload && (this.mode.canRequestSaveAs || this.mode.saveAsUrl)) { this.panels['save-copy'] = ((new DE.Views.FileMenuPanels.ViewSaveCopy({menu: this})).render()); } diff --git a/apps/presentationeditor/main/app/controller/LeftMenu.js b/apps/presentationeditor/main/app/controller/LeftMenu.js index c206574d2..1b65c7a0f 100644 --- a/apps/presentationeditor/main/app/controller/LeftMenu.js +++ b/apps/presentationeditor/main/app/controller/LeftMenu.js @@ -269,27 +269,31 @@ define([ defFileName = defFileName.substring(0, idx) + this.isFromFileDownloadAs; } - me._saveCopyDlg = new Common.Views.SaveAsDlg({ - saveFolderUrl: me.mode.saveAsUrl, - saveFileUrl: url, - defFileName: defFileName - }); - me._saveCopyDlg.on('saveaserror', function(obj, err){ - var config = { - closable: false, - title: me.notcriticalErrorTitle, - msg: err, - iconCls: 'warn', - buttons: ['ok'], - callback: function(btn){ - Common.NotificationCenter.trigger('edit:complete', me); - } - }; - Common.UI.alert(config); - }).on('close', function(obj){ - me._saveCopyDlg = undefined; - }); - me._saveCopyDlg.show(); + if (me.mode.canRequestSaveAs) { + Common.Gateway.requestSaveAs(url, defFileName); + } else { + me._saveCopyDlg = new Common.Views.SaveAsDlg({ + saveFolderUrl: me.mode.saveAsUrl, + saveFileUrl: url, + defFileName: defFileName + }); + me._saveCopyDlg.on('saveaserror', function(obj, err){ + var config = { + closable: false, + title: me.notcriticalErrorTitle, + msg: err, + iconCls: 'warn', + buttons: ['ok'], + callback: function(btn){ + Common.NotificationCenter.trigger('edit:complete', me); + } + }; + Common.UI.alert(config); + }).on('close', function(obj){ + me._saveCopyDlg = undefined; + }); + me._saveCopyDlg.show(); + } } this.isFromFileDownloadAs = false; }, diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 926f0962d..8cde163ce 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -316,6 +316,7 @@ define([ this.appOptions.canPlugins = false; this.appOptions.canRequestUsers = this.editorConfig.canRequestUsers; this.appOptions.canRequestSendNotify = this.editorConfig.canRequestSendNotify; + this.appOptions.canRequestSaveAs = this.editorConfig.canRequestSaveAs; appHeader = this.getApplication().getController('Viewport').getView('Common.Views.Header'); appHeader.setCanBack(this.appOptions.canBackToFolder === true, (this.appOptions.canBackToFolder) ? this.editorConfig.customization.goback.text : '') diff --git a/apps/presentationeditor/main/app/view/FileMenu.js b/apps/presentationeditor/main/app/view/FileMenu.js index 4cc11dc79..3a7fa0803 100644 --- a/apps/presentationeditor/main/app/view/FileMenu.js +++ b/apps/presentationeditor/main/app/view/FileMenu.js @@ -214,8 +214,6 @@ define([ var me = this; me.panels = { - 'saveas' : (new PE.Views.FileMenuPanels.ViewSaveAs({menu:me})).render(), - 'save-copy' : (new PE.Views.FileMenuPanels.ViewSaveCopy({menu:me})).render(), 'opts' : (new PE.Views.FileMenuPanels.Settings({menu:me})).render(), 'info' : (new PE.Views.FileMenuPanels.DocumentInfo({menu:me})).render(), 'rights' : (new PE.Views.FileMenuPanels.DocumentRights({menu:me})).render() @@ -256,7 +254,7 @@ define([ this.miNew.$el.find('+.devider')[this.mode.canCreateNew?'show':'hide'](); this.miDownload[(this.mode.canDownload && (!this.mode.isDesktopApp || !this.mode.isOffline))?'show':'hide'](); - this.miSaveCopyAs[((this.mode.canDownload || this.mode.canDownloadOrigin) && (!this.mode.isDesktopApp || !this.mode.isOffline)) && this.mode.saveAsUrl ?'show':'hide'](); + this.miSaveCopyAs[((this.mode.canDownload || this.mode.canDownloadOrigin) && (!this.mode.isDesktopApp || !this.mode.isOffline)) && (this.mode.canRequestSaveAs || this.mode.saveAsUrl) ?'show':'hide'](); this.miSaveAs[(this.mode.canDownload && this.mode.isDesktopApp && this.mode.isOffline)?'show':'hide'](); // this.hkSaveAs[this.mode.canDownload?'enable':'disable'](); @@ -297,6 +295,14 @@ define([ this.panels['protect'].setMode(this.mode); } + if (this.mode.canDownload) { + this.panels['saveas'] = ((new PE.Views.FileMenuPanels.ViewSaveAs({menu: this})).render()); + } + + if (this.mode.canDownload && (this.mode.canRequestSaveAs || this.mode.saveAsUrl)) { + this.panels['save-copy'] = ((new PE.Views.FileMenuPanels.ViewSaveCopy({menu: this})).render()); + } + if (this.mode.canHelp) { this.panels['help'] = ((new PE.Views.FileMenuPanels.Help({menu: this})).render()); this.panels['help'].setLangConfig(this.mode.lang); diff --git a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js index 6c6bd98de..4667170d1 100644 --- a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js @@ -315,27 +315,31 @@ define([ defFileName = defFileName.substring(0, idx) + this.isFromFileDownloadAs; } - me._saveCopyDlg = new Common.Views.SaveAsDlg({ - saveFolderUrl: me.mode.saveAsUrl, - saveFileUrl: url, - defFileName: defFileName - }); - me._saveCopyDlg.on('saveaserror', function(obj, err){ - var config = { - closable: false, - title: me.textWarning, - msg: err, - iconCls: 'warn', - buttons: ['ok'], - callback: function(btn){ - Common.NotificationCenter.trigger('edit:complete', me); - } - }; - Common.UI.alert(config); - }).on('close', function(obj){ - me._saveCopyDlg = undefined; - }); - me._saveCopyDlg.show(); + if (me.mode.canRequestSaveAs) { + Common.Gateway.requestSaveAs(url, defFileName); + } else { + me._saveCopyDlg = new Common.Views.SaveAsDlg({ + saveFolderUrl: me.mode.saveAsUrl, + saveFileUrl: url, + defFileName: defFileName + }); + me._saveCopyDlg.on('saveaserror', function(obj, err){ + var config = { + closable: false, + title: me.textWarning, + msg: err, + iconCls: 'warn', + buttons: ['ok'], + callback: function(btn){ + Common.NotificationCenter.trigger('edit:complete', me); + } + }; + Common.UI.alert(config); + }).on('close', function(obj){ + me._saveCopyDlg = undefined; + }); + me._saveCopyDlg.show(); + } } this.isFromFileDownloadAs = false; }, diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 24bb00796..c8be815d9 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -322,6 +322,7 @@ define([ this.appOptions.canPlugins = false; this.appOptions.canRequestUsers = this.editorConfig.canRequestUsers; this.appOptions.canRequestSendNotify = this.editorConfig.canRequestSendNotify; + this.appOptions.canRequestSaveAs = this.editorConfig.canRequestSaveAs; 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 : '') diff --git a/apps/spreadsheeteditor/main/app/view/FileMenu.js b/apps/spreadsheeteditor/main/app/view/FileMenu.js index b4600ab43..722d725c1 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenu.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenu.js @@ -203,8 +203,6 @@ define([ var me = this; me.panels = { - 'saveas' : (new SSE.Views.FileMenuPanels.ViewSaveAs({menu:me})).render(), - 'save-copy' : (new SSE.Views.FileMenuPanels.ViewSaveCopy({menu:me})).render(), 'opts' : (new SSE.Views.FileMenuPanels.Settings({menu:me})).render(), 'info' : (new SSE.Views.FileMenuPanels.DocumentInfo({menu:me})).render(), 'rights' : (new SSE.Views.FileMenuPanels.DocumentRights({menu:me})).render() @@ -245,7 +243,7 @@ define([ this.miNew.$el.find('+.devider')[this.mode.canCreateNew?'show':'hide'](); this.miDownload[(this.mode.canDownload && (!this.mode.isDesktopApp || !this.mode.isOffline))?'show':'hide'](); - this.miSaveCopyAs[((this.mode.canDownload || this.mode.canDownloadOrigin) && (!this.mode.isDesktopApp || !this.mode.isOffline)) && this.mode.saveAsUrl ?'show':'hide'](); + this.miSaveCopyAs[((this.mode.canDownload || this.mode.canDownloadOrigin) && (!this.mode.isDesktopApp || !this.mode.isOffline)) && (this.mode.canRequestSaveAs || this.mode.saveAsUrl) ?'show':'hide'](); this.miSaveAs[(this.mode.canDownload && this.mode.isDesktopApp && this.mode.isOffline)?'show':'hide'](); // this.hkSaveAs[this.mode.canDownload?'enable':'disable'](); @@ -288,6 +286,14 @@ define([ this.panels['protect'].setMode(this.mode); } + if (this.mode.canDownload) { + this.panels['saveas'] = ((new SSE.Views.FileMenuPanels.ViewSaveAs({menu: this})).render()); + } + + if (this.mode.canDownload && (this.mode.canRequestSaveAs || this.mode.saveAsUrl)) { + this.panels['save-copy'] = ((new SSE.Views.FileMenuPanels.ViewSaveCopy({menu: this})).render()); + } + if (this.mode.canHelp) { this.panels['help'] = ((new SSE.Views.FileMenuPanels.Help({menu: this})).render()); this.panels['help'].setLangConfig(this.mode.lang);