Merge pull request #1132 from ONLYOFFICE/feature/Bug-29082

Feature/bug 29082
This commit is contained in:
Julia Radzhabova 2021-08-27 18:42:37 +03:00 committed by GitHub
commit 9d7a50136e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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.mnuPageSize.on('item:click', _.bind(this.onPageSizeClick, this));
toolbar.mnuColorSchema.on('item:click', _.bind(this.onColorSchemaClick, this)); toolbar.mnuColorSchema.on('item:click', _.bind(this.onColorSchemaClick, this));
toolbar.mnuColorSchema.on('show:after', _.bind(this.onColorSchemaShow, 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.mnuPageNumberPosPicker.on('item:click', _.bind(this.onInsertPageNumberClick, this));
toolbar.btnEditHeader.menu.on('item:click', _.bind(this.onEditHeaderFooterClick, this)); toolbar.btnEditHeader.menu.on('item:click', _.bind(this.onEditHeaderFooterClick, this));
toolbar.btnInsDateTime.on('click', _.bind(this.onInsDateTimeClick, 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.btnRedo.setDisabled(this._state.can_redo!==true);
this.toolbar.btnCopy.setDisabled(this._state.can_copycut!==true); this.toolbar.btnCopy.setDisabled(this._state.can_copycut!==true);
this.toolbar.btnPrint.setDisabled(!this.toolbar.mode.canPrint); 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.btnMailRecepients.setDisabled(false);
this.toolbar.mnuMailRecepients.items[2].setVisible(this.toolbar.mode.fileChoiceUrl || this.toolbar.mode.canRequestMailMergeRecipients);
}
this._state.activated = true; this._state.activated = true;
var props = this.api.asc_GetSectionProps(); var props = this.api.asc_GetSectionProps();
@ -3099,22 +3101,45 @@ define([
disable ? Common.util.Shortcuts.suspendEvents('alt+h') : Common.util.Shortcuts.resumeEvents('alt+h'); 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._mailMergeDlg) return;
if (this.toolbar.mode.canRequestMailMergeRecipients) { var me = this;
Common.Gateway.requestMailMergeRecipients(); if (item.value === 'file') {
} else { this.api && this.api.asc_StartMailMerge();
var me = this; } else if (item.value === 'url') {
me._mailMergeDlg = new Common.Views.SelectFileDlg({ (new Common.Views.ImageFromUrlDialog({
fileChoiceUrl: this.toolbar.mode.fileChoiceUrl.replace("{fileExt}", "xlsx").replace("{documentType}", "") handler: function(result, value) {
}); if (result == 'ok') {
me._mailMergeDlg.on('selectfile', function(obj, recepients){ if (me.api) {
me.setMailMergeRecipients(recepients); var checkUrl = value.replace(/ /g, '');
}).on('close', function(obj){ if (!_.isEmpty(checkUrl)) {
me._mailMergeDlg = undefined; me.api.asc_StartMailMerge({ fileType: "csv", url: checkUrl });
}); } else {
me._mailMergeDlg.show(); 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', txtMarginsH: 'Top and bottom margins are too high for a given page height',
textInsert: 'Insert', textInsert: 'Insert',
textTabForms: 'Forms', textTabForms: 'Forms',
textGroup: 'Group' textGroup: 'Group',
textEmptyMMergeUrl: 'You need to specify URL.'
}, DE.Controllers.Toolbar || {})); }, DE.Controllers.Toolbar || {}));
}); });

View file

@ -1146,7 +1146,14 @@ define([
cls: 'btn-toolbar', cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-mailmerge', iconCls: 'toolbar__icon btn-mailmerge',
dataHint: '1', 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({ me.btnImgAlign = new Common.UI.Button({
@ -1234,6 +1241,7 @@ define([
this.mnuPageSize = this.btnPageSize.menu; this.mnuPageSize = this.btnPageSize.menu;
this.mnuColorSchema = this.btnColorSchemas.menu; this.mnuColorSchema = this.btnColorSchemas.menu;
this.mnuChangeCase = this.btnChangeCase.menu; this.mnuChangeCase = this.btnChangeCase.menu;
this.mnuMailRecepients = this.btnMailRecepients.menu;
this.cmbFontSize = new Common.UI.ComboBox({ this.cmbFontSize = new Common.UI.ComboBox({
cls: 'input-group-nr', cls: 'input-group-nr',
@ -2602,7 +2610,10 @@ define([
mniToggleCase: 'tOGGLE cASE', mniToggleCase: 'tOGGLE cASE',
textChangeLevel: 'Change List Level', textChangeLevel: 'Change List Level',
mniTextToTable: 'Convert Text to Table', mniTextToTable: 'Convert Text to Table',
txtScheme22: 'New Office' txtScheme22: 'New Office',
mniFromFile: 'From File',
mniFromUrl: 'From URL',
mniFromStorage: 'From Storage'
} }
})(), DE.Views.Toolbar || {})); })(), DE.Views.Toolbar || {}));
}); });

View file

@ -1219,6 +1219,7 @@
"DE.Controllers.Toolbar.txtSymbol_vdots": "Vertical ellipsis", "DE.Controllers.Toolbar.txtSymbol_vdots": "Vertical ellipsis",
"DE.Controllers.Toolbar.txtSymbol_xsi": "Xi", "DE.Controllers.Toolbar.txtSymbol_xsi": "Xi",
"DE.Controllers.Toolbar.txtSymbol_zeta": "Zeta", "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.textFitPage": "Fit to Page",
"DE.Controllers.Viewport.textFitWidth": "Fit to Width", "DE.Controllers.Viewport.textFitWidth": "Fit to Width",
"DE.Views.AddNewCaptionLabelDialog.textLabel": "Label:", "DE.Views.AddNewCaptionLabelDialog.textLabel": "Label:",
@ -2759,6 +2760,9 @@
"DE.Views.Toolbar.txtScheme7": "Equity", "DE.Views.Toolbar.txtScheme7": "Equity",
"DE.Views.Toolbar.txtScheme8": "Flow", "DE.Views.Toolbar.txtScheme8": "Flow",
"DE.Views.Toolbar.txtScheme9": "Foundry", "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.textAuto": "Auto",
"DE.Views.WatermarkSettingsDialog.textBold": "Bold", "DE.Views.WatermarkSettingsDialog.textBold": "Bold",
"DE.Views.WatermarkSettingsDialog.textColor": "Text color", "DE.Views.WatermarkSettingsDialog.textColor": "Text color",