[IMP] mail_preview_base: black, isort, prettier

This commit is contained in:
Víctor Martínez 2021-03-24 10:07:44 +01:00 committed by Jasmin Solanki
parent 6bfa014aec
commit 7329af8c70

View File

@ -3,7 +3,7 @@
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
**********************************************************************************/
odoo.define("mail_preview_base.preview", function(require) {
odoo.define("mail_preview_base.preview", function (require) {
"use strict";
var DocumentViewer = require("mail.DocumentViewer");
@ -12,10 +12,10 @@ odoo.define("mail_preview_base.preview", function(require) {
var AttachmentBox = require("mail.AttachmentBox");
DocumentViewer.include({
init: function(parent, attachments) {
init: function (parent, attachments) {
this._super.apply(this, arguments);
var self = this;
_.forEach(this.attachment, function(attachment) {
_.forEach(this.attachment, function (attachment) {
if (
attachment.mimetype === "application/pdf" ||
attachment.type === "text"
@ -26,7 +26,7 @@ odoo.define("mail_preview_base.preview", function(require) {
}
});
this.attachment = this.attachment.concat(
_.filter(attachments, function(attachment) {
_.filter(attachments, function (attachment) {
return self._checkAttachment(attachment);
})
);
@ -36,10 +36,10 @@ odoo.define("mail_preview_base.preview", function(require) {
This function is a hook, it will allow to define new kind of
records
*/
_checkAttachment: function() {
_checkAttachment: function () {
return false;
},
_getContentUrl: function(attachment) {
_getContentUrl: function (attachment) {
return (
"/web/content/" +
attachment.id +
@ -47,10 +47,10 @@ odoo.define("mail_preview_base.preview", function(require) {
window.encodeURIComponent(attachment.name)
);
},
_getImageUrl: function(attachment) {
_getImageUrl: function (attachment) {
return "/web/image/" + attachment.id;
},
_hasPreview: function(type, attachment) {
_hasPreview: function (type, attachment) {
return (
type === "image" ||
type === "video" ||
@ -60,8 +60,8 @@ odoo.define("mail_preview_base.preview", function(require) {
});
AttachmentBox.include({
init: function(parent, record, attachments) {
_.each(attachments, function(attachment) {
init: function (parent, record, attachments) {
_.each(attachments, function (attachment) {
attachment.has_preview = DocumentViewer.prototype._hasPreview(
attachment.mimetype && attachment.mimetype.split("/").shift(),
attachment
@ -72,12 +72,12 @@ odoo.define("mail_preview_base.preview", function(require) {
});
var FieldPreviewViewer = DocumentViewer.extend({
init: function(parent, attachments, activeAttachmentID, model, field) {
init: function (parent, attachments, activeAttachmentID, model, field) {
this.modelName = model;
this.fieldName = field;
this._super.apply(this, arguments);
},
_onDownload: function(e) {
_onDownload: function (e) {
e.preventDefault();
window.location =
"/web/content/" +
@ -90,7 +90,7 @@ odoo.define("mail_preview_base.preview", function(require) {
"datas" +
"?download=true";
},
_getContentUrl: function(attachment) {
_getContentUrl: function (attachment) {
return (
"/web/content/" +
this.modelName +
@ -102,7 +102,7 @@ odoo.define("mail_preview_base.preview", function(require) {
window.encodeURIComponent(attachment.name)
);
},
_getImageUrl: function(attachment) {
_getImageUrl: function (attachment) {
return (
"/web/image/" +
this.modelName +
@ -118,7 +118,7 @@ odoo.define("mail_preview_base.preview", function(require) {
events: _.extend({}, basic_fields.FieldBinaryFile.prototype.events, {
"click .preview_file": "_previewFile",
}),
_previewFile: function(event) {
_previewFile: function (event) {
event.stopPropagation();
event.preventDefault();
var attachmentViewer = new FieldPreviewViewer(
@ -130,7 +130,7 @@ odoo.define("mail_preview_base.preview", function(require) {
);
attachmentViewer.appendTo($("body"));
},
_renderReadonly: function() {
_renderReadonly: function () {
this._super.apply(this, arguments);
if (this.value) {
this.attachment = {