[FIX] website_sale: hide expand category if children are hidden

Before this commit, in collapse category list, if the children of a category
are currently hidden due a search not including them, the parent category would
still be displayed as having expandable children, but clicking on the expand
button would have no effect.

After this commit, the expand button will not be shown if the children are not
shown.

PR: #34249

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
This commit is contained in:
Sébastien Theys
2019-07-17 15:55:29 +00:00
parent 5f87def828
commit 1a49db046f
+5 -6
View File
@@ -370,15 +370,14 @@
<template id="option_collapse_categories_recursive" name="Collapse Category Recursive">
<li class="nav-item">
<i t-if="c.child_id" t-attf-class="text-primary fa #{'fa-chevron-down' if c.id in category.parents_and_self.ids else 'fa-chevron-right'}"
<t t-set="children" t-value="not search and c.child_id or c.child_id.filtered(lambda c: c.id in search_categories_ids)"/>
<i t-if="children" t-attf-class="text-primary fa #{'fa-chevron-down' if c.id in category.parents_and_self.ids else 'fa-chevron-right'}"
t-attf-title="#{'Unfold' if c.id in category.parents_and_self.ids else 'Fold'}"
t-attf-aria-label="#{'Unfold' if c.id in category.parents_and_self.ids else 'Fold'}" role="img"/>
<a t-att-href="keep('/shop/category/' + slug(c), category=0)" t-attf-class="nav-link #{'active' if c.id == category.id else ''}" t-field="c.name"></a>
<ul t-if="c.child_id" class="nav nav-pills flex-column nav-hierarchy" t-att-style="'display:block;' if c.id in category.parents_and_self.ids else 'display:none;'">
<t t-foreach="c.child_id" t-as="c">
<t t-if="not search or c.id in search_categories_ids">
<t t-call="website_sale.option_collapse_categories_recursive"/>
</t>
<ul t-if="children" class="nav nav-pills flex-column nav-hierarchy" t-att-style="'display:block;' if c.id in category.parents_and_self.ids else 'display:none;'">
<t t-foreach="children" t-as="c">
<t t-call="website_sale.option_collapse_categories_recursive"/>
</t>
</ul>
</li>