Skip to content

Commit

Permalink
Merge pull request #65 from OCA/15.0
Browse files Browse the repository at this point in the history
Fork Sync Branch 15.0
  • Loading branch information
btl-bot authored Jun 6, 2024
2 parents d43137b + ad9e5f2 commit f2b65e3
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ addon | version | maintainers | summary
[web_domain_field](web_domain_field/) | 15.0.1.0.1 | | Use computed field as domain
[web_drop_target](web_drop_target/) | 15.0.1.0.2 | | Allows to drag files into Odoo
[web_environment_ribbon](web_environment_ribbon/) | 15.0.1.0.0 | | Web Environment Ribbon
[web_filter_header_button](web_filter_header_button/) | 15.0.1.0.0 | | Show selected filters as buttons in the control panel
[web_filter_header_button](web_filter_header_button/) | 15.0.1.1.0 | | Show selected filters as buttons in the control panel
[web_group_expand](web_group_expand/) | 15.0.1.0.0 | | Group Expand Buttons
[web_hide_user_menu_item](web_hide_user_menu_item/) | 15.0.1.0.0 | | Web Hide User Menu Item
[web_ir_actions_act_multi](web_ir_actions_act_multi/) | 15.0.1.0.0 | | Enables triggering of more than one action on ActionManager
Expand Down
6 changes: 5 additions & 1 deletion web_filter_header_button/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Filter Button
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9da8b47931a94c1b0a4f43e7a450e88a87095f7d1d6aa5fdf36fc59efbb75fe4
!! source digest: sha256:474ef01827c48e1ba05df2c8301f718da67a2251d4ae3282ab86a3537dd7d3f2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down Expand Up @@ -95,6 +95,10 @@ Known issues / Roadmap
limiting in some cases. Keep it in mind or use
``base_view_inheritance_extension`` if you want to use proper context
inheritance.
- Another nice to have would be to be able to hide the filters in the
filter list to be able to show them just in the header, although
there's not a straigh forward way to do it and it could lead to side
effects.

Bug Tracker
===========
Expand Down
2 changes: 1 addition & 1 deletion web_filter_header_button/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Filter Button",
"version": "15.0.1.0.0",
"version": "15.0.1.1.0",
"summary": "Show selected filters as buttons in the control panel",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
Expand Down
5 changes: 5 additions & 0 deletions web_filter_header_button/demo/ir_module_module_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
name="context"
>{'shown_in_panel': {'icon': 'fa-toggle-off', 'hotkey': 'u'}}</attribute>
</filter>
<filter name="state" position="attributes">
<attribute
name="context"
>{'group_by':'state', 'shown_in_panel': {'icon': 'fa-th-list', 'hotkey': 's'}}</attribute>
</filter>
</field>
</record>
</odoo>
3 changes: 3 additions & 0 deletions web_filter_header_button/readme/ROADMAP.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
- Group filters by kind
- As we use the `context` attribute, the inheritance could be limiting in some cases. Keep it in mind or use `base_view_inheritance_extension` if you want to use proper context inheritance.
- Another nice to have would be to be able to hide the filters in the filter list to be
able to show them just in the header, although there's not a straigh forward way to
do it and it could lead to side effects.
7 changes: 5 additions & 2 deletions web_filter_header_button/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down Expand Up @@ -367,7 +366,7 @@ <h1 class="title">Filter Button</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9da8b47931a94c1b0a4f43e7a450e88a87095f7d1d6aa5fdf36fc59efbb75fe4
!! source digest: sha256:474ef01827c48e1ba05df2c8301f718da67a2251d4ae3282ab86a3537dd7d3f2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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>
<p>This module allows to add some selected filters as buttons in the header
Expand Down Expand Up @@ -436,6 +435,10 @@ <h1><a class="toc-backref" href="#toc-entry-4">Known issues / Roadmap</a></h1>
limiting in some cases. Keep it in mind or use
<tt class="docutils literal">base_view_inheritance_extension</tt> if you want to use proper context
inheritance.</li>
<li>Another nice to have would be to be able to hide the filters in the
filter list to be able to show them just in the header, although
there’s not a straigh forward way to do it and it could lead to side
effects.</li>
</ul>
</div>
<div class="section" id="bug-tracker">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-inherit="web.Legacy.ControlPanel" t-inherit-mode="extension" owl="1">
<xpath expr="//div[hasclass('o_cp_buttons')]" position="after">
<xpath expr="//div[hasclass('o_cp_bottom')]" position="after">
<t t-if="env.view.type !== 'form'">
<FilterButton />
</t>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,17 @@ patch(
}
return preFilter;
},
/**
* Allow groupBy filters to show up as buttons
* @override
* @param {Object} filter
* @param {Object} attrs
*/
_extractAttributes(filter, attrs) {
this._super(...arguments);
if (filter.type === "groupBy" && attrs.context.shown_in_panel) {
filter.context = attrs.context;
}
},
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export class FilterButton extends Component {
favorite: {
color: "warning",
},
groupBy: {
color: "info",
},
};
return mapping[filter.type];
}
Expand Down
56 changes: 29 additions & 27 deletions web_filter_header_button/static/src/filter_button/filter_button.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,38 @@

<t t-name="filter_button.FilterButton" owl="1">
<t t-set="filters" t-value="shownFilters(model.get('filters'))" />
<div class="btn-group" t-if="filters">
<button
t-if="filters &amp;&amp; filters.length"
t-attf-class="btn btn-outline-primary"
t-on-click.stop="onClickReset()"
>
<i class="fa fa-times" />
</button>
<!-- Directly get the model filters so we can react to changes -->
<t t-foreach="filters" t-as="filter" t-key="filter.id">
<t t-set="options" t-value="filter.context.shown_in_panel" />
<t t-set="filter_mapping" t-value="mapFilterType(filter)" />
<t t-set="color" t-value="filter_mapping.color || 'primary'" />
<!-- We can set an empty string on the optional name to show only the icon -->
<t
t-set="name"
t-value="options.name !== undefined ? options.name : filter.description"
/>
<div t-if="filters" class="o_cp_bottom_filter_buttons">
<div class="btn-group">
<button
t-attf-class="btn {{filter.isActive ? `btn-${color}` : `btn-outline-${color}`}}"
t-on-click.stop="onToggleFilter(filter)"
t-att-data-hotkey="options.hotkey"
t-if="filters &amp;&amp; filters.length"
t-attf-class="btn btn-outline-primary"
t-on-click.stop="onClickReset()"
>
<i
t-if="options.icon"
t-attf-class="fa {{options.icon}} {{name !== '' ? 'mr-1' : ''}}"
/>
<t t-esc="name" />
<i class="fa fa-times" />
</button>
</t>
<!-- Directly get the model filters so we can react to changes -->
<t t-foreach="filters" t-as="filter" t-key="filter.id">
<t t-set="options" t-value="filter.context.shown_in_panel" />
<t t-set="filter_mapping" t-value="mapFilterType(filter)" />
<t t-set="color" t-value="filter_mapping.color || 'primary'" />
<!-- We can set an empty string on the optional name to show only the icon -->
<t
t-set="name"
t-value="options.name !== undefined ? options.name : filter.description"
/>
<button
t-attf-class="btn {{filter.isActive ? `btn-${color}` : `btn-outline-${color}`}}"
t-on-click.stop="onToggleFilter(filter)"
t-att-data-hotkey="options.hotkey"
>
<i
t-if="options.icon"
t-attf-class="fa {{options.icon}} {{name !== '' ? 'mr-1' : ''}}"
/>
<t t-esc="name" />
</button>
</t>
</div>
</div>
</t>
</templates>

0 comments on commit f2b65e3

Please sign in to comment.