working category filter on widgets

This commit is contained in:
shumit taher 2025-08-05 09:22:36 +00:00
parent 1a42d766f8
commit 600f00ea5e
4 changed files with 14 additions and 6 deletions

View file

@ -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 */

View file

@ -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 */

View file

@ -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' : ''"
/>
</template>
<!-- Show add new section button, in edit mode -->

View file

@ -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