[IMP] pre-commit run -a
This commit is contained in:
parent
975e0b8cdb
commit
6bfa014aec
@ -16,8 +16,9 @@ odoo.define("mail_preview_base.preview", function (require) {
|
||||
this._super.apply(this, arguments);
|
||||
var self = this;
|
||||
_.forEach(this.attachment, function(attachment) {
|
||||
if (attachment.mimetype === 'application/pdf' ||
|
||||
attachment.type === 'text'
|
||||
if (
|
||||
attachment.mimetype === "application/pdf" ||
|
||||
attachment.type === "text"
|
||||
) {
|
||||
attachment.source_url = self._getContentUrl(attachment);
|
||||
} else {
|
||||
@ -39,16 +40,22 @@ odoo.define("mail_preview_base.preview", function (require) {
|
||||
return false;
|
||||
},
|
||||
_getContentUrl: function(attachment) {
|
||||
return "/web/content/" + attachment.id +"?filename=" +
|
||||
window.encodeURIComponent(attachment.name);
|
||||
return (
|
||||
"/web/content/" +
|
||||
attachment.id +
|
||||
"?filename=" +
|
||||
window.encodeURIComponent(attachment.name)
|
||||
);
|
||||
},
|
||||
_getImageUrl: function(attachment) {
|
||||
return "/web/image/" + attachment.id;
|
||||
},
|
||||
_hasPreview: function(type, attachment) {
|
||||
return type === 'image' ||
|
||||
type === 'video' ||
|
||||
attachment.mimetype === 'application/pdf';
|
||||
return (
|
||||
type === "image" ||
|
||||
type === "video" ||
|
||||
attachment.mimetype === "application/pdf"
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@ -56,8 +63,9 @@ odoo.define("mail_preview_base.preview", function (require) {
|
||||
init: function(parent, record, attachments) {
|
||||
_.each(attachments, function(attachment) {
|
||||
attachment.has_preview = DocumentViewer.prototype._hasPreview(
|
||||
attachment.mimetype && attachment.mimetype.split('/').shift(),
|
||||
attachment);
|
||||
attachment.mimetype && attachment.mimetype.split("/").shift(),
|
||||
attachment
|
||||
);
|
||||
});
|
||||
this._super.apply(this, arguments);
|
||||
},
|
||||
@ -83,18 +91,26 @@ odoo.define("mail_preview_base.preview", function (require) {
|
||||
"?download=true";
|
||||
},
|
||||
_getContentUrl: function(attachment) {
|
||||
return "/web/content/" +
|
||||
this.modelName + '/' +
|
||||
attachment.id + '/' +
|
||||
return (
|
||||
"/web/content/" +
|
||||
this.modelName +
|
||||
"/" +
|
||||
attachment.id +
|
||||
"/" +
|
||||
this.fieldName +
|
||||
"?filename=" +
|
||||
window.encodeURIComponent(attachment.name);
|
||||
window.encodeURIComponent(attachment.name)
|
||||
);
|
||||
},
|
||||
_getImageUrl: function(attachment) {
|
||||
return "/web/image/" +
|
||||
this.modelName + '/' +
|
||||
attachment.id + '/' +
|
||||
this.fieldName;
|
||||
return (
|
||||
"/web/image/" +
|
||||
this.modelName +
|
||||
"/" +
|
||||
attachment.id +
|
||||
"/" +
|
||||
this.fieldName
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@ -125,9 +141,7 @@ odoo.define("mail_preview_base.preview", function (require) {
|
||||
};
|
||||
var mimetype = this.recordData.res_mimetype;
|
||||
var type = mimetype.split("/").shift();
|
||||
if (
|
||||
DocumentViewer.prototype._hasPreview(type, this.attachment)
|
||||
) {
|
||||
if (DocumentViewer.prototype._hasPreview(type, this.attachment)) {
|
||||
this.$el.prepend(
|
||||
$("<span/>").addClass("fa fa-search preview_file")
|
||||
);
|
||||
@ -143,5 +157,4 @@ odoo.define("mail_preview_base.preview", function (require) {
|
||||
FieldPreviewBinary: FieldPreviewBinary,
|
||||
DocumentViewer: DocumentViewer,
|
||||
};
|
||||
|
||||
});
|
||||
|
@ -2,16 +2,24 @@
|
||||
<templates xml:space="preserve">
|
||||
<t t-extend="DocumentViewer.Content">
|
||||
<t t-jquery=".o_viewer_img" t-operation="attributes">
|
||||
<attribute name="t-attf-src">#{widget.activeAttachment.source_url}?unique=1&signature=#{widget.activeAttachment.checksum}</attribute>
|
||||
<attribute
|
||||
name="t-attf-src"
|
||||
>#{widget.activeAttachment.source_url}?unique=1&signature=#{widget.activeAttachment.checksum}</attribute>
|
||||
</t>
|
||||
<t t-jquery=".o_viewer_pdf" t-operation="attributes">
|
||||
<attribute name="t-attf-src">/web/static/lib/pdfjs/web/viewer.html?file=#{widget.activeAttachment.source_url}</attribute>
|
||||
<attribute
|
||||
name="t-attf-src"
|
||||
>/web/static/lib/pdfjs/web/viewer.html?file=#{widget.activeAttachment.source_url}</attribute>
|
||||
</t>
|
||||
<t t-jquery=".o_viewer_video > source" t-operation="attributes">
|
||||
<attribute name="t-attf-src">#{widget.activeAttachment.source_url}</attribute>
|
||||
<attribute
|
||||
name="t-attf-src"
|
||||
>#{widget.activeAttachment.source_url}</attribute>
|
||||
</t>
|
||||
<t t-jquery=".o_viewer_text:first" t-operation="attributes">
|
||||
<attribute name="t-attf-src">#{widget.activeAttachment.source_url}</attribute>
|
||||
<attribute
|
||||
name="t-attf-src"
|
||||
>#{widget.activeAttachment.source_url}</attribute>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
|
@ -6,12 +6,22 @@
|
||||
|
||||
-->
|
||||
<odoo>
|
||||
<template id="assets_backend" name="mail_preview_base_assets" inherit_id="web.assets_backend">
|
||||
<template
|
||||
id="assets_backend"
|
||||
name="mail_preview_base_assets"
|
||||
inherit_id="web.assets_backend"
|
||||
>
|
||||
<xpath expr="//script[last()]" position="after">
|
||||
<script type="text/javascript" src="/mail_preview_base/static/src/js/preview.js" />
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="/mail_preview_base/static/src/js/preview.js"
|
||||
/>
|
||||
</xpath>
|
||||
<xpath expr="//link[last()]" position="after">
|
||||
<link rel="stylesheet" href="/mail_preview_base/static/src/scss/preview.scss" />
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="/mail_preview_base/static/src/scss/preview.scss"
|
||||
/>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
||||
|
Loading…
Reference in New Issue
Block a user