[IMP] mail: introduce AttachmentViewer/print

Task-2579306

Part-of: odoo/odoo#88152
This commit is contained in:
Alexandre Kühn
2022-04-07 14:20:58 +02:00
parent 3a7ad52857
commit 1a26d41357
2 changed files with 26 additions and 29 deletions
@@ -117,34 +117,6 @@ export class AttachmentViewer extends Component {
}
}
/**
* Prompt the browser print of this attachment.
*
* @private
*/
_print() {
const printWindow = window.open('about:blank', '_new');
printWindow.document.open();
printWindow.document.write(`
<html>
<head>
<script>
function onloadImage() {
setTimeout('printImage()', 10);
}
function printImage() {
window.print();
window.close();
}
</script>
</head>
<body onload='onloadImage()'>
<img src="${this.attachmentViewer.imageUrl}" alt=""/>
</body>
</html>`);
printWindow.document.close();
}
/**
* Rotate the image by 90 degrees to the right.
*
@@ -290,7 +262,7 @@ export class AttachmentViewer extends Component {
*/
_onClickPrint(ev) {
ev.stopPropagation();
this._print();
this.attachmentViewer.print();
}
/**
@@ -112,6 +112,31 @@ registerModel({
}
this.dialogOwner.attachmentListOwnerAsAttachmentView.selectPreviousAttachment();
},
/**
* Prompt the browser print of this attachment.
*/
print() {
const printWindow = window.open('about:blank', '_new');
printWindow.document.open();
printWindow.document.write(`
<html>
<head>
<script>
function onloadImage() {
setTimeout('printImage()', 10);
}
function printImage() {
window.print();
window.close();
}
</script>
</head>
<body onload='onloadImage()'>
<img src="${this.imageUrl}" alt=""/>
</body>
</html>`);
printWindow.document.close();
},
/**
* @private
* @returns {string}