mirror of https://github.com/OCA/social.git
[IMP] mail_preview_base: black, isort, prettier
parent
26b5c57e35
commit
3f0ac51703
|
@ -2,14 +2,14 @@
|
||||||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
|
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
|
||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Mail Preview',
|
"name": "Mail Preview",
|
||||||
'summary': """
|
"summary": """
|
||||||
Base to add more previewing options""",
|
Base to add more previewing options""",
|
||||||
'version': '12.0.1.0.0',
|
"version": "13.0.1.0.0",
|
||||||
'license': 'LGPL-3',
|
"license": "LGPL-3",
|
||||||
'author': 'Creu Blanca,Odoo Community Association (OCA)',
|
"author": "Creu Blanca,Odoo Community Association (OCA)",
|
||||||
'website': 'https://github.com/OCA/social',
|
"website": "https://github.com/OCA/social",
|
||||||
'depends': ['mail'],
|
"depends": ["mail"],
|
||||||
'data': ['template/assets.xml'],
|
"data": ["template/assets.xml"],
|
||||||
'qweb': ['static/src/xml/preview.xml'],
|
"qweb": ["static/src/xml/preview.xml"],
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,19 +16,21 @@ 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' || attachment.type === 'text') {
|
if (attachment.mimetype === 'application/pdf' ||
|
||||||
|
attachment.type === 'text'
|
||||||
|
) {
|
||||||
attachment.source_url = self._getContentUrl(attachment);
|
attachment.source_url = self._getContentUrl(attachment);
|
||||||
|
} else {
|
||||||
|
attachment.source_url = self._getImageUrl(attachment);
|
||||||
}
|
}
|
||||||
else {
|
});
|
||||||
attachment.source_url = self._getImageUrl(attachment)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
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);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
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
|
||||||
|
@ -44,7 +46,9 @@ odoo.define("mail_preview_base.preview", function(require) {
|
||||||
return "/web/image/" + attachment.id;
|
return "/web/image/" + attachment.id;
|
||||||
},
|
},
|
||||||
_hasPreview: function (type, attachment) {
|
_hasPreview: function (type, attachment) {
|
||||||
return type === 'image' || type === 'video' || attachment.mimetype === 'application/pdf';
|
return type === 'image' ||
|
||||||
|
type === 'video' ||
|
||||||
|
attachment.mimetype === 'application/pdf';
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -53,11 +57,11 @@ odoo.define("mail_preview_base.preview", function(require) {
|
||||||
_.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);
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
|
|
||||||
var FieldPreviewViewer = DocumentViewer.extend({
|
var FieldPreviewViewer = DocumentViewer.extend({
|
||||||
init: function (parent, attachments, activeAttachmentID, model, field) {
|
init: function (parent, attachments, activeAttachmentID, model, field) {
|
||||||
|
@ -81,16 +85,16 @@ odoo.define("mail_preview_base.preview", function(require) {
|
||||||
_getContentUrl: function (attachment) {
|
_getContentUrl: function (attachment) {
|
||||||
return "/web/content/" +
|
return "/web/content/" +
|
||||||
this.modelName + '/' +
|
this.modelName + '/' +
|
||||||
attachment.id + '/'
|
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 "/web/image/" +
|
||||||
this.modelName + '/' +
|
this.modelName + '/' +
|
||||||
attachment.id + '/'
|
attachment.id + '/' +
|
||||||
+ this.fieldName
|
this.fieldName;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue