[DE] For Bug 29082: load recipient list from url or file

This commit is contained in:
Julia Radzhabova 2021-08-26 23:56:09 +03:00
parent 23fb2b0bbf
commit b6aa262f2b
3 changed files with 60 additions and 19 deletions

View file

@ -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));
@ -2879,8 +2879,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();
@ -3096,22 +3098,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(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();
}
}
},
@ -3619,7 +3644,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 || {}));
});

View file

@ -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 || {}));
});

View file

@ -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",