[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 committed by Houzéfa Abbasbhay
parent 96a866592f
commit 411822d443
No known key found for this signature in database
GPG Key ID: B30E9425D9198EC1
16 changed files with 150 additions and 54 deletions

View File

@ -14,13 +14,13 @@ Preview attachments
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github
:target: https://github.com/OCA/knowledge/tree/12.0/attachment_preview
:target: https://github.com/OCA/knowledge/tree/15.0/attachment_preview
:alt: OCA/knowledge
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/knowledge-12-0/knowledge-12-0-attachment_preview
:target: https://translation.odoo-community.org/projects/knowledge-15-0/knowledge-15-0-attachment_preview
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/118/12.0
:target: https://runbot.odoo-community.org/runbot/118/15.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@ -64,7 +64,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/knowledge/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/knowledge/issues/new?body=module:%20attachment_preview%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/knowledge/issues/new?body=module:%20attachment_preview%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@ -104,6 +104,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
This module is part of the `OCA/knowledge <https://github.com/OCA/knowledge/tree/12.0/attachment_preview>`_ project on GitHub.
This module is part of the `OCA/knowledge <https://github.com/OCA/knowledge/tree/15.0/attachment_preview>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -6,8 +6,6 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-08-23 14:25+0000\n"
"PO-Revision-Date: 2022-08-23 14:25+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@ -36,8 +34,8 @@ msgstr ""
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.js:0
#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.js:0
#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.esm.js:0
#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.esm.js:0
#, python-format
msgid "Preview %s"
msgstr ""

View File

@ -10,6 +10,7 @@ msgstr ""
"PO-Revision-Date: 2022-08-23 14:27+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
@ -36,8 +37,7 @@ msgstr "Vorschau"
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.js:0
#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.js:0
#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.esm.js:0
#, python-format
msgid "Preview %s"
msgstr "Vorschau %s"

View File

@ -26,8 +26,21 @@ msgstr ""
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:188
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:216
#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
#, python-format
msgid "Open in new page"
msgstr ""
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
#, python-format
msgid "Preview"
msgstr ""
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.esm.js:0
#, python-format
msgid "Preview %s"
msgstr "Previsualizar %s"

View File

@ -26,8 +26,21 @@ msgstr ""
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:188
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:216
#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
#, python-format
msgid "Open in new page"
msgstr ""
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
#, python-format
msgid "Preview"
msgstr ""
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.esm.js:0
#, python-format
msgid "Preview %s"
msgstr "Anteprima %s"

View File

@ -25,8 +25,21 @@ msgstr ""
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:188
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:216
#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
#, python-format
msgid "Open in new page"
msgstr ""
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
#, python-format
msgid "Preview"
msgstr ""
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.esm.js:0
#, python-format
msgid "Preview %s"
msgstr "Voorbeeld %s"

View File

@ -21,8 +21,21 @@ msgstr ""
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:188
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:216
#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
#, python-format
msgid "Open in new page"
msgstr ""
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
#, python-format
msgid "Preview"
msgstr ""
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.esm.js:0
#, python-format
msgid "Preview %s"
msgstr ""

View File

@ -26,8 +26,21 @@ msgstr ""
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:188
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:216
#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
#, python-format
msgid "Open in new page"
msgstr ""
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
#, python-format
msgid "Preview"
msgstr ""
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.esm.js:0
#, python-format
msgid "Preview %s"
msgstr "Antever %s"

View File

@ -28,8 +28,21 @@ msgstr ""
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:188
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:216
#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
#, python-format
msgid "Open in new page"
msgstr ""
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
#, python-format
msgid "Preview"
msgstr ""
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.esm.js:0
#, python-format
msgid "Preview %s"
msgstr "Predogled %s"

View File

@ -23,8 +23,21 @@ msgstr "Ek"
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:188
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:216
#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
#, python-format
msgid "Open in new page"
msgstr ""
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
#, python-format
msgid "Preview"
msgstr ""
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.esm.js:0
#, python-format
msgid "Preview %s"
msgstr "%s Önizle"

View File

@ -10,6 +10,7 @@ msgstr ""
"PO-Revision-Date: 2022-08-23 14:29+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
@ -36,8 +37,7 @@ msgstr "Xem trước"
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.js:0
#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.js:0
#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.esm.js:0
#, python-format
msgid "Preview %s"
msgstr "Xem trước %s"

View File

@ -26,8 +26,21 @@ msgstr ""
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:188
#: code:addons/attachment_preview/static/src/js/attachment_preview.js:216
#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
#, python-format
msgid "Open in new page"
msgstr ""
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/xml/attachment_preview.xml:0
#, python-format
msgid "Preview"
msgstr ""
#. module: attachment_preview
#. openerp-web
#: code:addons/attachment_preview/static/src/js/components/chatter/chatter.esm.js:0
#, python-format
msgid "Preview %s"
msgstr "预览 %s"

View File

@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/knowledge/tree/12.0/attachment_preview"><img alt="OCA/knowledge" src="https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/knowledge-12-0/knowledge-12-0-attachment_preview"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/118/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/knowledge/tree/15.0/attachment_preview"><img alt="OCA/knowledge" src="https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/knowledge-15-0/knowledge-15-0-attachment_preview"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/118/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This addon allows to preview attachments supported by <a class="reference external" href="http://viewerjs.org">http://viewerjs.org</a>.</p>
<p>Currently, thats most Libreoffice files and PDFs.</p>
<img alt="Screenshot of split form view" src="https://raw.githubusercontent.com/attachment_preview/static/description/screenshot-split.png" style="width: 100%;" />
@ -409,7 +409,7 @@ next to the navigational buttons you can open the preview in a separate window.<
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/knowledge/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/knowledge/issues/new?body=module:%20attachment_preview%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/knowledge/issues/new?body=module:%20attachment_preview%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@ -444,7 +444,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/knowledge/tree/12.0/attachment_preview">OCA/knowledge</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/knowledge/tree/15.0/attachment_preview">OCA/knowledge</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

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) {
self._showPreview(
attachment_id,
attachment_url,
attachment_extension,
attachment_title,
split_screen
);
} else {
rpc.query({
model: "ir.attachment",
method: "get_attachment_extension",
args: [attachment_id],
}).then(function (extension) {
self.showPreview(
self._showPreview(
attachment_id,
attachment_url,
extension,
null,
attachment_title,
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"