[IMP] attachment_preview: fix _onPreviewAttachment and remove class o_attachment_preview

This commit is contained in:
vancouver29 2023-04-17 15:57:34 +02:00
parent 0bce1f3b3b
commit e7c0e9d1d9
3 changed files with 14 additions and 20 deletions

View File

@ -205,12 +205,17 @@ odoo.define("attachment_preview.chatter", function (require) {
attachment_title,
split_screen
) {
if (!canPreview(attachment_extension)) {
return;
}
var url = getUrl(
attachment_id,
attachment_url,
attachment_extension,
attachment_title
);
if (split_screen) {
this.trigger("onAttachmentPreview", {url: url});
} else {

View File

@ -242,34 +242,23 @@ odoo.define("attachment_preview.attachment_card", function (require) {
$target = $(event.currentTarget),
split_screen = $target.attr("data-target") !== "new",
attachment_id = this.attachment.id,
attachment_extension = "pdf",
attachment_title = this.attachment.filename,
attachment_url = this.attachment.defaultSource;
active_attachment_id = attachment_id;
if (attachment_extension) {
rpc.query({
model: "ir.attachment",
method: "get_attachment_extension",
args: [attachment_id],
}).then(function (extension) {
self._showPreview(
attachment_id,
attachment_url,
attachment_extension,
extension,
attachment_title,
split_screen
);
} else {
rpc.query({
model: "ir.attachment",
method: "get_attachment_extension",
args: [attachment_id],
}).then(function (extension) {
self.showPreview(
attachment_id,
attachment_url,
extension,
null,
split_screen
);
});
}
});
},
}
);

View File

@ -13,7 +13,7 @@
>
<div
t-if="attachmentCard.attachment.downloadUrl"
class="o_AttachmentCard_asideItem d-flex justify-content-center align-items-center ml4 o_attachment_preview"
class="o_AttachmentCard_asideItem d-flex justify-content-center align-items-center ml4"
t-att-data-id="attachmentCard.attachment.id"
t-att-data-url="attachmentCard.attachment.defaultSource"
t-on-click="attachmentCard._onPreviewAttachment"
@ -27,7 +27,7 @@
</div>
<div
t-if="attachmentCard.attachment.downloadUrl"
class="o_AttachmentCard_asideItem d-flex justify-content-center align-items-center ml4 o_attachment_preview o_attachment_preview_new_tab"
class="o_AttachmentCard_asideItem d-flex justify-content-center align-items-center ml4 o_attachment_preview_new_tab"
data-target="new"
t-att-data-id="attachmentCard.attachment.id"
t-att-data-url="attachmentCard.attachment.defaultSource"