[IMP] mail: introduce AttachmentViewer/onLoadImage

Task-2579306

Part-of: odoo/odoo#88152
This commit is contained in:
Alexandre Kühn
2022-04-07 14:20:57 +02:00
parent 9b1bb1f64a
commit e4b1e28c48
3 changed files with 13 additions and 15 deletions
@@ -397,20 +397,6 @@ export class AttachmentViewer extends Component {
ev.stopPropagation();
}
/**
* Called when new image has been loaded
*
* @private
* @param {Event} ev
*/
_onLoadImage(ev) {
if (!this.attachmentViewer) {
return;
}
ev.stopPropagation();
this.attachmentViewer.update({ isImageLoading: false });
}
/**
* @private
* @param {DragEvent} ev
@@ -43,7 +43,7 @@
<i class="fa fa-3x fa-circle-o-notch fa-fw fa-spin text-white" role="img" title="Loading"/>
</div>
</t>
<img class="o_AttachmentViewer_view o_AttachmentViewer_viewImage mw-100 mh-100 bg-black" t-on-click="attachmentViewer.onClickImage" t-on-mousedown="_onMousedownImage" t-on-wheel="_onWheelImage" t-on-load="_onLoadImage" t-att-src="attachmentViewer.imageUrl" t-att-style="attachmentViewer.imageStyle" draggable="false" alt="Viewer" t-key="'image_' + attachmentViewer.attachment.id" t-ref="image_{{ attachmentViewer.attachment.id }}"/>
<img class="o_AttachmentViewer_view o_AttachmentViewer_viewImage mw-100 mh-100 bg-black" t-on-click="attachmentViewer.onClickImage" t-on-mousedown="_onMousedownImage" t-on-wheel="_onWheelImage" t-on-load="attachmentViewer.onLoadImage" t-att-src="attachmentViewer.imageUrl" t-att-style="attachmentViewer.imageStyle" draggable="false" alt="Viewer" t-key="'image_' + attachmentViewer.attachment.id" t-ref="image_{{ attachmentViewer.attachment.id }}"/>
</div>
</t>
<t t-if="attachmentViewer.attachment.isPdf">
@@ -82,6 +82,18 @@ registerModel({
onClickVideo(ev) {
ev.stopPropagation();
},
/**
* Called when new image has been loaded
*
* @param {Event} ev
*/
onLoadImage(ev) {
if (!this.exists()) {
return;
}
ev.stopPropagation();
this.update({ isImageLoading: false });
},
/**
* @private
* @returns {string}