From 600f00ea5e85a2ecad19b666131cea9d718f995f Mon Sep 17 00:00:00 2001 From: shumit taher Date: Tue, 5 Aug 2025 09:22:36 +0000 Subject: [PATCH] working category filter on widgets --- src/mixins/HomeMixin.js | 3 +-- src/utils/Search.js | 8 +++++++- src/views/Home.vue | 4 +++- user-data/conf.yml | 5 +++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/mixins/HomeMixin.js b/src/mixins/HomeMixin.js index 4da17474..636b1a63 100644 --- a/src/mixins/HomeMixin.js +++ b/src/mixins/HomeMixin.js @@ -105,9 +105,8 @@ const HomeMixin = { const visibleTiles = allTiles.filter((tile) => checkItemVisibility(tile)); return searchTiles(visibleTiles, this.searchValue); }, - filterWidgets(allWidgets) { - return searchWidgets(allWidgets); + return searchWidgets(allWidgets, this.searchValue); }, /* Checks if any sections or items use icons from a given CDN */ diff --git a/src/utils/Search.js b/src/utils/Search.js index 53a76417..c600e372 100644 --- a/src/utils/Search.js +++ b/src/utils/Search.js @@ -53,7 +53,13 @@ export const searchTiles = (allTiles, searchTerm) => { export const searchWidgets = (allWidgets, searchTerm) => { if (!searchTerm) return allWidgets; - return allWidgets; + if (!allWidgets) return []; + return allWidgets.filter((tile) => { + const { + options, + } = tile; + return filterHelper(options.category, searchTerm); + }); }; /* From a list of search bangs, return the URL associated with it */ diff --git a/src/views/Home.vue b/src/views/Home.vue index e2577258..79817d0b 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -35,7 +35,9 @@ @itemClicked="finishedSearching()" @change-modal-visibility="updateModalVisibility" :isWide="!!singleSectionView || layoutOrientation === 'horizontal'" - :class="(searchValue && section.filteredItems.length === 0) ? 'no-results' : ''" + :class="(searchValue && + section.filteredItems.length === 0 && + (!section.widgets || section.widgets.length === 0)) ? 'no-results' : ''" /> diff --git a/user-data/conf.yml b/user-data/conf.yml index ebab119e..0aa432f1 100644 --- a/user-data/conf.yml +++ b/user-data/conf.yml @@ -66,11 +66,12 @@ sections: timeZone: Pacific/Auckland format: en-NZ hideDate: false - label: "Test Label" + label: Test Label - type: clock options: timeZone: Pacific/Auckland format: en-NZ hideDate: false - label: "Test Label 2" + label: Test Label 2 + category: timer