print email

This commit is contained in:
Yuri Kuznetsov
2023-04-21 14:14:00 +03:00
parent 6a963f39d4
commit fc72d847da
2 changed files with 43 additions and 0 deletions

View File

@@ -247,6 +247,7 @@
"Tree View": "Tree View",
"Unlink All": "Unlink All",
"Total": "Total",
"Print": "Print",
"Print to PDF": "Print to PDF",
"Default": "Default",
"Number": "Number",

View File

@@ -164,6 +164,11 @@ define('views/email/record/detail', ['views/record/detail'], function (Dep) {
hidden: !(this.model.get('isHtml') && this.model.get('bodyPlain'))
});
this.addDropdownItem({
label: 'Print',
name: 'print',
});
this.listenTo(this.model, 'change:isImportant', () => {
if (this.model.get('isImportant')) {
this.hideActionItem('markAsImportant');
@@ -481,6 +486,43 @@ define('views/email/record/detail', ['views/record/detail'], function (Dep) {
});
},
actionPrint: function () {
/** @type {module:views/fields/wysiwyg.Class} */
let bodyView = this.getFieldView('body');
if (!bodyView) {
return;
}
let iframe = bodyView.$el.find('iframe').get(0);
if (iframe) {
iframe.contentWindow.print();
return;
}
let el = bodyView.$el.get(0);
/** @type {Element} */
let recordElement = this.$el.get(0);
iframe = document.createElement('iframe');
iframe.style.display = 'none';
recordElement.append(iframe);
let contentWindow = iframe.contentWindow;
contentWindow.document.open();
contentWindow.document.write(el.innerHTML);
contentWindow.document.close();
contentWindow.focus();
contentWindow.print();
contentWindow.onafterprint = () => {
recordElement.removeChild(iframe);
}
},
errorHandlerSendingFail: function (data) {
if (!this.model.id) {
this.model.id = data.id;