[DE] Add 'Save Copy As' action to file menu. Bug 23603, Bug 32790
This commit is contained in:
parent
2272e6e7bb
commit
a8482985e8
|
@ -44,7 +44,8 @@ define([
|
|||
'core',
|
||||
'common/main/lib/util/Shortcuts',
|
||||
'documenteditor/main/app/view/LeftMenu',
|
||||
'documenteditor/main/app/view/FileMenu'
|
||||
'documenteditor/main/app/view/FileMenu',
|
||||
'documenteditor/main/app/view/MailMergeSaveDlg'
|
||||
], function () {
|
||||
'use strict';
|
||||
|
||||
|
@ -85,6 +86,7 @@ define([
|
|||
'menu:show': _.bind(this.menuFilesShowHide, this, 'show'),
|
||||
'item:click': _.bind(this.clickMenuFileItem, this),
|
||||
'saveas:format': _.bind(this.clickSaveAsFormat, this),
|
||||
'savecopy:format': _.bind(this.clickSaveCopyAsFormat, this),
|
||||
'settings:apply': _.bind(this.applySettings, this),
|
||||
'create:new': _.bind(this.onCreateNew, this),
|
||||
'recent:open': _.bind(this.onOpenRecent, this)
|
||||
|
@ -143,6 +145,7 @@ define([
|
|||
this.api.asc_registerCallback('asc_onReplaceAll', _.bind(this.onApiTextReplaced, this));
|
||||
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onApiServerDisconnect, this, true));
|
||||
Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiServerDisconnect, this));
|
||||
this.api.asc_registerCallback('asc_onDownloadUrl', _.bind(this.onDownloadUrl, this));
|
||||
/** coauthoring begin **/
|
||||
if (this.mode.canCoAuthoring) {
|
||||
if (this.mode.canChat)
|
||||
|
@ -229,6 +232,10 @@ define([
|
|||
if ( isopts ) close_menu = false;
|
||||
else this.clickSaveAsFormat(undefined);
|
||||
break;
|
||||
case 'save-copy':
|
||||
if ( isopts ) close_menu = false;
|
||||
else this.clickSaveCopyAsFormat(undefined);
|
||||
break;
|
||||
case 'print': this.api.asc_Print(Common.Utils.isChrome || Common.Utils.isSafari || Common.Utils.isOpera); break;
|
||||
case 'exit': Common.NotificationCenter.trigger('goback'); break;
|
||||
case 'edit':
|
||||
|
@ -307,6 +314,70 @@ define([
|
|||
this.api.asc_DownloadOrigin();
|
||||
},
|
||||
|
||||
clickSaveCopyAsFormat: function(menu, format, ext) {
|
||||
if (menu) {
|
||||
if (format == Asc.c_oAscFileType.TXT || format == Asc.c_oAscFileType.RTF) {
|
||||
Common.UI.warning({
|
||||
closable: false,
|
||||
title: this.notcriticalErrorTitle,
|
||||
msg: (format == Asc.c_oAscFileType.TXT) ? this.warnDownloadAs : this.warnDownloadAsRTF,
|
||||
buttons: ['ok', 'cancel'],
|
||||
callback: _.bind(function(btn){
|
||||
if (btn == 'ok') {
|
||||
this.isFromFileDownloadAs = ext;
|
||||
this.api.asc_DownloadAs(format, true);
|
||||
menu.hide();
|
||||
}
|
||||
}, this)
|
||||
});
|
||||
} else {
|
||||
this.isFromFileDownloadAs = ext;
|
||||
this.api.asc_DownloadAs(format, true);
|
||||
menu.hide();
|
||||
}
|
||||
} else {
|
||||
this.isFromFileDownloadAs = true;
|
||||
this.api.asc_DownloadOrigin(true);
|
||||
}
|
||||
},
|
||||
|
||||
onDownloadUrl: function(url) {
|
||||
if (this.isFromFileDownloadAs) {
|
||||
var me = this,
|
||||
defFileName = this.getApplication().getController('Viewport').getView('Common.Views.Header').getDocumentCaption();
|
||||
!defFileName && (defFileName = me.txtUntitled);
|
||||
|
||||
if (typeof this.isFromFileDownloadAs == 'string') {
|
||||
var idx = defFileName.lastIndexOf('.');
|
||||
if (idx>0)
|
||||
defFileName = defFileName.substring(0, idx) + this.isFromFileDownloadAs;
|
||||
}
|
||||
|
||||
me._saveCopyDlg = new DE.Views.MailMergeSaveDlg({
|
||||
mergeFolderUrl: me.mode.saveCopyFolderUrl,
|
||||
mergedFileUrl: url,
|
||||
defFileName: defFileName
|
||||
});
|
||||
me._saveCopyDlg.on('mailmergeerror', function(obj, err){
|
||||
var config = {
|
||||
closable: false,
|
||||
title: this.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;
|
||||
},
|
||||
|
||||
applySettings: function(menu) {
|
||||
var value;
|
||||
|
||||
|
@ -732,6 +803,7 @@ define([
|
|||
notcriticalErrorTitle: 'Warning',
|
||||
leavePageText: 'All unsaved changes in this document will be lost.<br> Click \'Cancel\' then \'Save\' to save them. Click \'OK\' to discard all the unsaved changes.',
|
||||
warnDownloadAs : 'If you continue saving in this format all features except the text will be lost.<br>Are you sure you want to continue?',
|
||||
warnDownloadAsRTF : 'If you continue saving in this format some of the formatting might be lost.<br>Are you sure you want to continue?'
|
||||
warnDownloadAsRTF : 'If you continue saving in this format some of the formatting might be lost.<br>Are you sure you want to continue?',
|
||||
txtUntitled: 'Untitled'
|
||||
}, DE.Controllers.LeftMenu || {}));
|
||||
});
|
|
@ -305,6 +305,7 @@ define([
|
|||
this.appOptions.sharingSettingsUrl = this.editorConfig.sharingSettingsUrl;
|
||||
this.appOptions.fileChoiceUrl = this.editorConfig.fileChoiceUrl;
|
||||
this.appOptions.mergeFolderUrl = this.editorConfig.mergeFolderUrl;
|
||||
this.appOptions.saveCopyFolderUrl = this.editorConfig.saveCopyFolderUrl;
|
||||
this.appOptions.canAnalytics = false;
|
||||
this.appOptions.customization = this.editorConfig.customization;
|
||||
this.appOptions.canBackToFolder = (this.editorConfig.canBackToFolder!==false) && (typeof (this.editorConfig.customization) == 'object')
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<li id="fm-btn-save" class="fm-btn" />
|
||||
<li id="fm-btn-edit" class="fm-btn" />
|
||||
<li id="fm-btn-download" class="fm-btn" />
|
||||
<li id="fm-btn-save-copy" class="fm-btn" />
|
||||
<li id="fm-btn-save-desktop" class="fm-btn" />
|
||||
<li id="fm-btn-print" class="fm-btn" />
|
||||
<li id="fm-btn-rename" class="fm-btn" />
|
||||
|
@ -25,6 +26,7 @@
|
|||
</div>
|
||||
<div class="panel-context">
|
||||
<div id="panel-saveas" class="content-box" />
|
||||
<div id="panel-savecopy" class="content-box" />
|
||||
<div id="panel-recentfiles" class="content-box" />
|
||||
<div id="panel-createnew" class="content-box" />
|
||||
<div id="panel-info" class="content-box" />
|
||||
|
|
|
@ -105,6 +105,13 @@ define([
|
|||
canFocused: false
|
||||
});
|
||||
|
||||
this.miSaveCopyAs = new Common.UI.MenuItem({
|
||||
el : $('#fm-btn-save-copy',this.el),
|
||||
action : 'save-copy',
|
||||
caption : this.btnSaveCopyAsCaption,
|
||||
canFocused: false
|
||||
});
|
||||
|
||||
this.miSaveAs = new Common.UI.MenuItem({
|
||||
el : $('#fm-btn-save-desktop',this.el),
|
||||
action : 'save-desktop',
|
||||
|
@ -179,6 +186,7 @@ define([
|
|||
this.miSave,
|
||||
this.miEdit,
|
||||
this.miDownload,
|
||||
this.miSaveCopyAs,
|
||||
this.miSaveAs,
|
||||
this.miPrint,
|
||||
this.miRename,
|
||||
|
@ -251,6 +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.saveCopyFolderUrl ?'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']();
|
||||
|
||||
|
@ -295,6 +304,10 @@ define([
|
|||
} else if (this.mode.canDownloadOrigin)
|
||||
$('a',this.miDownload.$el).text(this.textDownload);
|
||||
|
||||
if (this.mode.canDownload && this.mode.saveCopyFolderUrl) {
|
||||
this.panels['save-copy'] = ((new DE.Views.FileMenuPanels.ViewSaveCopy({menu: this})).render());
|
||||
}
|
||||
|
||||
if (this.mode.canHelp) {
|
||||
this.panels['help'] = ((new DE.Views.FileMenuPanels.Help({menu: this})).render());
|
||||
this.panels['help'].setLangConfig(this.mode.lang);
|
||||
|
@ -385,6 +398,7 @@ define([
|
|||
textDownload : 'Download',
|
||||
btnRenameCaption : 'Rename...',
|
||||
btnCloseMenuCaption : 'Close Menu',
|
||||
btnProtectCaption: 'Protect'
|
||||
btnProtectCaption: 'Protect',
|
||||
btnSaveCopyAsCaption : 'Save Copy as...'
|
||||
}, DE.Views.FileMenu || {}));
|
||||
});
|
||||
|
|
|
@ -107,6 +107,67 @@ define([
|
|||
}
|
||||
});
|
||||
|
||||
DE.Views.FileMenuPanels.ViewSaveCopy = Common.UI.BaseView.extend({
|
||||
el: '#panel-savecopy',
|
||||
menu: undefined,
|
||||
|
||||
formats: [[
|
||||
{name: 'DOCX', imgCls: 'docx', type: Asc.c_oAscFileType.DOCX, ext: '.docx'},
|
||||
{name: 'PDF', imgCls: 'pdf', type: Asc.c_oAscFileType.PDF, ext: '.pdf'},
|
||||
{name: 'PDFA', imgCls: 'pdfa', type: Asc.c_oAscFileType.PDFA, ext: '.pdf'},
|
||||
{name: 'TXT', imgCls: 'txt', type: Asc.c_oAscFileType.TXT, ext: '.txt'}
|
||||
],[
|
||||
// {name: 'DOC', imgCls: 'doc-format btn-doc', type: Asc.c_oAscFileType.DOC, ext: '.doc'},
|
||||
{name: 'ODT', imgCls: 'odt', type: Asc.c_oAscFileType.ODT, ext: '.odt'},
|
||||
{name: 'RTF', imgCls: 'rtf', type: Asc.c_oAscFileType.RTF, ext: '.rtf'},
|
||||
{name: 'HTML (Zipped)', imgCls: 'html', type: Asc.c_oAscFileType.HTML, ext: '.html'}
|
||||
// {name: 'EPUB', imgCls: 'doc-format btn-epub', type: Asc.c_oAscFileType.EPUB, ext: '.epub'}
|
||||
]],
|
||||
|
||||
|
||||
template: _.template([
|
||||
'<table><tbody>',
|
||||
'<% _.each(rows, function(row) { %>',
|
||||
'<tr>',
|
||||
'<% _.each(row, function(item) { %>',
|
||||
'<td><div><svg class="btn-doc-format" format="<%= item.type %>", format-ext="<%= item.ext %>">',
|
||||
'<use xlink:href="#svg-format-<%= item.imgCls %>"></use>',
|
||||
'</svg></div></td>',
|
||||
'<% }) %>',
|
||||
'</tr>',
|
||||
'<% }) %>',
|
||||
'</tbody></table>'
|
||||
].join('')),
|
||||
|
||||
initialize: function(options) {
|
||||
Common.UI.BaseView.prototype.initialize.call(this,arguments);
|
||||
|
||||
this.menu = options.menu;
|
||||
},
|
||||
|
||||
render: function() {
|
||||
$(this.el).html(this.template({rows:this.formats}));
|
||||
$('.btn-doc-format',this.el).on('click', _.bind(this.onFormatClick,this));
|
||||
|
||||
if (_.isUndefined(this.scroller)) {
|
||||
this.scroller = new Common.UI.Scroller({
|
||||
el: $(this.el),
|
||||
suppressScrollX: true
|
||||
});
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
onFormatClick: function(e) {
|
||||
var type = e.currentTarget.attributes['format'],
|
||||
ext = e.currentTarget.attributes['format-ext'];
|
||||
if (!_.isUndefined(type) && !_.isUndefined(ext) && this.menu) {
|
||||
this.menu.fireEvent('savecopy:format', [this.menu, parseInt(type.value), ext.value]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
DE.Views.FileMenuPanels.Settings = Common.UI.BaseView.extend(_.extend({
|
||||
el: '#panel-settings',
|
||||
menu: undefined,
|
||||
|
|
|
@ -316,6 +316,7 @@
|
|||
"DE.Controllers.LeftMenu.textReplaceSuccess": "The search has been done. Occurrences replaced: {0}",
|
||||
"DE.Controllers.LeftMenu.warnDownloadAs": "If you continue saving in this format all features except the text will be lost.<br>Are you sure you want to continue?",
|
||||
"DE.Controllers.LeftMenu.warnDownloadAsRTF": "If you continue saving in this format some of the formatting might be lost.<br>Are you sure you want to continue?",
|
||||
"DE.Controllers.LeftMenu.txtUntitled": "Untitled",
|
||||
"DE.Controllers.Main.applyChangesTextText": "Loading the changes...",
|
||||
"DE.Controllers.Main.applyChangesTitleText": "Loading the Changes",
|
||||
"DE.Controllers.Main.convertationTimeoutText": "Conversion timeout exceeded.",
|
||||
|
@ -1105,6 +1106,7 @@
|
|||
"DE.Views.FileMenu.btnSettingsCaption": "Advanced Settings...",
|
||||
"DE.Views.FileMenu.btnToEditCaption": "Edit Document",
|
||||
"DE.Views.FileMenu.textDownload": "Download",
|
||||
"DE.Views.FileMenu.btnSaveCopyAsCaption": "Save Copy as...",
|
||||
"DE.Views.FileMenuPanels.CreateNew.fromBlankText": "From Blank",
|
||||
"DE.Views.FileMenuPanels.CreateNew.fromTemplateText": "From Template",
|
||||
"DE.Views.FileMenuPanels.CreateNew.newDescriptionText": "Create a new blank text document which you will be able to style and format after it is created during the editing. Or choose one of the templates to start a document of a certain type or purpose where some styles have already been pre-applied.",
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
#panel-saveas {
|
||||
#panel-saveas, #panel-savecopy {
|
||||
table {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
|
|
Loading…
Reference in a new issue