From 98172cdd4771230e8da13be511524a8d667f359c Mon Sep 17 00:00:00 2001 From: Ariel Barreiros Date: Thu, 14 Nov 2024 12:08:11 +0000 Subject: [PATCH] [ADD] website_snippet_popup_onclick --- .../odoo/addons/website_snippet_popup_onclik | 1 + setup/website_snippet_popup_onclik/setup.py | 6 + website_snippet_popup_onclik/README.rst | 92 ++++ website_snippet_popup_onclik/__init__.py | 0 website_snippet_popup_onclik/__manifest__.py | 20 + .../readme/CONTRIBUTORS.rst | 4 + .../readme/DESCRIPTION.rst | 1 + website_snippet_popup_onclik/readme/USAGE.rst | 1 + .../static/description/index.html | 434 ++++++++++++++++++ .../static/src/js/popup_trigger.js | 47 ++ .../views/website_popup_snippet.xml | 27 ++ 11 files changed, 633 insertions(+) create mode 120000 setup/website_snippet_popup_onclik/odoo/addons/website_snippet_popup_onclik create mode 100644 setup/website_snippet_popup_onclik/setup.py create mode 100644 website_snippet_popup_onclik/README.rst create mode 100644 website_snippet_popup_onclik/__init__.py create mode 100644 website_snippet_popup_onclik/__manifest__.py create mode 100644 website_snippet_popup_onclik/readme/CONTRIBUTORS.rst create mode 100644 website_snippet_popup_onclik/readme/DESCRIPTION.rst create mode 100644 website_snippet_popup_onclik/readme/USAGE.rst create mode 100644 website_snippet_popup_onclik/static/description/index.html create mode 100644 website_snippet_popup_onclik/static/src/js/popup_trigger.js create mode 100644 website_snippet_popup_onclik/views/website_popup_snippet.xml diff --git a/setup/website_snippet_popup_onclik/odoo/addons/website_snippet_popup_onclik b/setup/website_snippet_popup_onclik/odoo/addons/website_snippet_popup_onclik new file mode 120000 index 0000000000..32d984ee32 --- /dev/null +++ b/setup/website_snippet_popup_onclik/odoo/addons/website_snippet_popup_onclik @@ -0,0 +1 @@ +../../../../website_snippet_popup_onclik \ No newline at end of file diff --git a/setup/website_snippet_popup_onclik/setup.py b/setup/website_snippet_popup_onclik/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/website_snippet_popup_onclik/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/website_snippet_popup_onclik/README.rst b/website_snippet_popup_onclik/README.rst new file mode 100644 index 0000000000..fc57ff921f --- /dev/null +++ b/website_snippet_popup_onclik/README.rst @@ -0,0 +1,92 @@ +===================== +Website Popup Trigger +===================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:dfc7d6430dbe4c6af813dc484518b8d6c529a7998c632f8907a0f0c522e5e03c + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fwebsite-lightgray.png?logo=github + :target: https://github.com/OCA/website/tree/16.0/website_snippet_popup_onclik + :alt: OCA/website +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/website-16-0/website-16-0-website_snippet_popup_onclik + :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/website&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the popup snippet and adds the onClick trigger already present in Odoo 17 + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +From the popup widget on the website editor, now there is a On Click (via link) option on the Display field + +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 +~~~~~~~ + +* Binhex + +Contributors +~~~~~~~~~~~~ + +* `Binhex `_: + + * Jorge Rubén Elena Poblet + * Ariel Barreiros + +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-arielbarreiros96| image:: https://github.com/arielbarreiros96.png?size=40px + :target: https://github.com/arielbarreiros96 + :alt: arielbarreiros96 + +Current `maintainer `__: + +|maintainer-arielbarreiros96| + +This module is part of the `OCA/website `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/website_snippet_popup_onclik/__init__.py b/website_snippet_popup_onclik/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/website_snippet_popup_onclik/__manifest__.py b/website_snippet_popup_onclik/__manifest__.py new file mode 100644 index 0000000000..05171b31f9 --- /dev/null +++ b/website_snippet_popup_onclik/__manifest__.py @@ -0,0 +1,20 @@ +{ + "name": "Website Popup Trigger", + "version": "16.0.1.0.0", + "author": "Binhex, Odoo Community Association (OCA)", + "category": "Website", + "summary": 'Adds an "On Click" trigger option for website popups', + "website": "https://github.com/OCA/website", + "license": "AGPL-3", + "depends": ["web_editor", "website"], + "data": [ + "views/website_popup_snippet.xml", + ], + "assets": { + "web.assets_frontend": [ + "website_popup_trigger/static/src/js/popup_trigger.js", + ], + }, + "installable": True, + "maintainers": ["arielbarreiros96"], +} diff --git a/website_snippet_popup_onclik/readme/CONTRIBUTORS.rst b/website_snippet_popup_onclik/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..e4636a4c11 --- /dev/null +++ b/website_snippet_popup_onclik/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* `Binhex `_: + + * Jorge Rubén Elena Poblet + * Ariel Barreiros diff --git a/website_snippet_popup_onclik/readme/DESCRIPTION.rst b/website_snippet_popup_onclik/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..cb5d564fc2 --- /dev/null +++ b/website_snippet_popup_onclik/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module extends the popup snippet and adds the onClick trigger already present in Odoo 17 diff --git a/website_snippet_popup_onclik/readme/USAGE.rst b/website_snippet_popup_onclik/readme/USAGE.rst new file mode 100644 index 0000000000..c66bc87558 --- /dev/null +++ b/website_snippet_popup_onclik/readme/USAGE.rst @@ -0,0 +1 @@ +From the popup widget on the website editor, now there is a On Click (via link) option on the Display field diff --git a/website_snippet_popup_onclik/static/description/index.html b/website_snippet_popup_onclik/static/description/index.html new file mode 100644 index 0000000000..a5a233b4e4 --- /dev/null +++ b/website_snippet_popup_onclik/static/description/index.html @@ -0,0 +1,434 @@ + + + + + +Website Popup Trigger + + + +
+

Website Popup Trigger

+ + +

Beta License: AGPL-3 OCA/website Translate me on Weblate Try me on Runboat

+

This module extends the popup snippet and adds the onClick trigger already present in Odoo 17

+

Table of contents

+ +
+

Usage

+

From the popup widget on the website editor, now there is a On Click (via link) option on the Display field

+
+
+

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

+
    +
  • Binhex
  • +
+
+
+

Contributors

+
    +
  • Binhex:
      +
    • Jorge Rubén Elena Poblet
    • +
    • Ariel Barreiros
    • +
    +
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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.

+

Current maintainer:

+

arielbarreiros96

+

This module is part of the OCA/website project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/website_snippet_popup_onclik/static/src/js/popup_trigger.js b/website_snippet_popup_onclik/static/src/js/popup_trigger.js new file mode 100644 index 0000000000..c590f49fb4 --- /dev/null +++ b/website_snippet_popup_onclik/static/src/js/popup_trigger.js @@ -0,0 +1,47 @@ +odoo.define("website.s_popup_options", function (require) { + "use strict"; + + const options = require("web_editor.snippets.options"); + + options.registry.SnippetPopup = options.Class.extend({ + start: function () { + this._super.apply(this, arguments); + console.log("SnippetPopup logic initialized"); + }, + + /** + * Custom handler for "On Click" option. + */ + onClickOptionHandler: function () { + console.log("On Click option triggered"); + this._bindClickEvent(); + }, + + /** + * Bind click event to the trigger button that shows the popup. + */ + _bindClickEvent: function () { + const button = document.querySelector( + 'button[data-popup-action="triggerOnClick"]' + ); + if (button) { + button.addEventListener("click", (event) => { + event.preventDefault(); + console.log("Popup trigger button clicked"); + this._showPopup(); + }); + } + }, + + /** + * Function to show the popup when triggered. + */ + _showPopup: function () { + const popupElement = document.querySelector(".s_popup"); + if (popupElement) { + $(popupElement).modal("show"); + console.log("Popup displayed"); + } + }, + }); +}); diff --git a/website_snippet_popup_onclik/views/website_popup_snippet.xml b/website_snippet_popup_onclik/views/website_popup_snippet.xml new file mode 100644 index 0000000000..ef5890235e --- /dev/null +++ b/website_snippet_popup_onclik/views/website_popup_snippet.xml @@ -0,0 +1,27 @@ + + + Custom Popup JS + web.assets_frontend + website_popup_trigger/static/src/js/popup_trigger.js + + +