From a8482985e80bf620ac08947dcf12f4055cea0621 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 22 Aug 2018 11:13:37 +0300 Subject: [PATCH 1/6] [DE] Add 'Save Copy As' action to file menu. Bug 23603, Bug 32790 --- .../main/app/controller/LeftMenu.js | 76 ++++++++++++++++++- .../main/app/controller/Main.js | 1 + .../main/app/template/FileMenu.template | 2 + apps/documenteditor/main/app/view/FileMenu.js | 16 +++- .../main/app/view/FileMenuPanels.js | 61 +++++++++++++++ apps/documenteditor/main/locale/en.json | 2 + .../main/resources/less/filemenu.less | 2 +- 7 files changed, 156 insertions(+), 4 deletions(-) diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index 808680d5b..26eba22ed 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -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.
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.
Are you sure you want to continue?', - warnDownloadAsRTF : 'If you continue saving in this format some of the formatting might be lost.
Are you sure you want to continue?' + warnDownloadAsRTF : 'If you continue saving in this format some of the formatting might be lost.
Are you sure you want to continue?', + txtUntitled: 'Untitled' }, DE.Controllers.LeftMenu || {})); }); \ No newline at end of file diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 5f4075f1f..0edc65ffa 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -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') diff --git a/apps/documenteditor/main/app/template/FileMenu.template b/apps/documenteditor/main/app/template/FileMenu.template index 8ec3a1927..35378e635 100644 --- a/apps/documenteditor/main/app/template/FileMenu.template +++ b/apps/documenteditor/main/app/template/FileMenu.template @@ -5,6 +5,7 @@
  • +
  • @@ -25,6 +26,7 @@
    +
    diff --git a/apps/documenteditor/main/app/view/FileMenu.js b/apps/documenteditor/main/app/view/FileMenu.js index ec5073524..dc0ddfb3f 100644 --- a/apps/documenteditor/main/app/view/FileMenu.js +++ b/apps/documenteditor/main/app/view/FileMenu.js @@ -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 || {})); }); diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index 44dd732c1..8bfb0abda 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -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([ + '', + '<% _.each(rows, function(row) { %>', + '', + '<% _.each(row, function(item) { %>', + '', + '<% }) %>', + '', + '<% }) %>', + '
    ', + '', + '
    ' + ].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, diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 39840748b..b0d237932 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -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.
    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.
    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.", diff --git a/apps/documenteditor/main/resources/less/filemenu.less b/apps/documenteditor/main/resources/less/filemenu.less index c800db23b..67712c42c 100644 --- a/apps/documenteditor/main/resources/less/filemenu.less +++ b/apps/documenteditor/main/resources/less/filemenu.less @@ -86,7 +86,7 @@ } } -#panel-saveas { +#panel-saveas, #panel-savecopy { table { margin-left: auto; margin-right: auto; From 98ac0b05c696a8831e398bfdcdc6dc68fee6fc8f Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 27 Sep 2018 13:11:01 +0300 Subject: [PATCH 2/6] Change doc-format icons --- .../main/resources/img/doc-formats/csv.svg | 91 ++++++++----------- .../main/resources/img/doc-formats/docx.svg | 42 +++------ .../main/resources/img/doc-formats/epub.svg | 46 +++------- .../main/resources/img/doc-formats/html.svg | 46 +++------- .../main/resources/img/doc-formats/odp.svg | 41 +++------ .../main/resources/img/doc-formats/ods.svg | 41 +++------ .../main/resources/img/doc-formats/odt.svg | 44 +++------ .../main/resources/img/doc-formats/pdf.svg | 40 ++------ .../main/resources/img/doc-formats/pdfa.svg | 56 ++++-------- .../main/resources/img/doc-formats/pptx.svg | 49 +++------- .../main/resources/img/doc-formats/rtf.svg | 58 ++++-------- .../main/resources/img/doc-formats/txt.svg | 56 ++++-------- .../main/resources/img/doc-formats/xlsx.svg | 41 +++------ 13 files changed, 198 insertions(+), 453 deletions(-) diff --git a/apps/common/main/resources/img/doc-formats/csv.svg b/apps/common/main/resources/img/doc-formats/csv.svg index 66899742f..75fd3d549 100644 --- a/apps/common/main/resources/img/doc-formats/csv.svg +++ b/apps/common/main/resources/img/doc-formats/csv.svg @@ -1,58 +1,39 @@ - - - - + csv - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/common/main/resources/img/doc-formats/docx.svg b/apps/common/main/resources/img/doc-formats/docx.svg index 6e0814583..61d91d93f 100644 --- a/apps/common/main/resources/img/doc-formats/docx.svg +++ b/apps/common/main/resources/img/doc-formats/docx.svg @@ -1,33 +1,13 @@ - - - - - docx - - - - - - - - + + + + + + + + + - - + + diff --git a/apps/common/main/resources/img/doc-formats/epub.svg b/apps/common/main/resources/img/doc-formats/epub.svg index 562f3c21b..f18bc723f 100644 --- a/apps/common/main/resources/img/doc-formats/epub.svg +++ b/apps/common/main/resources/img/doc-formats/epub.svg @@ -1,35 +1,15 @@ - - - - - epub - - - - - - - - + + + + + + + + + - - - - + + + + diff --git a/apps/common/main/resources/img/doc-formats/html.svg b/apps/common/main/resources/img/doc-formats/html.svg index c6aae404d..0c9cbcc91 100644 --- a/apps/common/main/resources/img/doc-formats/html.svg +++ b/apps/common/main/resources/img/doc-formats/html.svg @@ -1,35 +1,15 @@ - - - - - html - - - - - - - - + + + + + + + + + - - - - + + + + diff --git a/apps/common/main/resources/img/doc-formats/odp.svg b/apps/common/main/resources/img/doc-formats/odp.svg index 78a1f3ee4..0fdf1bfd6 100644 --- a/apps/common/main/resources/img/doc-formats/odp.svg +++ b/apps/common/main/resources/img/doc-formats/odp.svg @@ -1,33 +1,14 @@ - - - - - odp - - - - - - - + + + + + + + - - - + + + diff --git a/apps/common/main/resources/img/doc-formats/ods.svg b/apps/common/main/resources/img/doc-formats/ods.svg index 1f0dbc620..6843b97c2 100644 --- a/apps/common/main/resources/img/doc-formats/ods.svg +++ b/apps/common/main/resources/img/doc-formats/ods.svg @@ -1,33 +1,14 @@ - - - - - ods - - - - - - - + + + + + + + - - - + + + diff --git a/apps/common/main/resources/img/doc-formats/odt.svg b/apps/common/main/resources/img/doc-formats/odt.svg index c69c9670b..ebf155e94 100644 --- a/apps/common/main/resources/img/doc-formats/odt.svg +++ b/apps/common/main/resources/img/doc-formats/odt.svg @@ -1,33 +1,13 @@ - - - - - odt - - - - - - - + + + + + + + + - - - - + + + + \ No newline at end of file diff --git a/apps/common/main/resources/img/doc-formats/pdf.svg b/apps/common/main/resources/img/doc-formats/pdf.svg index f28cae773..eb49e8e9a 100644 --- a/apps/common/main/resources/img/doc-formats/pdf.svg +++ b/apps/common/main/resources/img/doc-formats/pdf.svg @@ -1,32 +1,12 @@ - - - - - pdf - - - - - - - + + + + + + + + - - + + diff --git a/apps/common/main/resources/img/doc-formats/pdfa.svg b/apps/common/main/resources/img/doc-formats/pdfa.svg index 8c8d17452..bb7392f73 100644 --- a/apps/common/main/resources/img/doc-formats/pdfa.svg +++ b/apps/common/main/resources/img/doc-formats/pdfa.svg @@ -1,38 +1,18 @@ - - - - - pdfa - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/apps/common/main/resources/img/doc-formats/pptx.svg b/apps/common/main/resources/img/doc-formats/pptx.svg index 72e1d05ec..9b8a9c3f2 100644 --- a/apps/common/main/resources/img/doc-formats/pptx.svg +++ b/apps/common/main/resources/img/doc-formats/pptx.svg @@ -1,37 +1,18 @@ - - - - - pptx - - - - - - - - + + + + + + + + - - - - - - + + + + + + diff --git a/apps/common/main/resources/img/doc-formats/rtf.svg b/apps/common/main/resources/img/doc-formats/rtf.svg index f89f74108..18449d99c 100644 --- a/apps/common/main/resources/img/doc-formats/rtf.svg +++ b/apps/common/main/resources/img/doc-formats/rtf.svg @@ -1,41 +1,21 @@ - - - - - rtf - - - - - - - + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + diff --git a/apps/common/main/resources/img/doc-formats/txt.svg b/apps/common/main/resources/img/doc-formats/txt.svg index a4dca99e4..2dd3a9232 100644 --- a/apps/common/main/resources/img/doc-formats/txt.svg +++ b/apps/common/main/resources/img/doc-formats/txt.svg @@ -1,40 +1,20 @@ - - - - - txt - - - - - - - + + + + + + + + - - - - - - - - - - + + + + + + + + + + diff --git a/apps/common/main/resources/img/doc-formats/xlsx.svg b/apps/common/main/resources/img/doc-formats/xlsx.svg index a0944b5e4..3cfc5a1a2 100644 --- a/apps/common/main/resources/img/doc-formats/xlsx.svg +++ b/apps/common/main/resources/img/doc-formats/xlsx.svg @@ -1,33 +1,14 @@ - - - - - xlsx - - - - - - - - + + + + + + + + - - + + From 29dfa2b83d678303f7e1254544926e5ea02743ee Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 27 Sep 2018 13:25:30 +0300 Subject: [PATCH 3/6] [DE] Change config parameter for selecting save folder --- apps/api/documents/api.js | 4 +++- apps/documenteditor/main/app/controller/LeftMenu.js | 2 +- apps/documenteditor/main/app/controller/Main.js | 2 +- apps/documenteditor/main/app/view/FileMenu.js | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index fc8078b13..f504467bc 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -58,7 +58,8 @@ sharingSettingsUrl: 'document sharing settings url', fileChoiceUrl: 'mail merge sources url', callbackUrl: , - mergeFolderUrl: 'folder for saving merged file', + mergeFolderUrl: 'folder for saving merged file', // must be deprecated, use saveAsUrl instead + saveAsUrl: 'folder for saving files' licenseUrl: , customerId: , @@ -194,6 +195,7 @@ _config.editorConfig.canRequestEditRights = _config.events && !!_config.events.onRequestEditRights; _config.editorConfig.canRequestClose = _config.events && !!_config.events.onRequestClose; _config.editorConfig.canRename = _config.events && !!_config.events.onRequestRename; + _config.editorConfig.mergeFolderUrl = _config.editorConfig.mergeFolderUrl || _config.editorConfig.saveAsUrl; _config.frameEditorId = placeholderId; _config.events && !!_config.events.onReady && console.log("Obsolete: The onReady event is deprecated. Please use onAppReady instead."); diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index 26eba22ed..e70c76343 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -354,7 +354,7 @@ define([ } me._saveCopyDlg = new DE.Views.MailMergeSaveDlg({ - mergeFolderUrl: me.mode.saveCopyFolderUrl, + mergeFolderUrl: me.mode.saveAsUrl, mergedFileUrl: url, defFileName: defFileName }); diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 0edc65ffa..d7a1da99f 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -305,7 +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.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') diff --git a/apps/documenteditor/main/app/view/FileMenu.js b/apps/documenteditor/main/app/view/FileMenu.js index dc0ddfb3f..bd8e0e076 100644 --- a/apps/documenteditor/main/app/view/FileMenu.js +++ b/apps/documenteditor/main/app/view/FileMenu.js @@ -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.saveCopyFolderUrl ?'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.canDownloadOrigin) && this.mode.isDesktopApp && this.mode.isOffline)?'show':'hide'](); // this.hkSaveAs[this.mode.canDownload?'enable':'disable'](); @@ -304,7 +304,7 @@ define([ } else if (this.mode.canDownloadOrigin) $('a',this.miDownload.$el).text(this.textDownload); - if (this.mode.canDownload && this.mode.saveCopyFolderUrl) { + if (this.mode.canDownload && this.mode.saveAsUrl) { this.panels['save-copy'] = ((new DE.Views.FileMenuPanels.ViewSaveCopy({menu: this})).render()); } From 8dc82501ef18f0f9fad628b0afde70694ff592e4 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 27 Sep 2018 13:52:15 +0300 Subject: [PATCH 4/6] [DE] Replace MailMergeSaveDlg by SaveAsDlg from common --- .../main/lib/view/SaveAsDlg.js} | 27 +++++++++---------- .../main/app/controller/LeftMenu.js | 12 ++++----- .../main/app/view/MailMergeEmailDlg.js | 2 +- .../main/app/view/MailMergeSettings.js | 12 ++++----- apps/documenteditor/main/locale/en.json | 6 +++-- 5 files changed, 30 insertions(+), 29 deletions(-) rename apps/{documenteditor/main/app/view/MailMergeSaveDlg.js => common/main/lib/view/SaveAsDlg.js} (83%) diff --git a/apps/documenteditor/main/app/view/MailMergeSaveDlg.js b/apps/common/main/lib/view/SaveAsDlg.js similarity index 83% rename from apps/documenteditor/main/app/view/MailMergeSaveDlg.js rename to apps/common/main/lib/view/SaveAsDlg.js index 832f1bc6b..82fa60380 100644 --- a/apps/documenteditor/main/app/view/MailMergeSaveDlg.js +++ b/apps/common/main/lib/view/SaveAsDlg.js @@ -31,9 +31,8 @@ * */ /** - * User: Julia.Radzhabova - * Date: 15.04.15 - * Time: 13:56 + * Created by Julia.Radzhabova on 9/27/18 + * Copyright (c) 2018 Ascensio System SIA. All rights reserved. */ define([ @@ -41,7 +40,7 @@ define([ 'common/main/lib/component/LoadMask' ], function () { 'use strict'; - DE.Views.MailMergeSaveDlg = Common.UI.Window.extend(_.extend({ + Common.Views.SaveAsDlg = Common.UI.Window.extend(_.extend({ initialize : function(options) { var _options = {}; _.extend(_options, { @@ -52,15 +51,15 @@ define([ }, options); this.template = [ - '
    ' + '
    ' ].join(''); _options.tpl = _.template(this.template)(_options); - this.mergeFolderUrl = options.mergeFolderUrl || ''; - this.mergedFileUrl = options.mergedFileUrl || ''; + this.saveFolderUrl = options.saveFolderUrl || ''; + this.saveFileUrl = options.saveFileUrl || ''; this.defFileName = options.defFileName || ''; - this.mergeFolderUrl = this.mergeFolderUrl.replace("{title}", encodeURIComponent(this.defFileName)).replace("{fileuri}", encodeURIComponent(this.mergedFileUrl)); + this.saveFolderUrl = this.saveFolderUrl.replace("{title}", encodeURIComponent(this.defFileName)).replace("{fileuri}", encodeURIComponent(this.saveFileUrl)); Common.UI.Window.prototype.initialize.call(this, _options); }, @@ -75,13 +74,13 @@ define([ iframe.frameBorder = 0; iframe.scrolling = "no"; iframe.onload = _.bind(this._onLoad,this); - $('#id-mail-merge-folder-placeholder').append(iframe); + $('#id-saveas-folder-placeholder').append(iframe); - this.loadMask = new Common.UI.LoadMask({owner: $('#id-mail-merge-folder-placeholder')}); + this.loadMask = new Common.UI.LoadMask({owner: $('#id-saveas-folder-placeholder')}); this.loadMask.setTitle(this.textLoading); this.loadMask.show(); - iframe.src = this.mergeFolderUrl; + iframe.src = this.saveFolderUrl; var me = this; this._eventfunc = function(msg) { @@ -122,10 +121,10 @@ define([ _onMessage: function(msg) { if (msg && msg.Referer == "onlyoffice") { if ( !_.isEmpty(msg.error) ) { - this.trigger('mailmergeerror', this, msg.error); + this.trigger('saveaserror', this, msg.error); } // if ( !_.isEmpty(msg.folder) ) { -// this.trigger('mailmergefolder', this, msg.folder); // save last folder url +// this.trigger('saveasfolder', this, msg.folder); // save last folder url // } Common.NotificationCenter.trigger('window:close', this); } @@ -138,6 +137,6 @@ define([ textTitle : 'Folder for save', textLoading : 'Loading' - }, DE.Views.MailMergeSaveDlg || {})); + }, Common.Views.SaveAsDlg || {})); }); diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index e70c76343..bf46207ff 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -43,9 +43,9 @@ define([ 'core', 'common/main/lib/util/Shortcuts', + 'common/main/lib/view/SaveAsDlg', 'documenteditor/main/app/view/LeftMenu', - 'documenteditor/main/app/view/FileMenu', - 'documenteditor/main/app/view/MailMergeSaveDlg' + 'documenteditor/main/app/view/FileMenu' ], function () { 'use strict'; @@ -353,12 +353,12 @@ define([ defFileName = defFileName.substring(0, idx) + this.isFromFileDownloadAs; } - me._saveCopyDlg = new DE.Views.MailMergeSaveDlg({ - mergeFolderUrl: me.mode.saveAsUrl, - mergedFileUrl: url, + me._saveCopyDlg = new Common.Views.SaveAsDlg({ + saveFolderUrl: me.mode.saveAsUrl, + saveFileUrl: url, defFileName: defFileName }); - me._saveCopyDlg.on('mailmergeerror', function(obj, err){ + me._saveCopyDlg.on('saveaserror', function(obj, err){ var config = { closable: false, title: this.notcriticalErrorTitle, diff --git a/apps/documenteditor/main/app/view/MailMergeEmailDlg.js b/apps/documenteditor/main/app/view/MailMergeEmailDlg.js index 639aab015..ac61668f9 100644 --- a/apps/documenteditor/main/app/view/MailMergeEmailDlg.js +++ b/apps/documenteditor/main/app/view/MailMergeEmailDlg.js @@ -171,7 +171,7 @@ define([ 'text!documenteditor/main/app/template/MailMergeEmailDlg.template', _onMessage: function(msg) { if (msg && msg.Referer == "onlyoffice") { // if ( !_.isEmpty(msg.folder) ) { -// this.trigger('mailmergefolder', this, msg.folder); // save last folder url +// this.trigger('saveasfolder', this, msg.folder); // save last folder url // } } }, diff --git a/apps/documenteditor/main/app/view/MailMergeSettings.js b/apps/documenteditor/main/app/view/MailMergeSettings.js index 3146960b6..3a680ee43 100644 --- a/apps/documenteditor/main/app/view/MailMergeSettings.js +++ b/apps/documenteditor/main/app/view/MailMergeSettings.js @@ -42,8 +42,8 @@ define([ 'backbone', 'common/main/lib/component/Button', 'common/main/lib/component/Switcher', + 'common/main/lib/view/SaveAsDlg', 'documenteditor/main/app/view/MailMergeRecepients', - 'documenteditor/main/app/view/MailMergeSaveDlg', 'documenteditor/main/app/view/MailMergeEmailDlg' ], function (menuTemplate, $, _, Backbone) { 'use strict'; @@ -544,13 +544,13 @@ define([ if (this._mailMergeDlg) return; var me = this; if (this.cmbMergeTo.getValue() != Asc.c_oAscFileType.HTML) { - me._mailMergeDlg = new DE.Views.MailMergeSaveDlg({ - mergeFolderUrl: me.mode.mergeFolderUrl, - mergedFileUrl: url, + me._mailMergeDlg = new Common.Views.SaveAsDlg({ + saveFolderUrl: me.mode.mergeFolderUrl, + savedFileUrl: url, defFileName: me.defFileName + ((this.cmbMergeTo.getValue() == Asc.c_oAscFileType.PDF) ? '.pdf' : '.docx') }); - me._mailMergeDlg.on('mailmergefolder', function(obj, folder){ // save last folder - }).on('mailmergeerror', function(obj, err){ // save last folder + me._mailMergeDlg.on('saveasfolder', function(obj, folder){ // save last folder + }).on('saveaserror', function(obj, err){ // save last folder var config = { closable: false, title: this.notcriticalErrorTitle, diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index b0d237932..93532315b 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -279,6 +279,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", @@ -1361,8 +1363,8 @@ "DE.Views.MailMergeEmailDlg.textWarningMsg": "Please note that mailing cannot be stopped once your click the 'Send' button.", "DE.Views.MailMergeRecepients.textLoading": "Loading", "DE.Views.MailMergeRecepients.textTitle": "Select Data Source", - "DE.Views.MailMergeSaveDlg.textLoading": "Loading", - "DE.Views.MailMergeSaveDlg.textTitle": "Folder for save", + "del_DE.Views.MailMergeSaveDlg.textLoading": "Loading", + "del_DE.Views.MailMergeSaveDlg.textTitle": "Folder for save", "DE.Views.MailMergeSettings.downloadMergeTitle": "Merging", "DE.Views.MailMergeSettings.errorMailMergeSaveFile": "Merge failed.", "DE.Views.MailMergeSettings.notcriticalErrorTitle": "Warning", From 470a0483bbb7d6e99edc3e893e80d7c1a428c9c5 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 27 Sep 2018 15:25:15 +0300 Subject: [PATCH 5/6] [PE][SSE] Add 'Save Copy As' action to file menu. Bug 23603, Bug 32790 --- .../main/app/controller/LeftMenu.js | 50 +++++++++++++- .../main/app/controller/Main.js | 1 + .../main/app/template/FileMenu.template | 2 + .../main/app/view/FileMenu.js | 13 +++- .../main/app/view/FileMenuPanels.js | 54 +++++++++++++++ apps/presentationeditor/main/locale/en.json | 5 ++ .../main/resources/less/leftmenu.less | 2 +- .../main/app/controller/LeftMenu.js | 68 ++++++++++++++++++- .../main/app/controller/Main.js | 1 + .../main/app/template/FileMenu.template | 2 + .../main/app/view/FileMenu.js | 13 +++- .../main/app/view/FileMenuPanels.js | 60 ++++++++++++++++ apps/spreadsheeteditor/main/locale/en.json | 4 ++ .../main/resources/less/leftmenu.less | 2 +- 14 files changed, 271 insertions(+), 6 deletions(-) diff --git a/apps/presentationeditor/main/app/controller/LeftMenu.js b/apps/presentationeditor/main/app/controller/LeftMenu.js index 174054b64..91d556b0d 100644 --- a/apps/presentationeditor/main/app/controller/LeftMenu.js +++ b/apps/presentationeditor/main/app/controller/LeftMenu.js @@ -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 || {})); }); \ No newline at end of file diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 2107e270f..3fb1a344e 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -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') diff --git a/apps/presentationeditor/main/app/template/FileMenu.template b/apps/presentationeditor/main/app/template/FileMenu.template index 5565d15e9..d67b35cfe 100644 --- a/apps/presentationeditor/main/app/template/FileMenu.template +++ b/apps/presentationeditor/main/app/template/FileMenu.template @@ -5,6 +5,7 @@
  • +
  • @@ -24,6 +25,7 @@
    +
    diff --git a/apps/presentationeditor/main/app/view/FileMenu.js b/apps/presentationeditor/main/app/view/FileMenu.js index cc7ac1a13..c44d4ab21 100644 --- a/apps/presentationeditor/main/app/view/FileMenu.js +++ b/apps/presentationeditor/main/app/view/FileMenu.js @@ -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 || {})); }); diff --git a/apps/presentationeditor/main/app/view/FileMenuPanels.js b/apps/presentationeditor/main/app/view/FileMenuPanels.js index 2e38b60dd..9220f90af 100644 --- a/apps/presentationeditor/main/app/view/FileMenuPanels.js +++ b/apps/presentationeditor/main/app/view/FileMenuPanels.js @@ -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([ + '', + '<% _.each(rows, function(row) { %>', + '', + '<% _.each(row, function(item) { %>', + '', + '<% }) %>', + '', + '<% }) %>', + '
    ', + '', + '
    ' + ].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, diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json index e9a07a9e7..5d32dfe00 100644 --- a/apps/presentationeditor/main/locale/en.json +++ b/apps/presentationeditor/main/locale/en.json @@ -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.", diff --git a/apps/presentationeditor/main/resources/less/leftmenu.less b/apps/presentationeditor/main/resources/less/leftmenu.less index 98ca17e83..6be922434 100644 --- a/apps/presentationeditor/main/resources/less/leftmenu.less +++ b/apps/presentationeditor/main/resources/less/leftmenu.less @@ -185,7 +185,7 @@ overflow: hidden; } - #panel-saveas { + #panel-saveas, #panel-savecopy { table { margin-left: auto; margin-right: auto; diff --git a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js index 172dedfdc..f2b684139 100644 --- a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js @@ -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 || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 3d5253428..deb10596c 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -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; diff --git a/apps/spreadsheeteditor/main/app/template/FileMenu.template b/apps/spreadsheeteditor/main/app/template/FileMenu.template index 5565d15e9..d67b35cfe 100644 --- a/apps/spreadsheeteditor/main/app/template/FileMenu.template +++ b/apps/spreadsheeteditor/main/app/template/FileMenu.template @@ -5,6 +5,7 @@
  • +
  • @@ -24,6 +25,7 @@
    +
    diff --git a/apps/spreadsheeteditor/main/app/view/FileMenu.js b/apps/spreadsheeteditor/main/app/view/FileMenu.js index 76547cd4a..faeed2cee 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenu.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenu.js @@ -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 || {})); }); diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 94585261c..20a587c23 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -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([ + '', + '<% _.each(rows, function(row) { %>', + '', + '<% _.each(row, function(item) { %>', + '', + '<% }) %>', + '', + '<% }) %>', + '
    ', + '', + '
    ' + ].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, diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 64ff02d93..a1f741644 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -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.
    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.
    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.", diff --git a/apps/spreadsheeteditor/main/resources/less/leftmenu.less b/apps/spreadsheeteditor/main/resources/less/leftmenu.less index 7f818cac5..7dc8bec55 100644 --- a/apps/spreadsheeteditor/main/resources/less/leftmenu.less +++ b/apps/spreadsheeteditor/main/resources/less/leftmenu.less @@ -174,7 +174,7 @@ overflow: hidden; } - #panel-saveas { + #panel-saveas, #panel-savecopy { table { margin-left: auto; margin-right: auto; From 641e5813af27e89c51cb2e39db55503e7ba10816 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 27 Sep 2018 16:12:19 +0300 Subject: [PATCH 6/6] Bugfix --- apps/documenteditor/main/app/controller/LeftMenu.js | 2 +- apps/documenteditor/main/app/view/MailMergeSettings.js | 2 +- apps/presentationeditor/main/app/controller/LeftMenu.js | 2 +- apps/spreadsheeteditor/main/app/controller/LeftMenu.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index bf46207ff..c2ba23614 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -361,7 +361,7 @@ define([ me._saveCopyDlg.on('saveaserror', function(obj, err){ var config = { closable: false, - title: this.notcriticalErrorTitle, + title: me.notcriticalErrorTitle, msg: err, iconCls: 'warn', buttons: ['ok'], diff --git a/apps/documenteditor/main/app/view/MailMergeSettings.js b/apps/documenteditor/main/app/view/MailMergeSettings.js index 3a680ee43..02d1e21b0 100644 --- a/apps/documenteditor/main/app/view/MailMergeSettings.js +++ b/apps/documenteditor/main/app/view/MailMergeSettings.js @@ -553,7 +553,7 @@ define([ }).on('saveaserror', function(obj, err){ // save last folder var config = { closable: false, - title: this.notcriticalErrorTitle, + title: me.notcriticalErrorTitle, msg: err, iconCls: 'warn', buttons: ['ok'], diff --git a/apps/presentationeditor/main/app/controller/LeftMenu.js b/apps/presentationeditor/main/app/controller/LeftMenu.js index 91d556b0d..87a858e8b 100644 --- a/apps/presentationeditor/main/app/controller/LeftMenu.js +++ b/apps/presentationeditor/main/app/controller/LeftMenu.js @@ -273,7 +273,7 @@ define([ me._saveCopyDlg.on('saveaserror', function(obj, err){ var config = { closable: false, - title: this.notcriticalErrorTitle, + title: me.notcriticalErrorTitle, msg: err, iconCls: 'warn', buttons: ['ok'], diff --git a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js index f2b684139..dd4355afd 100644 --- a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js @@ -318,7 +318,7 @@ define([ me._saveCopyDlg.on('saveaserror', function(obj, err){ var config = { closable: false, - title: this.textWarning, + title: me.textWarning, msg: err, iconCls: 'warn', buttons: ['ok'],