Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/mixins/HomeMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ const HomeMixin = {
}
},
/* Returns true if there is more than 1 sub-result visible during searching */
checkIfResults() {
if (!this.sections) return false;
checkIfResults(sections) {
if (!sections) return false;
else {
let itemsFound = true;
this.sections.forEach((section) => {
sections.forEach((section) => {
if (section.widgets && section.widgets.length > 0) itemsFound = false;
if (this.filterTiles(section.items, this.searchValue).length > 0) itemsFound = false;
if (section.filteredItems.length > 0) itemsFound = false;
});
return itemsFound;
}
Expand Down
19 changes: 11 additions & 8 deletions src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,29 @@
+ (singleSectionView ? 'single-section-view ' : '')
+ (this.colCount ? `col-count-${this.colCount} ` : '')"
>
<template v-for="(section, index) in filteredTiles">
<template v-for="(section, index) in filteredSections">
<Section
:key="index"
:index="index"
:title="section.name"
:icon="section.icon || undefined"
:displayData="getDisplayData(section)"
:groupId="`${pageId}-section-${index}`"
:items="filterTiles(section.items, searchValue)"
:items="section.filteredItems"
:widgets="section.widgets"
:searchTerm="searchValue"
:itemSize="itemSizeBound"
@itemClicked="finishedSearching()"
@change-modal-visibility="updateModalVisibility"
:isWide="!!singleSectionView || layoutOrientation === 'horizontal'"
:class="
(searchValue && filterTiles(section.items, searchValue).length === 0) ? 'no-results' : ''"
:class="(searchValue && section.filteredItems.length === 0) ? 'no-results' : ''"
/>
</template>
<!-- Show add new section button, in edit mode -->
<AddNewSection v-if="isEditMode && !singleSectionView" />
</div>
<!-- Show message when there's no data to show -->
<div v-if="checkIfResults() && !isEditMode" class="no-data">
<div v-if="checkIfResults(filteredSections) && !isEditMode" class="no-data">
{{searchValue ? $t('home.no-results') : $t('home.no-data')}}
</div>
<!-- Show banner at bottom of screen, for Saving config changes -->
Expand Down Expand Up @@ -100,10 +99,14 @@ export default {
if (colCount > 8) colCount = 8;
return colCount;
},
/* Return all sections, that match users search term */
filteredTiles() {
/* Return sections with filtered items, that match users search term */
filteredSections() {
const sections = this.singleSectionView || this.sections;
return sections.filter((section) => this.filterTiles(section.items, this.searchValue));
return sections.map((_section) => {
const section = _section;
section.filteredItems = this.filterTiles(section.items, this.searchValue);
return section;
});
},
/* Updates layout (when button clicked), and saves in local storage */
layoutOrientation() {
Expand Down