diff --git a/apps/documenteditor/main/app/controller/FormsTab.js b/apps/documenteditor/main/app/controller/FormsTab.js index ffda935a8..61fddb753 100644 --- a/apps/documenteditor/main/app/controller/FormsTab.js +++ b/apps/documenteditor/main/app/controller/FormsTab.js @@ -73,6 +73,7 @@ define([ this.api.asc_registerCallback('asc_onStartAction', _.bind(this.onLongActionBegin, this)); this.api.asc_registerCallback('asc_onEndAction', _.bind(this.onLongActionEnd, this)); this.api.asc_registerCallback('asc_onError', _.bind(this.onError, this)); + this.api.asc_registerCallback('asc_onDownloadUrl', _.bind(this.onDownloadUrl, this)); // this.api.asc_registerCallback('asc_onShowContentControlsActions',_.bind(this.onShowContentControlsActions, this)); // this.api.asc_registerCallback('asc_onHideContentControlsActions',_.bind(this.onHideContentControlsActions, this)); @@ -247,7 +248,43 @@ define([ }, onSaveFormClick: function() { - this.api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.OFORM)); + this.isFromFormSaveAs = this.appConfig.canRequestSaveAs || !!this.appConfig.saveAsUrl; + this.api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.OFORM, this.isFromFormSaveAs)); + }, + + onDownloadUrl: function(url, fileType) { + if (this.isFromFormSaveAs) { + var me = this, + defFileName = this.getApplication().getController('Viewport').getView('Common.Views.Header').getDocumentCaption(); + !defFileName && (defFileName = me.view.txtUntitled); + + var idx = defFileName.lastIndexOf('.'); + if (idx>0) + defFileName = defFileName.substring(0, idx) + '.oform'; + + if (me.appConfig.canRequestSaveAs) { + Common.Gateway.requestSaveAs(url, defFileName, fileType); + } else { + me._saveCopyDlg = new Common.Views.SaveAsDlg({ + saveFolderUrl: me.appConfig.saveAsUrl, + saveFileUrl: url, + defFileName: defFileName + }); + me._saveCopyDlg.on('saveaserror', function(obj, err){ + Common.UI.warning({ + closable: false, + msg: err, + callback: function(btn){ + Common.NotificationCenter.trigger('edit:complete', me); + } + }); + }).on('close', function(obj){ + me._saveCopyDlg = undefined; + }); + me._saveCopyDlg.show(); + } + } + this.isFromFormSaveAs = false; }, disableEditing: function(disable) { diff --git a/apps/documenteditor/main/app/view/FormsTab.js b/apps/documenteditor/main/app/view/FormsTab.js index 15a6776f6..33a6ce3d6 100644 --- a/apps/documenteditor/main/app/view/FormsTab.js +++ b/apps/documenteditor/main/app/view/FormsTab.js @@ -430,7 +430,8 @@ define([ textSubmited: 'Form submitted successfully', textRequired: 'Fill all required fields to send form.', capBtnSaveForm: 'Save as a Form', - tipSaveForm: 'Save a file as a fillable OFORM document' + tipSaveForm: 'Save a file as a fillable OFORM document', + txtUntitled: 'Untitled' } }()), DE.Views.FormsTab || {})); }); \ No newline at end of file diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index fff7a32a4..7e9248164 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -1824,6 +1824,7 @@ "DE.Views.FormsTab.tipSubmit": "Submit form", "DE.Views.FormsTab.tipTextField": "Insert text field", "DE.Views.FormsTab.tipViewForm": "View form", + "DE.Views.FormsTab.txtUntitled": "Untitled", "DE.Views.HeaderFooterSettings.textBottomCenter": "Bottom center", "DE.Views.HeaderFooterSettings.textBottomLeft": "Bottom left", "DE.Views.HeaderFooterSettings.textBottomPage": "Bottom of Page",