[DE] Save form using onRequestSaveAs event or saveAsUrl parameter

This commit is contained in:
Julia Radzhabova 2021-10-20 16:26:55 +03:00
parent a8dc7359c1
commit 13492a66eb
3 changed files with 41 additions and 2 deletions

View file

@ -73,6 +73,7 @@ define([
this.api.asc_registerCallback('asc_onStartAction', _.bind(this.onLongActionBegin, this)); 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_onEndAction', _.bind(this.onLongActionEnd, this));
this.api.asc_registerCallback('asc_onError', _.bind(this.onError, 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_onShowContentControlsActions',_.bind(this.onShowContentControlsActions, this));
// this.api.asc_registerCallback('asc_onHideContentControlsActions',_.bind(this.onHideContentControlsActions, this)); // this.api.asc_registerCallback('asc_onHideContentControlsActions',_.bind(this.onHideContentControlsActions, this));
@ -247,7 +248,43 @@ define([
}, },
onSaveFormClick: function() { 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) { disableEditing: function(disable) {

View file

@ -430,7 +430,8 @@ define([
textSubmited: 'Form submitted successfully', textSubmited: 'Form submitted successfully',
textRequired: 'Fill all required fields to send form.', textRequired: 'Fill all required fields to send form.',
capBtnSaveForm: 'Save as a 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 || {})); }()), DE.Views.FormsTab || {}));
}); });

View file

@ -1824,6 +1824,7 @@
"DE.Views.FormsTab.tipSubmit": "Submit form", "DE.Views.FormsTab.tipSubmit": "Submit form",
"DE.Views.FormsTab.tipTextField": "Insert text field", "DE.Views.FormsTab.tipTextField": "Insert text field",
"DE.Views.FormsTab.tipViewForm": "View form", "DE.Views.FormsTab.tipViewForm": "View form",
"DE.Views.FormsTab.txtUntitled": "Untitled",
"DE.Views.HeaderFooterSettings.textBottomCenter": "Bottom center", "DE.Views.HeaderFooterSettings.textBottomCenter": "Bottom center",
"DE.Views.HeaderFooterSettings.textBottomLeft": "Bottom left", "DE.Views.HeaderFooterSettings.textBottomLeft": "Bottom left",
"DE.Views.HeaderFooterSettings.textBottomPage": "Bottom of Page", "DE.Views.HeaderFooterSettings.textBottomPage": "Bottom of Page",