mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
print email
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user