mirror of https://github.com/OCA/social.git
[IMP] pre-commit run -a
parent
975e0b8cdb
commit
6bfa014aec
|
@ -16,8 +16,9 @@ odoo.define("mail_preview_base.preview", function (require) {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
var self = this;
|
var self = this;
|
||||||
_.forEach(this.attachment, function(attachment) {
|
_.forEach(this.attachment, function(attachment) {
|
||||||
if (attachment.mimetype === 'application/pdf' ||
|
if (
|
||||||
attachment.type === 'text'
|
attachment.mimetype === "application/pdf" ||
|
||||||
|
attachment.type === "text"
|
||||||
) {
|
) {
|
||||||
attachment.source_url = self._getContentUrl(attachment);
|
attachment.source_url = self._getContentUrl(attachment);
|
||||||
} else {
|
} else {
|
||||||
|
@ -39,16 +40,22 @@ odoo.define("mail_preview_base.preview", function (require) {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
_getContentUrl: function(attachment) {
|
_getContentUrl: function(attachment) {
|
||||||
return "/web/content/" + attachment.id +"?filename=" +
|
return (
|
||||||
window.encodeURIComponent(attachment.name);
|
"/web/content/" +
|
||||||
|
attachment.id +
|
||||||
|
"?filename=" +
|
||||||
|
window.encodeURIComponent(attachment.name)
|
||||||
|
);
|
||||||
},
|
},
|
||||||
_getImageUrl: function(attachment) {
|
_getImageUrl: function(attachment) {
|
||||||
return "/web/image/" + attachment.id;
|
return "/web/image/" + attachment.id;
|
||||||
},
|
},
|
||||||
_hasPreview: function(type, attachment) {
|
_hasPreview: function(type, attachment) {
|
||||||
return type === 'image' ||
|
return (
|
||||||
type === 'video' ||
|
type === "image" ||
|
||||||
attachment.mimetype === 'application/pdf';
|
type === "video" ||
|
||||||
|
attachment.mimetype === "application/pdf"
|
||||||
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -56,8 +63,9 @@ odoo.define("mail_preview_base.preview", function (require) {
|
||||||
init: function(parent, record, attachments) {
|
init: function(parent, record, attachments) {
|
||||||
_.each(attachments, function(attachment) {
|
_.each(attachments, function(attachment) {
|
||||||
attachment.has_preview = DocumentViewer.prototype._hasPreview(
|
attachment.has_preview = DocumentViewer.prototype._hasPreview(
|
||||||
attachment.mimetype && attachment.mimetype.split('/').shift(),
|
attachment.mimetype && attachment.mimetype.split("/").shift(),
|
||||||
attachment);
|
attachment
|
||||||
|
);
|
||||||
});
|
});
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
@ -83,18 +91,26 @@ odoo.define("mail_preview_base.preview", function (require) {
|
||||||
"?download=true";
|
"?download=true";
|
||||||
},
|
},
|
||||||
_getContentUrl: function(attachment) {
|
_getContentUrl: function(attachment) {
|
||||||
return "/web/content/" +
|
return (
|
||||||
this.modelName + '/' +
|
"/web/content/" +
|
||||||
attachment.id + '/' +
|
this.modelName +
|
||||||
|
"/" +
|
||||||
|
attachment.id +
|
||||||
|
"/" +
|
||||||
this.fieldName +
|
this.fieldName +
|
||||||
"?filename=" +
|
"?filename=" +
|
||||||
window.encodeURIComponent(attachment.name);
|
window.encodeURIComponent(attachment.name)
|
||||||
|
);
|
||||||
},
|
},
|
||||||
_getImageUrl: function(attachment) {
|
_getImageUrl: function(attachment) {
|
||||||
return "/web/image/" +
|
return (
|
||||||
this.modelName + '/' +
|
"/web/image/" +
|
||||||
attachment.id + '/' +
|
this.modelName +
|
||||||
this.fieldName;
|
"/" +
|
||||||
|
attachment.id +
|
||||||
|
"/" +
|
||||||
|
this.fieldName
|
||||||
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -125,9 +141,7 @@ odoo.define("mail_preview_base.preview", function (require) {
|
||||||
};
|
};
|
||||||
var mimetype = this.recordData.res_mimetype;
|
var mimetype = this.recordData.res_mimetype;
|
||||||
var type = mimetype.split("/").shift();
|
var type = mimetype.split("/").shift();
|
||||||
if (
|
if (DocumentViewer.prototype._hasPreview(type, this.attachment)) {
|
||||||
DocumentViewer.prototype._hasPreview(type, this.attachment)
|
|
||||||
) {
|
|
||||||
this.$el.prepend(
|
this.$el.prepend(
|
||||||
$("<span/>").addClass("fa fa-search preview_file")
|
$("<span/>").addClass("fa fa-search preview_file")
|
||||||
);
|
);
|
||||||
|
@ -143,5 +157,4 @@ odoo.define("mail_preview_base.preview", function (require) {
|
||||||
FieldPreviewBinary: FieldPreviewBinary,
|
FieldPreviewBinary: FieldPreviewBinary,
|
||||||
DocumentViewer: DocumentViewer,
|
DocumentViewer: DocumentViewer,
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,16 +2,24 @@
|
||||||
<templates xml:space="preserve">
|
<templates xml:space="preserve">
|
||||||
<t t-extend="DocumentViewer.Content">
|
<t t-extend="DocumentViewer.Content">
|
||||||
<t t-jquery=".o_viewer_img" t-operation="attributes">
|
<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 t-jquery=".o_viewer_pdf" t-operation="attributes">
|
<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 t-jquery=".o_viewer_video > source" t-operation="attributes">
|
<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 t-jquery=".o_viewer_text:first" t-operation="attributes">
|
<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>
|
||||||
</t>
|
</t>
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,22 @@
|
||||||
|
|
||||||
-->
|
-->
|
||||||
<odoo>
|
<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">
|
<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>
|
||||||
<xpath expr="//link[last()]" position="after">
|
<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>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
Loading…
Reference in New Issue