portal documents working with PDF preview.

This commit is contained in:
Marc Durepos 2023-09-21 19:34:47 -04:00
parent 679e29f4da
commit 981af372f6

View file

@ -32,9 +32,8 @@
</t> </t>
</t> </t>
</template> </template>
<template id="document_portal_template" name="Document Portal Template" <template id="document_portal_template" name="Document Portal Template">
inherit_id="portal.portal_sidebar" primary="True"> <t t-call="portal.portal_layout">
<xpath expr="//div[hasclass('o_portal_sidebar')]" position="inside">
<t t-set="o_portal_fullwidth_alert" <t t-set="o_portal_fullwidth_alert"
groups="documents.group_documents_user"> groups="documents.group_documents_user">
<t t-call="portal.portal_back_in_edit_mode"> <t t-call="portal.portal_back_in_edit_mode">
@ -42,42 +41,42 @@
t-value="'/web#model=%s&amp;id=%s&amp;action=%s&amp;view_type=form' % (document._name, document.id, action.id)"/> t-value="'/web#model=%s&amp;id=%s&amp;action=%s&amp;view_type=form' % (document._name, document.id, action.id)"/>
</t> </t>
</t> </t>
<div class="row mt16"> <t t-call="portal.portal_record_layout">
<!-- Sidebar --> <t t-set="card_header">
<t t-call="portal.portal_record_sidebar"> <div class="row no-gutters">
<t t-set="classes">col-lg-auto d-print-none</t> <h5 class="mb-1 mb-md-0">
<t t-set="title"> <span t-field="document.name"/>
<h2 class="mb-0"> </h5>
<b>Document Info</b> </div>
</h2>
</t> </t>
<t t-set="entries"> <t t-set="card_body">
<!-- Main Document Contents -->
<div id="document_content"
class="col-12 col-lg justify-content-end w-100 h-100">
<div t-if="document.attachment_type == 'image'"
class="o_attachment_preview_img">
<img id="attachment_img"
class="img img-fluid d-block"
t-attf-src="/documents/content/{{document.id}}"/>
</div>
<iframe t-if="document.mimetype == 'application/pdf'"
class="mb48 w-100 min-vh-100"
t-attf-src="/web/static/lib/pdfjs/web/viewer.html?file=/documents/content/{{document.id}}&amp;filename={{document.name}}"/>
<ul class="list-group list-group-flush flex-wrap flex-row flex-lg-column"> <ul class="list-group list-group-flush flex-wrap flex-row flex-lg-column">
<li class="list-group-item flex-grow-1 b-0"> <li class="list-group-item flex-grow-1 b-0">
File name: <t t-esc="document.name"/> <a class="btn btn-secondary btn-block o_download_btn"
t-att-href="document.get_portal_url(download=True)">
</li> Download</a>
<li class="list-group-item flex-grow-1 b-0">
<strong class="text-muted">File Type:
<t t-esc="document.mimetype"/>
</strong>
</li> </li>
<li class="list-group-item flex-grow-1 b-0"> <li class="list-group-item flex-grow-1 b-0">
<strong class="text-muted">File Size: <strong class="text-muted">File Size:
<t t-call="documents.format_file_size"/> <t t-call="documents.format_file_size"/>
</strong> </strong>
</li> </li>
<li class="list-group-item flex-grow-1 b-0">
<a class="btn btn-secondary btn-block o_download_btn"
t-att-href="document.get_portal_url(download=True)">
Download</a>
</li>
</ul> </ul>
</div>
</t> </t>
</t> </t>
<!-- Main Document Contents -->
<div id="document_content" class="col-12 col-lg justify-content-end">
<div class="card">
<!-- Chatter --> <!-- Chatter -->
<div id="document_communication" class="card-body"> <div id="document_communication" class="card-body">
<h2>History</h2> <h2>History</h2>
@ -85,10 +84,7 @@
<t t-set="object" t-value="document"/> <t t-set="object" t-value="document"/>
</t> </t>
</div> </div>
</div> </t>
</div>
</div>
</xpath>
</template> </template>
<template id="portal_breadcrumbs" inherit_id="portal.portal_breadcrumbs"> <template id="portal_breadcrumbs" inherit_id="portal.portal_breadcrumbs">
<xpath expr="//ol[hasclass('o_portal_submenu')]" position="inside"> <xpath expr="//ol[hasclass('o_portal_submenu')]" position="inside">