Skip to content

Commit 8e25391

Browse files
committed
[MIG] web_filter_header_button: Migration to 18.0
TT54366
1 parent c23491d commit 8e25391

12 files changed

Lines changed: 177 additions & 102 deletions

File tree

web_filter_header_button/README.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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/15.0/web_filter_header_button
20+
:target: https://github.com/OCA/web/tree/18.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-15-0/web-15-0-web_filter_header_button
23+
:target: https://translation.odoo-community.org/projects/web-18-0/web-18-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=15.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=18.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -84,6 +84,9 @@ You can show filter, groups or even favorites.
8484
Usage
8585
=====
8686

87+
In a search view with header filter buttons, you'll see a filter icon
88+
(funnel). Use it to unfold the filters.
89+
8790
There's a demo implementation in ``Apps`` and you can play around
8891
following the *Configure* section.
8992

@@ -106,7 +109,7 @@ Bug Tracker
106109
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
107110
In case of trouble, please check there if your issue has already been reported.
108111
If you spotted it first, help us to smash it by providing a detailed and welcomed
109-
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_filter_header_button%0Aversion:%2015.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:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
110113

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

@@ -138,6 +141,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
138141
mission is to support the collaborative development of Odoo features and
139142
promote its widespread use.
140143

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

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

web_filter_header_button/__manifest__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
33
{
44
"name": "Filter Button",
5-
"version": "15.0.1.1.1",
5+
"version": "18.0.1.0.0",
66
"summary": "Show selected filters as buttons in the control panel",
77
"author": "Tecnativa, Odoo Community Association (OCA)",
88
"license": "AGPL-3",
@@ -14,7 +14,6 @@
1414
"demo/ir_module_module_view.xml",
1515
],
1616
"assets": {
17-
"web.assets_backend": ["web_filter_header_button/static/src/**/*.js"],
18-
"web.assets_qweb": ["web_filter_header_button/static/src/**/*.xml"],
17+
"web.assets_backend": ["web_filter_header_button/static/src/**/*"],
1918
},
2019
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
In a search view with header filter buttons, you'll see a filter icon (funnel). Use it
2+
to unfold the filters.
3+
14
There's a demo implementation in `Apps` and you can play around following the *Configure*
25
section.

web_filter_header_button/static/description/index.html

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88

99
/*
1010
:Author: David Goodger (goodger@python.org)
11-
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
11+
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
1212
:Copyright: This stylesheet has been placed in the public domain.
1313
1414
Default cascading style sheet for the HTML output of Docutils.
15+
Despite the name, some widely supported CSS2 features are used.
1516
1617
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
1718
customize this style sheet.
@@ -274,7 +275,7 @@
274275
margin-left: 2em ;
275276
margin-right: 2em }
276277

277-
pre.code .ln { color: grey; } /* line numbers */
278+
pre.code .ln { color: gray; } /* line numbers */
278279
pre.code, code { background-color: #eeeeee }
279280
pre.code .comment, code .comment { color: #5C6576 }
280281
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -300,7 +301,7 @@
300301
span.pre {
301302
white-space: pre }
302303

303-
span.problematic {
304+
span.problematic, pre.problematic {
304305
color: red }
305306

306307
span.section-subtitle {
@@ -368,7 +369,7 @@ <h1 class="title">Filter Button</h1>
368369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
369370
!! source digest: sha256:c2b64cc19b28ee8850599360a44f1ba6ad28db0bc8574f041a845a5ca9529af1
370371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
371-
<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/15.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-15-0/web-15-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=15.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/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>
372373
<p>This module allows to add some selected filters as buttons in the header
373374
control panel.</p>
374375
<p><strong>Table of contents</strong></p>
@@ -424,6 +425,8 @@ <h1><a class="toc-backref" href="#toc-entry-2">Configuration</a></h1>
424425
</div>
425426
<div class="section" id="usage">
426427
<h1><a class="toc-backref" href="#toc-entry-3">Usage</a></h1>
428+
<p>In a search view with header filter buttons, you’ll see a filter icon
429+
(funnel). Use it to unfold the filters.</p>
427430
<p>There’s a demo implementation in <tt class="docutils literal">Apps</tt> and you can play around
428431
following the <em>Configure</em> section.</p>
429432
</div>
@@ -446,7 +449,7 @@ <h1><a class="toc-backref" href="#toc-entry-5">Bug Tracker</a></h1>
446449
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
447450
In case of trouble, please check there if your issue has already been reported.
448451
If you spotted it first, help us to smash it by providing a detailed and welcomed
449-
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_filter_header_button%0Aversion:%2015.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:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
450453
<p>Do not contact contributors directly about support or help with technical issues.</p>
451454
</div>
452455
<div class="section" id="credits">
@@ -469,11 +472,13 @@ <h2><a class="toc-backref" href="#toc-entry-8">Contributors</a></h2>
469472
<div class="section" id="maintainers">
470473
<h2><a class="toc-backref" href="#toc-entry-9">Maintainers</a></h2>
471474
<p>This module is maintained by the OCA.</p>
472-
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
475+
<a class="reference external image-reference" href="https://odoo-community.org">
476+
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
477+
</a>
473478
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
474479
mission is to support the collaborative development of Odoo features and
475480
promote its widespread use.</p>
476-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/15.0/web_filter_header_button">OCA/web</a> project on GitHub.</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>
477482
<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>
478483
</div>
479484
</div>

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

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2-
<templates>
3-
<t t-inherit="web.Legacy.ControlPanel" t-inherit-mode="extension" owl="1">
4-
<xpath expr="//div[hasclass('o_cp_bottom')]" position="after">
5-
<t t-if="env.view and env.view.type !== 'form'">
6-
<FilterButton />
2+
<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>
721
</t>
822
</xpath>
23+
24+
<xpath expr="//button[@t-on-click='onClickShowEmbedded']" position="after">
25+
<button
26+
t-if="state.headerButtonFilters?.length"
27+
class="btn btn-secondary"
28+
t-att-class="{active: state.showButtonFilters}"
29+
t-on-click="onClickShowshowButtonFilters"
30+
>
31+
<i class="fa fa-filter" />
32+
</button>
33+
</xpath>
934
</t>
1035
</templates>

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

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import {ControlPanel} from "@web/search/control_panel/control_panel";
2+
import {FilterButton} from "../filter_button/filter_button.esm";
3+
import {browser} from "@web/core/browser/browser";
4+
import {patch} from "@web/core/utils/patch";
5+
import {useState} from "@odoo/owl";
6+
import {user} from "@web/core/user";
7+
8+
patch(ControlPanel, {
9+
components: {...ControlPanel.components, FilterButton},
10+
});
11+
12+
patch(ControlPanel.prototype, {
13+
setup() {
14+
super.setup(...arguments);
15+
this.buttonFiltersVisibilityKey = `visibleHeaderButtons${this.env.config.actionId}+${user.userId}`;
16+
this.state = useState({
17+
...this.state,
18+
headerButtonFilters: this.env.searchModel?.headerButtonFilters,
19+
showButtonFilters:
20+
this.env.searchModel?.headerButtonFilters.length > 0 &&
21+
Boolean(this.env.config.actionId) &&
22+
Boolean(
23+
JSON.parse(
24+
browser.localStorage.getItem(this.buttonFiltersVisibilityKey)
25+
)
26+
),
27+
});
28+
},
29+
onClickShowshowButtonFilters() {
30+
if (this.state.showButtonFilters) {
31+
browser.localStorage.removeItem(this.buttonFiltersVisibilityKey);
32+
} else {
33+
browser.localStorage.setItem(this.buttonFiltersVisibilityKey, true);
34+
}
35+
this.state.showButtonFilters = !this.state.showButtonFilters;
36+
},
37+
});

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

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
1-
/** @odoo-module **/
2-
const {Component} = owl;
1+
import {Component} from "@odoo/owl";
32

43
export class FilterButton extends Component {
4+
static template = "filter_button.FilterButton";
5+
static props = {
6+
filters: {type: Object, optional: false},
7+
};
58
setup() {
69
this.model = this.env.searchModel;
710
}
8-
/**
9-
* Filter flagged filters to be shown in the control panel.
10-
*
11-
* @param {Array} filters
12-
* @returns {Array}
13-
*/
14-
shownFilters(filters) {
15-
return filters.filter((filter) => {
16-
return filter.context && filter.context.shown_in_panel;
17-
});
18-
}
1911
/**
2012
* Return custom properties depending on the filter properties
2113
*
@@ -40,14 +32,14 @@ export class FilterButton extends Component {
4032
* Clear filters
4133
*/
4234
onClickReset() {
43-
this.model.dispatch("clearQuery");
35+
this.model.clearQuery();
4436
}
4537
/**
4638
* Set / unset filter
4739
* @param {Object} filter
4840
*/
4941
onToggleFilter(filter) {
50-
this.model.dispatch("toggleFilter", filter.id);
42+
// This.model.dispatch("toggleSearchItem", filter.id);
43+
this.model.toggleSearchItem(filter.id);
5144
}
5245
}
53-
FilterButton.template = "filter_button.FilterButton";

web_filter_header_button/static/src/filter_button/filter_button.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<templates>
3-
<t t-name="filter_button.FilterButton" owl="1">
4-
<t t-set="filters" t-value="shownFilters(model.get('filters'))" />
3+
<t t-name="filter_button.FilterButton">
4+
<t t-set="filters" t-value="this.props.filters" />
55
<div t-if="filters" class="o_cp_bottom_filter_buttons">
6-
<div class="btn-group">
6+
<div class="btn-group" role="group">
77
<button
8-
t-if="filters &amp;&amp; filters.length"
8+
t-if="filters and filters.length"
99
t-attf-class="btn btn-outline-primary"
10-
t-on-click.stop="onClickReset()"
10+
t-on-click.stop="this.onClickReset"
1111
>
1212
<i class="fa fa-times" />
1313
</button>
@@ -22,8 +22,8 @@
2222
t-value="options.name !== undefined ? options.name : filter.description"
2323
/>
2424
<button
25-
t-attf-class="btn {{filter.isActive ? `btn-${color}` : `btn-outline-${color}`}}"
26-
t-on-click.stop="onToggleFilter(filter)"
25+
t-attf-class="btn ms-0 border-start-0 {{filter.isActive ? `btn-${color}` : `btn-outline-${color}`}}"
26+
t-on-click.stop="() => this.onToggleFilter(filter)"
2727
t-att-data-hotkey="options.hotkey"
2828
>
2929
<i

0 commit comments

Comments
 (0)