diff --git a/addons/sale/static/src/js/product_catalog/kanban_view.js b/addons/sale/static/src/js/product_catalog/kanban_view.js index 8756f7bb4f7..b4856a325ee 100644 --- a/addons/sale/static/src/js/product_catalog/kanban_view.js +++ b/addons/sale/static/src/js/product_catalog/kanban_view.js @@ -6,7 +6,7 @@ import { registry } from "@web/core/registry"; import { ProductCatalogKanbanController } from "./kanban_controller"; import { ProductCatalogKanbanModel } from "./kanban_model"; import { ProductCatalogKanbanRenderer } from "./kanban_renderer"; -import { ProductCatalogSearchPanel} from "./search_panel"; +import { ProductCatalogSearchPanel} from "./search/search_panel"; export const productCatalogKanbanView = { diff --git a/addons/sale/static/src/js/product_catalog/search/search_panel.js b/addons/sale/static/src/js/product_catalog/search/search_panel.js new file mode 100644 index 00000000000..70b43c3366d --- /dev/null +++ b/addons/sale/static/src/js/product_catalog/search/search_panel.js @@ -0,0 +1,56 @@ +/** @odoo-module **/ + +import { SearchPanel } from "@web/search/search_panel/search_panel"; +import { useState } from "@odoo/owl"; + + +export class ProductCatalogSearchPanel extends SearchPanel { + setup() { + super.setup(); + + this.state = useState({ + ...this.state, + sectionOfAttributes: {}, + }); + } + + updateActiveValues() { + super.updateActiveValues(); + this.state.sectionOfAttributes = this.buildSection(); + } + + buildSection() { + const values = this.env.searchModel.filters[0].values; + let sections = new Map(); + + values.forEach(element => { + const name = element.display_name; + const id = element.id; + const count = element.__count; + + if (sections.has(name)) { + let currentAttr = sections.get(name); + currentAttr.get('ids').push(id); + currentAttr.set('count', currentAttr.get('count') + count); + } else { + let newAttr = new Map(); + newAttr.set('ids', [id]); + newAttr.set('count', count); + sections.set(name, newAttr); + } + }); + + return sections; + } + + toggleSectionFilterValue(filterId, attrIds, { currentTarget }) { + attrIds.forEach(id => { + this.toggleFilterValue(filterId, id, { currentTarget }); + }) + } +} + +ProductCatalogSearchPanel.subTemplates = { + ...SearchPanel.subTemplates, + filtersGroup: "sale.ProductCatalogSearchPanel.FiltersGroup", +} diff --git a/addons/sale/static/src/js/product_catalog/search/search_panel.xml b/addons/sale/static/src/js/product_catalog/search/search_panel.xml new file mode 100644 index 00000000000..840a6b6c4c5 --- /dev/null +++ b/addons/sale/static/src/js/product_catalog/search/search_panel.xml @@ -0,0 +1,28 @@ + + + + +
  • +
  • + + +
    + + +
    +
  • + +
    +
    diff --git a/addons/sale/views/product_product_views.xml b/addons/sale/views/product_product_views.xml index 14743520d40..ba4aeef046a 100644 --- a/addons/sale/views/product_product_views.xml +++ b/addons/sale/views/product_product_views.xml @@ -37,6 +37,7 @@ class="d-flex flex-column"/>