From 4b0775b5ea53bc97155cd73f68f31ebc731dd0ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Wed, 28 Oct 2026 11:36:40 +0100 Subject: [PATCH] feat(ProductFilterViewModel): enhance URL parameter handling Improve loading of search, ranges, tags, and brands from URL. Trigger loading state and refresh list when filters are applied. --- .../ProductsViewer/ProductFilterViewModel.ts | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/resources/ts/fo/components/ProductsViewer/ProductFilterViewModel.ts b/resources/ts/fo/components/ProductsViewer/ProductFilterViewModel.ts index 8f7053d6..a3d5239f 100644 --- a/resources/ts/fo/components/ProductsViewer/ProductFilterViewModel.ts +++ b/resources/ts/fo/components/ProductsViewer/ProductFilterViewModel.ts @@ -143,28 +143,32 @@ export class ProductFilterViewModel { const urlParams = new URL(document.location.href).searchParams; const urlSearch = urlParams.get("search")?.trim() ?? ""; - if (urlSearch) { - this.store.setSearchValue(urlSearch); - } - this.searchValue.value = this.store.currentSearchValue; - const urlRanges = urlParams .getAll("ranges[]") .map(v => Number.parseInt(v.trim(), 10)) .filter(v => !Number.isNaN(v)) as RangeId[]; - this.store.setActiveRanges(urlRanges); - const urlTags = urlParams .getAll("tags[]") .map(v => Number.parseInt(v.trim(), 10)) .filter(v => !Number.isNaN(v)) as TagId[]; - this.store.setActiveTags(urlTags); - const urlBrands = urlParams .getAll("brands[]") .map(v => v.trim()) .filter(v => v.length) as BrandValue[]; + + if (urlSearch.length) { + this.store.setSearchValue(urlSearch); + } + this.store.setActiveRanges(urlRanges); + this.store.setActiveTags(urlTags); this.store.setActiveBrands(urlBrands); + this.searchValue.value = this.store.currentSearchValue; + + if (urlSearch.length || urlRanges.length || urlTags.length || urlBrands.length) { + this.store.setLoading(true); + this.refreshList(); + } + watch(this.searchValue, (newValue) => { const cleanText = String(newValue || "");