Skip to content

Commit

Permalink
[MIG] attachment_preview: Migration to 16.0
Browse files Browse the repository at this point in the history
Overall implementation remains the same as in previous versions:
* patch into attachment list to prepare prev/next buttons in the viewer
* patch into attachment cards to observe clicks on new buttons this
  module adds
* fetch attachment extensions
* add an iframe into the DOM tree next to the main form one, display
  viewer inside it
* add preview button within binary fields

Main changes in this migration:
* update imports/exports to proper JS modules - in particular, this
  fixes "service already defined" console messages we also get in 15.0
* rework FormRenderer injector, previous (legacy) one was no longer used
* patch attachment list / cards with new methods in the mail module
* fix preview button inclusion within binary fields
  • Loading branch information
houzefa-abba committed Sep 29, 2023
1 parent 4a06dba commit bcd570d
Show file tree
Hide file tree
Showing 10 changed files with 334 additions and 570 deletions.
6 changes: 3 additions & 3 deletions attachment_preview/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Preview attachments",
"version": "15.0.1.0.0",
"version": "16.0.1.0.0",
"author": "Therp BV," "Onestein," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/knowledge",
"license": "AGPL-3",
Expand All @@ -15,15 +15,15 @@
"assets": {
"web._assets_primary_variables": [],
"web.assets_backend": [
"attachment_preview/static/src/js/models/attachment_card/attachment_card.esm.js",
"attachment_preview/static/src/js/attachmentPreviewWidget.esm.js",
"attachment_preview/static/src/js/models/attachment_card/attachment_card.esm.js",
"attachment_preview/static/src/js/components/chatter/chatter.esm.js",
"attachment_preview/static/src/scss/attachment_preview.scss",
"attachment_preview/static/src/xml/attachment_preview.xml",
],
"web.assets_frontend": [],
"web.assets_tests": [],
"web.qunit_suite_tests": [],
"web.assets_qweb": ["attachment_preview/static/src/xml/attachment_preview.xml"],
},
"installable": True,
}
3 changes: 3 additions & 0 deletions attachment_preview/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
* Holger Brunn <[email protected]>
* Dennis Sluijk <[email protected]>
* `XCG Consulting <https://xcg-consulting.fr>`_:

* Houzéfa Abbasbhay
8 changes: 8 additions & 0 deletions attachment_preview/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
* Remove `FormRenderer` patch, convert `AttachmentPreviewWidget` into a component instead.
* Remove `BinaryField` patch, convert preview button into a component instead.
* Don't use `bus.trigger("open_attachment_preview", ...)` to open viewer from an attachment; there
must be a smoother way.
* Binary fields only have an external preview button. Also add inline preview; stub code is already
there.
* Add tests to ensure preview & open buttons are rendered in attachment cards.
* Add JS tests to ensure preview & open buttons work as expected (display viewer / open url).
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Widget from "web.Widget";
var active_attachment_index = 0;
var is_first_click = true;

var AttachmentPreviewWidget = Widget.extend({
export const AttachmentPreviewWidget = Widget.extend({
template: "attachment_preview.AttachmentPreviewWidget",
activeIndex: 0,

Expand Down Expand Up @@ -116,9 +116,8 @@ var AttachmentPreviewWidget = Widget.extend({
this.$iframe.attr("src", att.previewUrl);
},

setAttachments: function (attachments, active_attachment_id, first_click) {
is_first_click = first_click;

setAttachments: function (attachments, active_attachment_id) {
is_first_click = true;
if (active_attachment_id) {
this.active_attachment_id = active_attachment_id;
}
Expand All @@ -130,5 +129,3 @@ var AttachmentPreviewWidget = Widget.extend({
}
},
});

export default AttachmentPreviewWidget;
Loading

0 comments on commit bcd570d

Please sign in to comment.