[IMP] mail: introduce AttachmentViewer/print
Task-2579306 Part-of: odoo/odoo#88152
This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user