[PE][SSE] Add 'Save Copy As' action to file menu. Bug 23603, Bug 32790

This commit is contained in:
Julia Radzhabova 2018-09-27 15:25:15 +03:00
parent 8dc82501ef
commit 470a0483bb
14 changed files with 271 additions and 6 deletions

View file

@ -43,6 +43,7 @@
define([
'core',
'common/main/lib/util/Shortcuts',
'common/main/lib/view/SaveAsDlg',
'presentationeditor/main/app/view/LeftMenu',
'presentationeditor/main/app/view/FileMenu'
], function () {
@ -83,6 +84,7 @@ define([
'filemenu:hide': _.bind(this.menuFilesHide, this),
'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)
@ -133,6 +135,7 @@ define([
this.api.asc_registerCallback('asc_onThumbnailsShow', _.bind(this.onThumbnailsShow, 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)
@ -244,6 +247,49 @@ define([
menu.hide();
},
clickSaveCopyAsFormat: function(menu, format, ext) {
this.isFromFileDownloadAs = ext;
this.api.asc_DownloadAs(format, true);
menu.hide();
},
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 Common.Views.SaveAsDlg({
saveFolderUrl: me.mode.saveAsUrl,
saveFileUrl: url,
defFileName: defFileName
});
me._saveCopyDlg.on('saveaserror', 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 = Common.localStorage.getBool("pe-settings-inputmode");
Common.Utils.InternalSettings.set("pe-settings-inputmode", value);
@ -590,6 +636,8 @@ define([
textNoTextFound : 'Text not found',
newDocumentTitle : 'Unnamed document',
requestEditRightsText : 'Requesting editing rights...'
requestEditRightsText : 'Requesting editing rights...',
notcriticalErrorTitle: 'Warning',
txtUntitled: 'Untitled'
}, PE.Controllers.LeftMenu || {}));
});

View file

@ -290,6 +290,7 @@ define([
this.appOptions.lang = this.editorConfig.lang;
this.appOptions.location = (typeof (this.editorConfig.location) == 'string') ? this.editorConfig.location.toLowerCase() : '';
this.appOptions.sharingSettingsUrl = this.editorConfig.sharingSettingsUrl;
this.appOptions.saveAsUrl = this.editorConfig.saveAsUrl;
this.appOptions.canAnalytics = false;
this.appOptions.customization = this.editorConfig.customization;
this.appOptions.canBackToFolder = (this.editorConfig.canBackToFolder!==false) && (typeof (this.editorConfig.customization) == 'object')

View file

@ -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" />
@ -24,6 +25,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" />

View file

@ -108,6 +108,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',
@ -175,6 +182,7 @@ define([
this.miSave,
this.miEdit,
this.miDownload,
this.miSaveCopyAs,
this.miSaveAs,
this.miPrint,
this.miRename,
@ -206,6 +214,7 @@ 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()
@ -246,6 +255,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.miSaveAs[(this.mode.canDownload && this.mode.isDesktopApp && this.mode.isOffline)?'show':'hide']();
// this.hkSaveAs[this.mode.canDownload?'enable':'disable']();
@ -382,6 +392,7 @@ define([
btnSaveAsCaption : 'Save as',
btnRenameCaption : 'Rename...',
btnCloseMenuCaption : 'Close Menu',
btnProtectCaption: 'Protect'
btnProtectCaption: 'Protect',
btnSaveCopyAsCaption : 'Save Copy as...'
}, PE.Views.FileMenu || {}));
});

View file

@ -102,6 +102,60 @@ define([
}
});
PE.Views.FileMenuPanels.ViewSaveCopy = Common.UI.BaseView.extend({
el: '#panel-savecopy',
menu: undefined,
formats: [[
{name: 'PPTX', imgCls: 'pptx', type: Asc.c_oAscFileType.PPTX, ext: '.pptx'},
{name: 'PDF', imgCls: 'pdf', type: Asc.c_oAscFileType.PDF, ext: '.pdf'},
{name: 'PDFA', imgCls: 'pdfa', type: Asc.c_oAscFileType.PDFA, ext: '.pdf'},
{name: 'ODP', imgCls: 'odp', type: Asc.c_oAscFileType.ODP, ext: '.odp'}
]],
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]);
}
}
});
PE.Views.FileMenuPanels.Settings = Common.UI.BaseView.extend(_.extend({
el: '#panel-settings',
menu: undefined,

View file

@ -202,6 +202,8 @@
"Common.Views.ReviewPopover.textOpenAgain": "Open Again",
"Common.Views.ReviewPopover.textReply": "Reply",
"Common.Views.ReviewPopover.textResolve": "Resolve",
"Common.Views.SaveAsDlg.textLoading": "Loading",
"Common.Views.SaveAsDlg.textTitle": "Folder for save",
"Common.Views.SignDialog.cancelButtonText": "Cancel",
"Common.Views.SignDialog.okButtonText": "Ok",
"Common.Views.SignDialog.textBold": "Bold",
@ -230,8 +232,10 @@
"Common.Views.SignSettingsDialog.textTitle": "Signature Setup",
"Common.Views.SignSettingsDialog.txtEmpty": "This field is required",
"PE.Controllers.LeftMenu.newDocumentTitle": "Unnamed presentation",
"PE.Controllers.LeftMenu.notcriticalErrorTitle": "Warning",
"PE.Controllers.LeftMenu.requestEditRightsText": "Requesting editing rights...",
"PE.Controllers.LeftMenu.textNoTextFound": "The data you have been searching for could not be found. Please adjust your search options.",
"PE.Controllers.LeftMenu.txtUntitled": "Untitled",
"PE.Controllers.Main.applyChangesTextText": "Loading data...",
"PE.Controllers.Main.applyChangesTitleText": "Loading Data",
"PE.Controllers.Main.convertationTimeoutText": "Conversion timeout exceeded.",
@ -950,6 +954,7 @@
"PE.Views.FileMenu.btnSaveCaption": "Save",
"PE.Views.FileMenu.btnSettingsCaption": "Advanced Settings...",
"PE.Views.FileMenu.btnToEditCaption": "Edit Presentation",
"PE.Views.FileMenu.btnSaveCopyAsCaption": "Save Copy as...",
"PE.Views.FileMenuPanels.CreateNew.fromBlankText": "From Blank",
"PE.Views.FileMenuPanels.CreateNew.fromTemplateText": "From Template",
"PE.Views.FileMenuPanels.CreateNew.newDescriptionText": "Create a new blank presentation 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 presentation of a certain type or purpose where some styles have already been pre-applied.",

View file

@ -185,7 +185,7 @@
overflow: hidden;
}
#panel-saveas {
#panel-saveas, #panel-savecopy {
table {
margin-left: auto;
margin-right: auto;

View file

@ -33,6 +33,7 @@
define([
'core',
'common/main/lib/util/Shortcuts',
'common/main/lib/view/SaveAsDlg',
'spreadsheeteditor/main/app/view/LeftMenu',
'spreadsheeteditor/main/app/view/FileMenu'
], function () {
@ -73,6 +74,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)
@ -141,6 +143,7 @@ define([
this.api.asc_registerCallback('asc_onRenameCellTextEnd', _.bind(this.onRenameText, 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)
@ -270,6 +273,68 @@ define([
}
},
clickSaveCopyAsFormat: function(menu, format, ext) {
if (format == Asc.c_oAscFileType.CSV) {
Common.UI.warning({
title: this.textWarning,
msg: this.warnDownloadAs,
buttons: ['ok', 'cancel'],
callback: _.bind(function(btn){
if (btn == 'ok') {
this.isFromFileDownloadAs = ext;
this.api.asc_DownloadAs(format, true);
menu.hide();
}
}, this)
});
} else if (format == Asc.c_oAscFileType.PDF || format == Asc.c_oAscFileType.PDFA) {
this.isFromFileDownloadAs = ext;
menu.hide();
Common.NotificationCenter.trigger('download:settings', this.leftMenu, format, true);
} else {
this.isFromFileDownloadAs = ext;
this.api.asc_DownloadAs(format, true);
menu.hide();
}
},
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 Common.Views.SaveAsDlg({
saveFolderUrl: me.mode.saveAsUrl,
saveFileUrl: url,
defFileName: defFileName
});
me._saveCopyDlg.on('saveaserror', function(obj, err){
var config = {
closable: false,
title: this.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;
},
applySettings: function(menu) {
var value = Common.localStorage.getItem("sse-settings-fontrender");
Common.Utils.InternalSettings.set("sse-settings-fontrender", value);
@ -819,6 +884,7 @@ define([
textValues: 'Values',
textWithin: 'Within',
textSearch: 'Search',
textLookin: 'Look in'
textLookin: 'Look in',
txtUntitled: 'Untitled'
}, SSE.Controllers.LeftMenu || {}));
});

View file

@ -297,6 +297,7 @@ define([
this.appOptions.canAutosave = false;
this.appOptions.canAnalytics = false;
this.appOptions.sharingSettingsUrl = this.editorConfig.sharingSettingsUrl;
this.appOptions.saveAsUrl = this.editorConfig.saveAsUrl;
this.appOptions.isEditDiagram = this.editorConfig.mode == 'editdiagram';
this.appOptions.isEditMailMerge = this.editorConfig.mode == 'editmerge';
this.appOptions.customization = this.editorConfig.customization;

View file

@ -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" />
@ -24,6 +25,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" />

View file

@ -95,6 +95,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',
@ -169,6 +176,7 @@ define([
this.miSave,
this.miEdit,
this.miDownload,
this.miSaveCopyAs,
this.miSaveAs,
this.miPrint,
this.miRename,
@ -195,6 +203,7 @@ 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()
@ -235,6 +244,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.miSaveAs[(this.mode.canDownload && this.mode.isDesktopApp && this.mode.isOffline)?'show':'hide']();
// this.hkSaveAs[this.mode.canDownload?'enable':'disable']();
@ -362,6 +372,7 @@ define([
btnSaveAsCaption : 'Save as',
btnRenameCaption : 'Rename...',
btnCloseMenuCaption : 'Close Menu',
btnProtectCaption: 'Protect'
btnProtectCaption: 'Protect',
btnSaveCopyAsCaption : 'Save Copy as...'
}, SSE.Views.FileMenu || {}));
});

View file

@ -97,6 +97,66 @@ define([
}
});
SSE.Views.FileMenuPanels.ViewSaveCopy = Common.UI.BaseView.extend({
el: '#panel-savecopy',
menu: undefined,
formats: [[
{name: 'XLSX', imgCls: 'xlsx', type: Asc.c_oAscFileType.XLSX, ext: '.xlsx'},
{name: 'PDF', imgCls: 'pdf', type: Asc.c_oAscFileType.PDF, ext: '.pdf'},
{name: 'PDFA', imgCls: 'pdfa', type: Asc.c_oAscFileType.PDFA, ext: '.pdf'}
],[
{name: 'ODS', imgCls: 'ods', type: Asc.c_oAscFileType.ODS, ext: '.ods'},
{name: 'CSV', imgCls: 'csv', type: Asc.c_oAscFileType.CSV, ext: '.csv'}
]
// ,[
// {name: 'HTML', imgCls: 'html', type: Asc.c_oAscFileType.HTML, ext: '.html'}
// ]
],
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]);
}
}
});
SSE.Views.FileMenuPanels.Settings = Common.UI.BaseView.extend(_.extend({
el: '#panel-settings',
menu: undefined,

View file

@ -192,6 +192,8 @@
"Common.Views.ReviewPopover.textOpenAgain": "Open Again",
"Common.Views.ReviewPopover.textReply": "Reply",
"Common.Views.ReviewPopover.textResolve": "Resolve",
"Common.Views.SaveAsDlg.textLoading": "Loading",
"Common.Views.SaveAsDlg.textTitle": "Folder for save",
"Common.Views.SignDialog.cancelButtonText": "Cancel",
"Common.Views.SignDialog.okButtonText": "Ok",
"Common.Views.SignDialog.textBold": "Bold",
@ -378,6 +380,7 @@
"SSE.Controllers.LeftMenu.textWithin": "Within",
"SSE.Controllers.LeftMenu.textWorkbook": "Workbook",
"SSE.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?",
"SSE.Controllers.LeftMenu.txtUntitled": "Untitled",
"SSE.Controllers.Main.confirmMoveCellRange": "The destination cell range can contain data. Continue the operation?",
"SSE.Controllers.Main.confirmPutMergeRange": "The source data contained merged cells.<br>They had been unmerged before they were pasted into the table.",
"SSE.Controllers.Main.convertationTimeoutText": "Conversion timeout exceeded.",
@ -1260,6 +1263,7 @@
"SSE.Views.FileMenu.btnSaveCaption": "Save",
"SSE.Views.FileMenu.btnSettingsCaption": "Advanced Settings...",
"SSE.Views.FileMenu.btnToEditCaption": "Edit Spreadsheet",
"SSE.Views.FileMenu.btnSaveCopyAsCaption": "Save Copy as...",
"SSE.Views.FileMenuPanels.CreateNew.fromBlankText": "From Blank",
"SSE.Views.FileMenuPanels.CreateNew.fromTemplateText": "From Template",
"SSE.Views.FileMenuPanels.CreateNew.newDescriptionText": "Create a new blank spreadsheet 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 spreadsheet of a certain type or purpose where some styles have already been pre-applied.",

View file

@ -174,7 +174,7 @@
overflow: hidden;
}
#panel-saveas {
#panel-saveas, #panel-savecopy {
table {
margin-left: auto;
margin-right: auto;