Skip to content

Commit b382f3d

Browse files
committed
[ADD] web_filter_header_button
1 parent 9f6a3d9 commit b382f3d

14 files changed

Lines changed: 190 additions & 104 deletions

web_filter_header_button/README.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Filter Button
77
!! This file is generated by oca-gen-addon-readme !!
88
!! changes will be overwritten. !!
99
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10-
!! source digest: sha256:ca8b5898e3d8f183bcf7575688c5858938135a593f03f422767e69367be33984
10+
!! source digest: sha256:329df6eb8c7d4f5db280601a3416d14460c294c342081e38909eabc689074bcf
1111
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1212
1313
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -17,13 +17,13 @@ Filter Button
1717
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1818
:alt: License: AGPL-3
1919
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
20-
:target: https://github.com/OCA/web/tree/18.0/web_filter_header_button
20+
:target: https://github.com/OCA/web/tree/16.0/web_filter_header_button
2121
:alt: OCA/web
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/web-18-0/web-18-0-web_filter_header_button
23+
:target: https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_filter_header_button
2424
:alt: Translate me on Weblate
2525
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=18.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=16.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -109,7 +109,7 @@ Bug Tracker
109109
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
110110
In case of trouble, please check there if your issue has already been reported.
111111
If you spotted it first, help us to smash it by providing a detailed and welcomed
112-
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_filter_header_button%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
112+
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_filter_header_button%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
113113

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

@@ -120,6 +120,7 @@ Authors
120120
-------
121121

122122
* Tecnativa
123+
* Therp Bv
123124

124125
Contributors
125126
------------
@@ -128,6 +129,8 @@ Contributors
128129

129130
- David Vidal
130131

132+
- `Therp Bv <https://therp.nl>`__
133+
131134
Maintainers
132135
-----------
133136

@@ -141,6 +144,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
141144
mission is to support the collaborative development of Odoo features and
142145
promote its widespread use.
143146

144-
This module is part of the `OCA/web <https://github.com/OCA/web/tree/18.0/web_filter_header_button>`_ project on GitHub.
147+
This module is part of the `OCA/web <https://github.com/OCA/web/tree/16.0/web_filter_header_button>`_ project on GitHub.
145148

146149
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Copyright 2024 Tecnativa - David Vidal
1+
# Copyright 2026 Therp Bv
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
33
{
44
"name": "Filter Button",
5-
"version": "18.0.1.0.0",
5+
"version": "16.0.1.0.0",
66
"summary": "Show selected filters as buttons in the control panel",
7-
"author": "Tecnativa, Odoo Community Association (OCA)",
7+
"author": "Tecnativa, Therp Bv, Odoo Community Association (OCA)",
88
"license": "AGPL-3",
99
"category": "Server UX",
1010
"website": "https://github.com/OCA/web",
@@ -14,6 +14,15 @@
1414
"demo/ir_module_module_view.xml",
1515
],
1616
"assets": {
17-
"web.assets_backend": ["web_filter_header_button/static/src/**/*"],
17+
"web.assets_backend": [
18+
"web_filter_header_button/static/src/control_panel/control_panel_patch.js",
19+
"web_filter_header_button/static/src/control_panel/control_panel.xml",
20+
"web_filter_header_button/static/src/filter_button/filter_header_buttons.scss",
21+
"web_filter_header_button/static/src/filter_button/filter_button.js",
22+
"web_filter_header_button/static/src/filter_button/filter_button.xml",
23+
"web_filter_header_button/static/src/search/search_model_patch.js",
24+
"web_filter_header_button/static/src/search/search_arch_parser_patch.js",
25+
],
1826
},
27+
"installable": True,
1928
}

web_filter_header_button/i18n/it.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
msgid ""
55
msgstr ""
6-
"Project-Id-Version: Odoo Server 18.0\n"
6+
"Project-Id-Version: Odoo Server 16.0\n"
77
"Report-Msgid-Bugs-To: \n"
88
"Last-Translator: Automatically generated\n"
99
"Language-Team: none\n"

web_filter_header_button/i18n/web_filter_header_button.pot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
msgid ""
55
msgstr ""
6-
"Project-Id-Version: Odoo Server 18.0\n"
6+
"Project-Id-Version: Odoo Server 16.0\n"
77
"Report-Msgid-Bugs-To: \n"
88
"Last-Translator: \n"
99
"Language-Team: \n"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
- [Tecnativa](https://tecnativa.com)
22
- David Vidal
3+
- [Therp Bv](https://therp.nl)

web_filter_header_button/static/description/index.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,9 @@ <h1 class="title">Filter Button</h1>
367367
!! This file is generated by oca-gen-addon-readme !!
368368
!! changes will be overwritten. !!
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370-
!! source digest: sha256:ca8b5898e3d8f183bcf7575688c5858938135a593f03f422767e69367be33984
370+
!! source digest: sha256:329df6eb8c7d4f5db280601a3416d14460c294c342081e38909eabc689074bcf
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<p><a class="reference external image-reference" 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 image-reference" 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 image-reference" href="https://github.com/OCA/web/tree/18.0/web_filter_header_button"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-18-0/web-18-0-web_filter_header_button"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<p><a class="reference external image-reference" 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 image-reference" 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 image-reference" href="https://github.com/OCA/web/tree/16.0/web_filter_header_button"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_filter_header_button"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373373
<p>This module allows to add some selected filters as buttons in the header
374374
control panel.</p>
375375
<p><strong>Table of contents</strong></p>
@@ -449,7 +449,7 @@ <h1><a class="toc-backref" href="#toc-entry-5">Bug Tracker</a></h1>
449449
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
450450
In case of trouble, please check there if your issue has already been reported.
451451
If you spotted it first, help us to smash it by providing a detailed and welcomed
452-
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_filter_header_button%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
452+
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_filter_header_button%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
453453
<p>Do not contact contributors directly about support or help with technical issues.</p>
454454
</div>
455455
<div class="section" id="credits">
@@ -458,6 +458,7 @@ <h1><a class="toc-backref" href="#toc-entry-6">Credits</a></h1>
458458
<h2><a class="toc-backref" href="#toc-entry-7">Authors</a></h2>
459459
<ul class="simple">
460460
<li>Tecnativa</li>
461+
<li>Therp Bv</li>
461462
</ul>
462463
</div>
463464
<div class="section" id="contributors">
@@ -467,6 +468,7 @@ <h2><a class="toc-backref" href="#toc-entry-8">Contributors</a></h2>
467468
<li>David Vidal</li>
468469
</ul>
469470
</li>
471+
<li><a class="reference external" href="https://therp.nl">Therp Bv</a></li>
470472
</ul>
471473
</div>
472474
<div class="section" id="maintainers">
@@ -478,7 +480,7 @@ <h2><a class="toc-backref" href="#toc-entry-9">Maintainers</a></h2>
478480
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
479481
mission is to support the collaborative development of Odoo features and
480482
promote its widespread use.</p>
481-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/18.0/web_filter_header_button">OCA/web</a> project on GitHub.</p>
483+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/16.0/web_filter_header_button">OCA/web</a> project on GitHub.</p>
482484
<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>
483485
</div>
484486
</div>
Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,44 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<templates xml:space="preserve">
3-
<t t-inherit="web.ControlPanel" t-inherit-mode="extension">
4-
<xpath expr="//div[hasclass('o_control_panel_main')]" position="after">
5-
<t t-if="this.env.config.viewType and this.env.config.viewType !== 'form'">
6-
<Transition
7-
visible="state.showButtonFilters"
8-
name="'o-fade'"
9-
t-slot-scope="transition"
10-
leaveDuration="500"
11-
>
12-
<div
13-
class="o_embedded_actions overflow-hidden d-flex flex-wrap w-100 align-items-center justify-content-center gap-2"
14-
t-att-class="transition.className"
15-
>
16-
<FilterButton
17-
filters="this.env.searchModel.headerButtonFilters"
18-
/>
19-
</div>
20-
</Transition>
21-
</t>
22-
</xpath>
23-
24-
<xpath expr="//button[@t-on-click='onClickShowEmbedded']" position="after">
3+
<t
4+
t-name="web_filter_header_button.ControlPanel.Regular"
5+
t-inherit="web.ControlPanel.Regular"
6+
t-inherit-mode="extension"
7+
owl="1"
8+
>
9+
<xpath expr="//div[hasclass('o_search_options')]/*[last()]" position="after">
10+
<t t-set="sm" t-value="env.searchModel" />
11+
<t
12+
t-set="hbf"
13+
t-value="(sm &amp;&amp; sm.headerButtonFilters) ? sm.headerButtonFilters : []"
14+
/>
2515
<button
26-
t-if="state.headerButtonFilters?.length"
27-
class="btn btn-secondary"
28-
t-att-class="{active: state.showButtonFilters}"
29-
t-on-click="onClickShowshowButtonFilters"
16+
t-if="hbf.length"
17+
type="button"
18+
class="btn btn-secondary mx-2 o_filter_header_toggle"
19+
t-att-title="env._t('Toggle filter buttons')"
20+
t-att-aria-label="env._t('Toggle filter buttons')"
21+
t-att-aria-expanded="hbfShowButtonFilters ? 'true' : 'false'"
22+
t-on-click.stop.prevent="onClickToggleHeaderButtons"
3023
>
31-
<i class="fa fa-filter" />
24+
<i class="fa fa-sliders" /> Filter Buttons
3225
</button>
3326
</xpath>
3427
</t>
28+
29+
<t t-inherit="web.ControlPanel" t-inherit-mode="extension" owl="1">
30+
<xpath expr="//div[hasclass('o_control_panel')]" position="inside">
31+
<t t-set="sm" t-value="env.searchModel" />
32+
<t
33+
t-set="hbf"
34+
t-value="(sm &amp;&amp; sm.headerButtonFilters) ? sm.headerButtonFilters : []"
35+
/>
36+
<div
37+
t-if="hbf.length"
38+
t-att-class="'o_filter_header_button_bar ' + (hbfShowButtonFilters ? 'o_filter_header_button_bar_show' : 'o_filter_header_button_bar_hide')"
39+
>
40+
<FilterButton filters="hbf" />
41+
</div>
42+
</xpath>
43+
</t>
3544
</templates>

web_filter_header_button/static/src/control_panel/control_panel_patch.esm.js

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/** @odoo-module **/
2+
3+
import {patch} from "@web/core/utils/patch";
4+
import {ControlPanel} from "@web/search/control_panel/control_panel";
5+
import {useState} from "@odoo/owl";
6+
7+
import {FilterButton} from "../filter_button/filter_button";
8+
9+
patch(ControlPanel, "web_filter_header_button.ControlPanel.components", {
10+
components: {
11+
...ControlPanel.components,
12+
FilterButton,
13+
},
14+
});
15+
16+
patch(ControlPanel.prototype, "web_filter_header_button.ControlPanel", {
17+
setup() {
18+
this._super(...arguments);
19+
20+
this.state = useState({
21+
...(this.state || {}),
22+
showButtonFilters: false,
23+
});
24+
25+
this._hbfUserToggled = false;
26+
27+
this.onClickToggleHeaderButtons = this.onClickToggleHeaderButtons.bind(this);
28+
},
29+
30+
/**
31+
* Always show by default when header button filters exist.
32+
* If user toggles, respect the toggled value afterward.
33+
*/
34+
get hbfShowButtonFilters() {
35+
const headerButtonFilters = this.env?.searchModel?.headerButtonFilters || [];
36+
37+
if (!headerButtonFilters.length) {
38+
return false;
39+
}
40+
41+
if (!this._hbfUserToggled) {
42+
return true;
43+
}
44+
45+
return this.state.showButtonFilters;
46+
},
47+
48+
onClickToggleHeaderButtons() {
49+
const currentlyVisible = this.hbfShowButtonFilters;
50+
51+
this._hbfUserToggled = true;
52+
this.state.showButtonFilters = !currentlyVisible;
53+
},
54+
});

web_filter_header_button/static/src/filter_button/filter_button.esm.js renamed to web_filter_header_button/static/src/filter_button/filter_button.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/** @odoo-module **/
2+
13
import {Component} from "@odoo/owl";
24

35
export class FilterButton extends Component {

0 commit comments

Comments
 (0)