diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index a3cff0e83..77319b610 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -204,6 +204,7 @@ _config.editorConfig.mergeFolderUrl = _config.editorConfig.mergeFolderUrl || _config.editorConfig.saveAsUrl; _config.editorConfig.canRequestSaveAs = _config.events && !!_config.events.onRequestSaveAs; _config.editorConfig.canRequestInsertImage = _config.events && !!_config.events.onRequestInsertImage; + _config.editorConfig.canRequestMailMergeRecipients = _config.events && !!_config.events.onRequestMailMergeRecipients; _config.frameEditorId = placeholderId; _config.events && !!_config.events.onReady && console.log("Obsolete: The onReady event is deprecated. Please use onAppReady instead."); @@ -569,6 +570,13 @@ }); }; + var _setMailMergeRecipients = function(data) { + _sendCommand({ + command: 'setMailMergeRecipients', + data: data + }); + }; + var _processMouse = function(evt) { var r = iframe.getBoundingClientRect(); var data = { @@ -612,7 +620,8 @@ setUsers : _setUsers, showSharingSettings : _showSharingSettings, setSharingSettings : _setSharingSettings, - insertImage : _insertImage + insertImage : _insertImage, + setMailMergeRecipients: _setMailMergeRecipients } }; diff --git a/apps/common/Gateway.js b/apps/common/Gateway.js index 5ba1710a2..b8e90ebad 100644 --- a/apps/common/Gateway.js +++ b/apps/common/Gateway.js @@ -114,6 +114,10 @@ if (Common === undefined) { 'insertImage': function(data) { $me.trigger('insertimage', data); + }, + + 'setMailMergeRecipients': function(data) { + $me.trigger('setmailmergerecipients', data); } }; @@ -300,6 +304,10 @@ if (Common === undefined) { _postMessage({event:'onRequestInsertImage'}) }, + requestMailMergeRecipients: function () { + _postMessage({event:'onRequestMailMergeRecipients'}) + }, + on: function(event, handler){ var localHandler = function(event, data){ handler.call(me, data) diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index eacd8804f..cb4904416 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -351,6 +351,7 @@ define([ this.appOptions.canRequestSendNotify = this.editorConfig.canRequestSendNotify; this.appOptions.canRequestSaveAs = this.editorConfig.canRequestSaveAs; this.appOptions.canRequestInsertImage = this.editorConfig.canRequestInsertImage; + this.appOptions.canRequestMailMergeRecipients = this.editorConfig.canRequestMailMergeRecipients; appHeader = this.getApplication().getController('Viewport').getView('Common.Views.Header'); appHeader.setCanBack(this.appOptions.canBackToFolder === true, (this.appOptions.canBackToFolder) ? this.editorConfig.customization.goback.text : '') diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index 2c33652e4..f093edef4 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -324,6 +324,7 @@ define([ toolbar.mnuNoControlsColor.on('click', _.bind(this.onNoControlsColor, this)); toolbar.mnuControlsColorPicker.on('select', _.bind(this.onSelectControlsColor, this)); Common.Gateway.on('insertimage', _.bind(this.insertImage, this)); + Common.Gateway.on('setmailmergerecipients', _.bind(this.setMailMergeRecipients, this)); $('#id-toolbar-menu-new-control-color').on('click', _.bind(this.onNewControlsColor, this)); $('#id-save-style-plus, #id-save-style-link', toolbar.$el).on('click', this.onMenuSaveStyle.bind(this)); @@ -2605,7 +2606,7 @@ define([ this.toolbar.btnRedo.setDisabled(this._state.can_redo!==true); this.toolbar.btnCopy.setDisabled(this._state.can_copycut!==true); this.toolbar.btnPrint.setDisabled(!this.toolbar.mode.canPrint); - if (this.toolbar.mode.fileChoiceUrl) + if (this.toolbar.mode.fileChoiceUrl || this.toolbar.mode.canRequestMailMergeRecipients) this.toolbar.btnMailRecepients.setDisabled(false); this._state.activated = true; @@ -2803,22 +2804,28 @@ define([ onSelectRecepientsClick: function() { if (this._mailMergeDlg) return; - var me = this; - me._mailMergeDlg = new Common.Views.SelectFileDlg({ - fileChoiceUrl: this.toolbar.mode.fileChoiceUrl.replace("{fileExt}", "xlsx").replace("{documentType}", "") - }); - me._mailMergeDlg.on('selectfile', function(obj, recepients){ - me.api.asc_StartMailMerge(recepients); - if (!me.mergeEditor) - me.mergeEditor = me.getApplication().getController('Common.Controllers.ExternalMergeEditor').getView('Common.Views.ExternalMergeEditor'); - if (me.mergeEditor) - me.mergeEditor.setEditMode(false); + if (this.toolbar.mode.canRequestMailMergeRecipients) { + Common.Gateway.requestMailMergeRecipients(); + } else { + var me = this; + me._mailMergeDlg = new Common.Views.SelectFileDlg({ + fileChoiceUrl: this.toolbar.mode.fileChoiceUrl.replace("{fileExt}", "xlsx").replace("{documentType}", "") + }); + me._mailMergeDlg.on('selectfile', function(obj, recepients){ + me.setMailMergeRecipients(recepients); + }).on('close', function(obj){ + me._mailMergeDlg = undefined; + }); + me._mailMergeDlg.show(); + } + }, - }).on('close', function(obj){ - me._mailMergeDlg = undefined; - }); - - me._mailMergeDlg.show(); + setMailMergeRecipients: function(recepients) { + this.api.asc_StartMailMerge(recepients); + if (!this.mergeEditor) + this.mergeEditor = this.getApplication().getController('Common.Controllers.ExternalMergeEditor').getView('Common.Views.ExternalMergeEditor'); + if (this.mergeEditor) + this.mergeEditor.setEditMode(false); }, createDelayedElements: function() {