diff --git a/addons/pos_self_order/static/src/app/pages/product_list_page/product_list_page.js b/addons/pos_self_order/static/src/app/pages/product_list_page/product_list_page.js index cd552030229..7d1acc0dba3 100644 --- a/addons/pos_self_order/static/src/app/pages/product_list_page/product_list_page.js +++ b/addons/pos_self_order/static/src/app/pages/product_list_page/product_list_page.js @@ -1,12 +1,13 @@ /** @odoo-module */ -import { Component, useEffect, useRef } from "@odoo/owl"; +import { Component, useEffect, useRef, useState } from "@odoo/owl"; import { useSelfOrder } from "@pos_self_order/app/self_order_service"; import { ProductCard } from "@pos_self_order/app/components/product_card/product_card"; import { CancelPopup } from "@pos_self_order/app/components/cancel_popup/cancel_popup"; import { useService, useChildRef } from "@web/core/utils/hooks"; import { OrderWidget } from "@pos_self_order/app/components/order_widget/order_widget"; import { _t } from "@web/core/l10n/translation"; +import { fuzzyLookup } from "@web/core/utils/search"; export class ProductListPage extends Component { static template = "pos_self_order.ProductListPage"; @@ -19,7 +20,10 @@ export class ProductListPage extends Component { this.productsList = useRef("productsList"); this.categoryList = useRef("categoryList"); this.currentProductCard = useChildRef(); - + this.state = useState({ + search: false, + searchInput: "", + }); this.categoryButton = Object.fromEntries( Array.from(this.selfOrder.categoryList).map((category) => { return [category.name, useRef(`category_${category.name}`)]; @@ -73,12 +77,32 @@ export class ProductListPage extends Component { ); } + get width() { + return window.innerWidth; + } + get productCategory() { const productByCat = this.selfOrder.productsGroupedByCategory; const currentCategory = this.selfOrder.currentCategory; return productByCat[currentCategory] ? productByCat[currentCategory] : []; } + focusSearch() { + this.state.search = !this.state.search; + + if (!this.state.search) { + this.state.searchInput = ""; + } + } + + getFilteredProducts(products) { + return fuzzyLookup( + this.state.searchInput, + products, + (product) => product.name + product.description_sale + ); + } + scrollTo(ref = null, { behavior = "smooth" } = {}) { this.productsList.el.scroll({ top: ref?.el ? ref.el.offsetTop - this.productsList.el.offsetTop : 0, diff --git a/addons/pos_self_order/static/src/app/pages/product_list_page/product_list_page.scss b/addons/pos_self_order/static/src/app/pages/product_list_page/product_list_page.scss index 36b2ae3e327..3e602640a84 100644 --- a/addons/pos_self_order/static/src/app/pages/product_list_page/product_list_page.scss +++ b/addons/pos_self_order/static/src/app/pages/product_list_page/product_list_page.scss @@ -1,18 +1,28 @@ -.category-list { +.navbar-container { height: 225px; overflow-y: hidden; - .category-item { - width: 150px; - height: 150px; - padding: 0px !important; + .category-list { + width: calc(100% - 50px); + overflow-y: hidden; + + .category-item { + width: 150px; + height: 150px; + padding: 0px !important; + } + + img { + object-fit: cover; + } } - img { - object-fit: cover; + .search-button { + width: 50px; } } + .product-list { overflow-y: scroll; margin-top: 225px; @@ -34,16 +44,18 @@ height: calc(100% - 60px); } - .category-list { + .navbar-container { height: 60px; overflow-y: hidden; - .category-item { - height: 40px; - } + .category-list { + .category-item { + height: 40px; + } - img { - display: none; + img { + display: none; + } } } -} \ No newline at end of file +} diff --git a/addons/pos_self_order/static/src/app/pages/product_list_page/product_list_page.xml b/addons/pos_self_order/static/src/app/pages/product_list_page/product_list_page.xml index b0ca742f103..882e464829c 100644 --- a/addons/pos_self_order/static/src/app/pages/product_list_page/product_list_page.xml +++ b/addons/pos_self_order/static/src/app/pages/product_list_page/product_list_page.xml @@ -3,23 +3,39 @@
- +
-

- + + +

+ +

No products found