Add onRequestSaveAs event

This commit is contained in:
Julia Radzhabova 2019-07-26 12:54:20 +03:00
parent dc5d6576a1
commit 1cff575fd6
11 changed files with 109 additions and 71 deletions

View file

@ -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.");

View file

@ -250,6 +250,16 @@ if (Common === undefined) {
});
},
requestSaveAs: function(url, title) {
_postMessage({
event: 'onRequestSaveAs',
data: {
url: url,
title: title
}
});
},
collaborativeChanges: function() {
_postMessage({event: 'onCollaborativeChanges'});
},

View file

@ -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;
},

View file

@ -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 : '')

View file

@ -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());
}

View file

@ -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;
},

View file

@ -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 : '')

View file

@ -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);

View file

@ -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;
},

View file

@ -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 : '')

View file

@ -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);