diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index ed2f9cfb3..e3b20bdfd 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -338,7 +338,7 @@ define([ toolbar.mnuPageSize.on('item:click', _.bind(this.onPageSizeClick, this)); toolbar.mnuColorSchema.on('item:click', _.bind(this.onColorSchemaClick, this)); toolbar.mnuColorSchema.on('show:after', _.bind(this.onColorSchemaShow, this)); - toolbar.btnMailRecepients.on('click', _.bind(this.onSelectRecepientsClick, this)); + toolbar.mnuMailRecepients.on('item:click', _.bind(this.onSelectRecepientsClick, this)); toolbar.mnuPageNumberPosPicker.on('item:click', _.bind(this.onInsertPageNumberClick, this)); toolbar.btnEditHeader.menu.on('item:click', _.bind(this.onEditHeaderFooterClick, this)); toolbar.btnInsDateTime.on('click', _.bind(this.onInsDateTimeClick, this)); @@ -2882,8 +2882,10 @@ 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._state.mmdisable && (this.toolbar.mode.fileChoiceUrl || this.toolbar.mode.canRequestMailMergeRecipients)) + if (!this._state.mmdisable) { this.toolbar.btnMailRecepients.setDisabled(false); + this.toolbar.mnuMailRecepients.items[2].setVisible(this.toolbar.mode.fileChoiceUrl || this.toolbar.mode.canRequestMailMergeRecipients); + } this._state.activated = true; var props = this.api.asc_GetSectionProps(); @@ -3099,22 +3101,45 @@ define([ disable ? Common.util.Shortcuts.suspendEvents('alt+h') : Common.util.Shortcuts.resumeEvents('alt+h'); }, - onSelectRecepientsClick: function() { + onSelectRecepientsClick: function(menu, item, e) { if (this._mailMergeDlg) return; - 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(); + var me = this; + if (item.value === 'file') { + this.api && this.api.asc_StartMailMerge(); + } else if (item.value === 'url') { + (new Common.Views.ImageFromUrlDialog({ + handler: function(result, value) { + if (result == 'ok') { + if (me.api) { + var checkUrl = value.replace(/ /g, ''); + if (!_.isEmpty(checkUrl)) { + me.api.asc_StartMailMerge({ fileType: "csv", url: checkUrl }); + } else { + Common.UI.warning({ + msg: me.textEmptyMMergeUrl + }); + } + } + + Common.NotificationCenter.trigger('edit:complete', me.toolbar); + } + } + })).show(); + } else if (item.value === 'storage') { + if (this.toolbar.mode.canRequestMailMergeRecipients) { + Common.Gateway.requestMailMergeRecipients(); + } else { + 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(); + } } }, @@ -3622,7 +3647,8 @@ define([ txtMarginsH: 'Top and bottom margins are too high for a given page height', textInsert: 'Insert', textTabForms: 'Forms', - textGroup: 'Group' + textGroup: 'Group', + textEmptyMMergeUrl: 'You need to specify URL.' }, DE.Controllers.Toolbar || {})); }); diff --git a/apps/documenteditor/main/app/view/Toolbar.js b/apps/documenteditor/main/app/view/Toolbar.js index 62a0501cc..89b39e1e5 100644 --- a/apps/documenteditor/main/app/view/Toolbar.js +++ b/apps/documenteditor/main/app/view/Toolbar.js @@ -1146,7 +1146,14 @@ define([ cls: 'btn-toolbar', iconCls: 'toolbar__icon btn-mailmerge', dataHint: '1', - dataHintDirection: 'bottom' + dataHintDirection: 'bottom', + menu: new Common.UI.Menu({ + items: [ + {caption: this.mniFromFile, value: 'file'}, + {caption: this.mniFromUrl, value: 'url'}, + {caption: this.mniFromStorage, value: 'storage'} + ] + }) }); me.btnImgAlign = new Common.UI.Button({ @@ -1234,6 +1241,7 @@ define([ this.mnuPageSize = this.btnPageSize.menu; this.mnuColorSchema = this.btnColorSchemas.menu; this.mnuChangeCase = this.btnChangeCase.menu; + this.mnuMailRecepients = this.btnMailRecepients.menu; this.cmbFontSize = new Common.UI.ComboBox({ cls: 'input-group-nr', @@ -2602,7 +2610,10 @@ define([ mniToggleCase: 'tOGGLE cASE', textChangeLevel: 'Change List Level', mniTextToTable: 'Convert Text to Table', - txtScheme22: 'New Office' + txtScheme22: 'New Office', + mniFromFile: 'From File', + mniFromUrl: 'From URL', + mniFromStorage: 'From Storage' } })(), DE.Views.Toolbar || {})); }); diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 99575292a..8995b8bc6 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -1219,6 +1219,7 @@ "DE.Controllers.Toolbar.txtSymbol_vdots": "Vertical ellipsis", "DE.Controllers.Toolbar.txtSymbol_xsi": "Xi", "DE.Controllers.Toolbar.txtSymbol_zeta": "Zeta", + "DE.Controllers.Toolbar.textEmptyMMergeUrl": "You need to specify URL.", "DE.Controllers.Viewport.textFitPage": "Fit to Page", "DE.Controllers.Viewport.textFitWidth": "Fit to Width", "DE.Views.AddNewCaptionLabelDialog.textLabel": "Label:", @@ -2759,6 +2760,9 @@ "DE.Views.Toolbar.txtScheme7": "Equity", "DE.Views.Toolbar.txtScheme8": "Flow", "DE.Views.Toolbar.txtScheme9": "Foundry", + "DE.Views.Toolbar.mniFromFile": "From File", + "DE.Views.Toolbar.mniFromUrl": "From URL", + "DE.Views.Toolbar.mniFromStorage": "From Storage", "DE.Views.WatermarkSettingsDialog.textAuto": "Auto", "DE.Views.WatermarkSettingsDialog.textBold": "Bold", "DE.Views.WatermarkSettingsDialog.textColor": "Text color",