[REF] mail: move channel attachment url to discuss folder

Part-of: odoo/odoo#121256
This commit is contained in:
Sébastien Theys
2023-05-15 12:56:09 +02:00
parent f9611105e6
commit c6b86893f2
3 changed files with 18 additions and 8 deletions
@@ -119,12 +119,7 @@ export class Attachment {
if (this.uploading && this.tmpUrl) {
return this.tmpUrl;
}
if (!this.accessToken && this.originThread?.model === "discuss.channel") {
return this.isImage
? `/discuss/channel/${this.originThread.id}/image/${this.id}`
: `/discuss/channel/${this.originThread.id}/attachment/${this.id}`;
}
return this.isImage ? `/web/image/${this.id}` : `/web/content/ir.attachment/${this.id}`;
return this.isImage ? `/web/image/${this.id}` : `/web/content/${this.id}`;
}
/**
@@ -6,9 +6,9 @@
<t t-if="state.thread.mainAttachment">
<h3 t-if="!state.thread.mainAttachment.isPdf" class="mt0 mb8 ps-2 text-muted float-end"><t t-esc="state.thread.mainAttachment.filename"/></h3>
<div t-if="state.thread.mainAttachment.isImage" class="o-mail-Attachment-imgContainer">
<img id="attachment_img" class="img img-fluid d-block" t-attf-src="state.thread.mainAttachment.defaultSource"/>
<img id="attachment_img" class="img img-fluid d-block" t-att-src="state.thread.mainAttachment.defaultSource"/>
</div>
<iframe t-if="state.thread.mainAttachment.isPdf" class="mb48" t-attf-src="state.thread.mainAttachment.defaultSource" t-ref="iframeViewerPdf"/>
<iframe t-if="state.thread.mainAttachment.isPdf" class="mb48" t-att-src="state.thread.mainAttachment.defaultSource" t-ref="iframeViewerPdf"/>
<t t-if="state.thread.attachmentsInWebClientView.length > 1">
<a class="arrow o_move_previous text-center" href="#" t-on-click.prevent="onClickPrevious">
<span class="oi oi-chevron-left"/>
@@ -0,0 +1,15 @@
/* @odoo-module */
import { Attachment } from "@mail/attachments/attachment_model";
import { patch } from "@web/core/utils/patch";
patch(Attachment.prototype, "discuss", {
get urlRoute() {
if (!this.accessToken && this.originThread?.model === "discuss.channel") {
return this.isImage
? `/discuss/channel/${this.originThread.id}/image/${this.id}`
: `/discuss/channel/${this.originThread.id}/attachment/${this.id}`;
}
return this._super();
},
});