diff --git a/web_widget_image_gallery/README.rst b/web_widget_image_gallery/README.rst new file mode 100644 index 00000000000..0def8164858 --- /dev/null +++ b/web_widget_image_gallery/README.rst @@ -0,0 +1,97 @@ +==================== +Image Gallery Widget +==================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:bdf4420a8c609da5fafebdebd86f0b54816ee401b89cfbc7dd02f0aae48bbd58 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github + :target: https://github.com/OCA/web/tree/18.0/web_widget_image_gallery + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-18-0/web-18-0-web_widget_image_gallery + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows you to set up an image gallery in a view (such as a +Kanban view). + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Example: +-------- + +.. code:: xml + + + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Tecnativa + +Contributors +------------ + +- `Tecnativa `__: + + - Víctor Martínez + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +.. |maintainer-victoralmau| image:: https://github.com/victoralmau.png?size=40px + :target: https://github.com/victoralmau + :alt: victoralmau + +Current `maintainer `__: + +|maintainer-victoralmau| + +This module is part of the `OCA/web `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_widget_image_gallery/__init__.py b/web_widget_image_gallery/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/web_widget_image_gallery/__manifest__.py b/web_widget_image_gallery/__manifest__.py new file mode 100644 index 00000000000..b9bfe3a5f6d --- /dev/null +++ b/web_widget_image_gallery/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2026 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + "name": "Image Gallery Widget", + "version": "18.0.1.0.0", + "license": "AGPL-3", + "author": "Tecnativa, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/web", + "depends": ["web"], + "assets": { + "web.assets_backend": [ + "web_widget_image_gallery/static/src/**/*.js", + "web_widget_image_gallery/static/src/**/*.xml", + ], + }, + "installable": True, + "maintainers": ["victoralmau"], +} diff --git a/web_widget_image_gallery/i18n/web_widget_image_gallery.pot b/web_widget_image_gallery/i18n/web_widget_image_gallery.pot new file mode 100644 index 00000000000..e3530b4459f --- /dev/null +++ b/web_widget_image_gallery/i18n/web_widget_image_gallery.pot @@ -0,0 +1,15 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-04-20 11:18+0000\n" +"PO-Revision-Date: 2026-04-20 11:18+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" diff --git a/web_widget_image_gallery/pyproject.toml b/web_widget_image_gallery/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/web_widget_image_gallery/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/web_widget_image_gallery/readme/CONTRIBUTORS.md b/web_widget_image_gallery/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..ed67b081ec1 --- /dev/null +++ b/web_widget_image_gallery/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [Tecnativa](https://www.tecnativa.com): + - Víctor Martínez diff --git a/web_widget_image_gallery/readme/DESCRIPTION.md b/web_widget_image_gallery/readme/DESCRIPTION.md new file mode 100644 index 00000000000..cb8692db974 --- /dev/null +++ b/web_widget_image_gallery/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module allows you to set up an image gallery in a view (such as a Kanban view). diff --git a/web_widget_image_gallery/readme/USAGE.md b/web_widget_image_gallery/readme/USAGE.md new file mode 100644 index 00000000000..8839b558fa0 --- /dev/null +++ b/web_widget_image_gallery/readme/USAGE.md @@ -0,0 +1,5 @@ +## Example: + +``` xml + +``` diff --git a/web_widget_image_gallery/static/description/icon.png b/web_widget_image_gallery/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/web_widget_image_gallery/static/description/icon.png differ diff --git a/web_widget_image_gallery/static/description/index.html b/web_widget_image_gallery/static/description/index.html new file mode 100644 index 00000000000..71b20b2d48b --- /dev/null +++ b/web_widget_image_gallery/static/description/index.html @@ -0,0 +1,442 @@ + + + + + +Image Gallery Widget + + + + + + diff --git a/web_widget_image_gallery/static/src/js/image_gallery_field.esm.js b/web_widget_image_gallery/static/src/js/image_gallery_field.esm.js new file mode 100644 index 00000000000..08039e9b92a --- /dev/null +++ b/web_widget_image_gallery/static/src/js/image_gallery_field.esm.js @@ -0,0 +1,51 @@ +import {Component, onWillStart, useState} from "@odoo/owl"; +import {registry} from "@web/core/registry"; +import {useFileViewer} from "@web/core/file_viewer/file_viewer_hook"; +import {useService} from "@web/core/utils/hooks"; + +export class ImageGalleryField extends Component { + static template = "web_widget_image_gallery.ImageGalleryField"; + setup() { + this.orm = useService("orm"); + this.store = useService("mail.store"); + this.fileViewer = useFileViewer(); + this.state = useState({ + attachments: [], + }); + onWillStart(() => this._loadImages()); + } + + async _loadImages() { + const record = this.props.record; + if (!record || !record.data) { + this.state.attachments = []; + return; + } + const attachments = record.data[this.props.name].records; + this.state.attachments = attachments.map((att) => ({ + id: att.resId, + name: att.data.name, + mimetype: att.data.mimetype, + })); + } + openGallery = (index = 0) => { + this.state.index = index; + const files = this.state.attachments.map((att) => + this.store.Attachment.insert({ + id: att.id, + name: att.name, + filename: att.name, + mimetype: att.mimetype, + }) + ); + this.fileViewer.open(files[index], files); + }; +} +export const imageGalleryField = { + component: ImageGalleryField, + relatedFields: [ + {name: "name", type: "char"}, + {name: "mimetype", type: "char"}, + ], +}; +registry.category("fields").add("image_gallery", imageGalleryField); diff --git a/web_widget_image_gallery/static/src/xml/image_gallery_field.xml b/web_widget_image_gallery/static/src/xml/image_gallery_field.xml new file mode 100644 index 00000000000..7a08106b7fc --- /dev/null +++ b/web_widget_image_gallery/static/src/xml/image_gallery_field.xml @@ -0,0 +1,12 @@ + + +