From 5292cf4edf4d51173046185d8f9b1c8d946d9bf3 Mon Sep 17 00:00:00 2001 From: kobros-tech Date: Sat, 30 Nov 2024 03:02:47 +0300 Subject: [PATCH] [17.0][MIG] website_search_header: Migration to 17.0 --- website_search_header/README.rst | 28 ++--- website_search_header/__manifest__.py | 6 +- website_search_header/pyproject.toml | 3 + website_search_header/readme/CONTRIBUTORS.md | 2 + website_search_header/readme/CONTRIBUTORS.rst | 2 - .../{DESCRIPTION.rst => DESCRIPTION.md} | 0 website_search_header/readme/USAGE.md | 3 + website_search_header/readme/USAGE.rst | 1 - .../static/description/index.html | 23 ++-- .../static/src/js/website.js | 103 +++++++----------- website_search_header/views/templates.xml | 24 ++-- 11 files changed, 96 insertions(+), 99 deletions(-) create mode 100644 website_search_header/pyproject.toml create mode 100644 website_search_header/readme/CONTRIBUTORS.md delete mode 100644 website_search_header/readme/CONTRIBUTORS.rst rename website_search_header/readme/{DESCRIPTION.rst => DESCRIPTION.md} (100%) create mode 100644 website_search_header/readme/USAGE.md delete mode 100644 website_search_header/readme/USAGE.rst diff --git a/website_search_header/README.rst b/website_search_header/README.rst index 5d037ddc9d..2a0c36af18 100644 --- a/website_search_header/README.rst +++ b/website_search_header/README.rst @@ -2,7 +2,7 @@ Website Search in Header ======================== -.. +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! @@ -17,13 +17,13 @@ Website Search in Header :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-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_search_header + :target: https://github.com/OCA/website/tree/17.0/website_search_header :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_search_header + :target: https://translation.odoo-community.org/projects/website-17-0/website-17-0-website_search_header :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 + :target: https://runboat.odoo-community.org/builds?repo=OCA/website&target_branch=17.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -38,7 +38,9 @@ This module adds a search bar in the header of your website Usage ===== -On desktop, the user will be able to show and hide the search input in the website header. While on mobile our searchbox will behave by default. +On desktop, the user will be able to show and hide the search input in +the website header. While on mobile our searchbox will behave by +default. Bug Tracker =========== @@ -46,7 +48,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -54,19 +56,19 @@ Credits ======= Authors -~~~~~~~ +------- * ForgeFlow +* Ooops Contributors -~~~~~~~~~~~~ +------------ - -* Jordi Ballester -* Elmer GarcĂ­a +- ForgeFlow +- Kencove Maintainers -~~~~~~~~~~~ +----------- This module is maintained by the OCA. @@ -78,6 +80,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/website `_ project on GitHub. +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_search_header/__manifest__.py b/website_search_header/__manifest__.py index 8d4cb5c0fd..4912a25e43 100644 --- a/website_search_header/__manifest__.py +++ b/website_search_header/__manifest__.py @@ -4,21 +4,19 @@ { "name": "Website Search in Header", "category": "Website", - "version": "16.0.1.1.0", + "version": "17.0.1.1.0", "author": "ForgeFlow, Ooops, Odoo Community Association (OCA)", "website": "https://github.com/OCA/website", "license": "LGPL-3", "depends": [ "website", - "web", ], "data": [ "views/templates.xml", ], "assets": { - "web.assets_frontend": [ + "website_search_header.assets_frontend": [ "website_search_header/static/src/js/website.js", - "website_search_header/static/src/scss/website_search_header.scss", ], }, "installable": True, diff --git a/website_search_header/pyproject.toml b/website_search_header/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/website_search_header/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/website_search_header/readme/CONTRIBUTORS.md b/website_search_header/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..9651e0b4ff --- /dev/null +++ b/website_search_header/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- ForgeFlow \<\> +- Kencove \<\> diff --git a/website_search_header/readme/CONTRIBUTORS.rst b/website_search_header/readme/CONTRIBUTORS.rst deleted file mode 100644 index 7b25f3c80f..0000000000 --- a/website_search_header/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1,2 +0,0 @@ - -* ForgeFlow diff --git a/website_search_header/readme/DESCRIPTION.rst b/website_search_header/readme/DESCRIPTION.md similarity index 100% rename from website_search_header/readme/DESCRIPTION.rst rename to website_search_header/readme/DESCRIPTION.md diff --git a/website_search_header/readme/USAGE.md b/website_search_header/readme/USAGE.md new file mode 100644 index 0000000000..189ee53c4c --- /dev/null +++ b/website_search_header/readme/USAGE.md @@ -0,0 +1,3 @@ +On desktop, the user will be able to show and hide the search input in +the website header. While on mobile our searchbox will behave by +default. diff --git a/website_search_header/readme/USAGE.rst b/website_search_header/readme/USAGE.rst deleted file mode 100644 index 202d13188f..0000000000 --- a/website_search_header/readme/USAGE.rst +++ /dev/null @@ -1 +0,0 @@ -On desktop, the user will be able to show and hide the search input in the website header. While on mobile our searchbox will behave by default. diff --git a/website_search_header/static/description/index.html b/website_search_header/static/description/index.html index 36f95548c4..2a6c001b07 100644 --- a/website_search_header/static/description/index.html +++ b/website_search_header/static/description/index.html @@ -1,4 +1,3 @@ - @@ -9,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -369,7 +369,7 @@

Website Search in Header

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:0190640b3113a806206eba0406254bfdb594eb50e99f4f870b3815401ff7621f !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

+

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

This module adds a search bar in the header of your website

Table of contents

@@ -386,14 +386,16 @@

Website Search in Header

Usage

-

On desktop, the user will be able to show and hide the search input in the website header. While on mobile our searchbox will behave by default.

+

On desktop, the user will be able to show and hide the search input in +the website header. While on mobile our searchbox will behave by +default.

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.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -409,16 +411,19 @@

Authors

Contributors

Maintainers

This module is maintained by the OCA.

-Odoo Community Association + +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.

-

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

+

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_search_header/static/src/js/website.js b/website_search_header/static/src/js/website.js index 9a3d223733..9eedbe717e 100644 --- a/website_search_header/static/src/js/website.js +++ b/website_search_header/static/src/js/website.js @@ -1,62 +1,43 @@ -odoo.define("website_search_header.search_header", function (require) { +(function () { "use strict"; - - const publicWidget = require("web.public.widget"); - - publicWidget.registry.SearchHeader = publicWidget.Widget.extend({ - selector: "#div_search_button", - - events: { - "click #search_btn_toggle_search": "_onClickSearchBtn", - }, - - start: function () { - const def = this._super.apply(this, arguments); - this.$boxInput = this.$el.find(".o_search_header"); - return def; - }, - - mobileSearch: function () { - if (!this.$boxInput.hasClass("d-none")) { - this.$boxInput.addClass("d-none"); - } - var searchQuery = document.querySelector("input[name='search']").value; - var encodedQuery = encodeURIComponent(searchQuery); - var searchURL = this._getSearchUrl(encodedQuery); - window.location.href = searchURL; - }, - - desktopSearch: function () { - if (!$(".o_search_header").hasClass("d-lg-none")) { - $(".o_search_header").addClass("d-lg-none"); - $("#search_btn_toggle_search i").removeClass("oi-close"); - $("#search_btn_toggle_search i").addClass("oi-search"); - $("#div_search_header").addClass("ms-lg-0"); - $("#div_search_button").addClass("ms-lg-2"); - } else { - $(".o_search_header").removeClass("d-lg-none"); - $("#search_btn_toggle_search i").removeClass("oi-search"); - $("#search_btn_toggle_search i").addClass("oi-close"); - $("#div_search_header").removeClass("ms-lg-0"); - $("#div_search_button").removeClass("ms-lg-2"); - $("input.oe_search_box").focus(); - } - }, - - _onClickSearchBtn: function () { - var screenWidth = - window.innerWidth || - document.documentElement.clientWidth || - document.body.clientWidth; - if (screenWidth < 992) { - this.mobileSearch(); - } else { - this.desktopSearch(); - } - }, - - _getSearchUrl: function (encodedQuery) { - return "/website/search?search=" + encodedQuery + "&order=name+asc"; - }, - }); -}); + function mobileSearch() { + if (!this.$boxInput.hasClass("d-none")) { + this.$boxInput.addClass("d-none"); + } + var searchQuery = document.querySelector("input[name='search']").value; + var encodedQuery = encodeURIComponent(searchQuery); + var searchURL = this._getSearchUrl(encodedQuery); + window.location.href = searchURL; + } + + function desktopSearch() { + if ($(".o_search_header").hasClass("d-lg-none")) { + $(".o_search_header").removeClass("d-lg-none"); + $("#search_btn_toggle_search i").removeClass("oi-search"); + $("#search_btn_toggle_search i").addClass("oi-close"); + $("#div_search_header").removeClass("ms-lg-0"); + $("#div_search_button").removeClass("ms-lg-2"); + $("input.oe_search_box").focus(); + } else { + $(".o_search_header").addClass("d-lg-none"); + $("#search_btn_toggle_search i").removeClass("oi-close"); + $("#search_btn_toggle_search i").addClass("oi-search"); + $("#div_search_header").addClass("ms-lg-0"); + $("#div_search_button").addClass("ms-lg-2"); + } + } + + function searchHeader() { + var screenWidth = + window.innerWidth || + document.documentElement.clientWidth || + document.body.clientWidth; + if (screenWidth < 992) { + mobileSearch(); + } else { + desktopSearch(); + } + } + + window.searchHeader = searchHeader; +})(); diff --git a/website_search_header/views/templates.xml b/website_search_header/views/templates.xml index 973eecba23..26fcada53e 100644 --- a/website_search_header/views/templates.xml +++ b/website_search_header/views/templates.xml @@ -32,13 +32,19 @@ aria-label="Search" t-attf-class="btn oe_search_button btn-primary" title="Search" + t-attf-onclick="searchHeader()" > + + -