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