mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
[ACA-1740] hide search filter when getting 0 results without any selected filters (#591)
This commit is contained in:
committed by
Denys Vuika
parent
d607618920
commit
a9c6d0f942
@@ -14,7 +14,7 @@
|
|||||||
<div class="adf-search-results">
|
<div class="adf-search-results">
|
||||||
<adf-search-filter
|
<adf-search-filter
|
||||||
#searchFilter
|
#searchFilter
|
||||||
[ngClass]="{ 'adf-search-filter--hidden': !searchedWord }"></adf-search-filter>
|
[ngClass]="{ 'adf-search-filter--hidden': hideSearchFilter() }"></adf-search-filter>
|
||||||
<div class="adf-search-results__content">
|
<div class="adf-search-results__content">
|
||||||
<mat-progress-bar
|
<mat-progress-bar
|
||||||
*ngIf="isLoading"
|
*ngIf="isLoading"
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||||
import { NodePaging, Pagination, MinimalNodeEntity } from 'alfresco-js-api';
|
import { NodePaging, Pagination, MinimalNodeEntity } from 'alfresco-js-api';
|
||||||
import { ActivatedRoute, Params } from '@angular/router';
|
import { ActivatedRoute, Params } from '@angular/router';
|
||||||
import { SearchQueryBuilderService, SearchComponent as AdfSearchComponent } from '@alfresco/adf-content-services';
|
import { SearchQueryBuilderService, SearchComponent as AdfSearchComponent, SearchFilterComponent } from '@alfresco/adf-content-services';
|
||||||
import { PageComponent } from '../../page.component';
|
import { PageComponent } from '../../page.component';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { AppStore } from '../../../store/states/app.state';
|
import { AppStore } from '../../../store/states/app.state';
|
||||||
@@ -45,10 +45,14 @@ export class SearchResultsComponent extends PageComponent implements OnInit {
|
|||||||
@ViewChild('search')
|
@ViewChild('search')
|
||||||
search: AdfSearchComponent;
|
search: AdfSearchComponent;
|
||||||
|
|
||||||
|
@ViewChild('searchFilter')
|
||||||
|
searchFilter: SearchFilterComponent;
|
||||||
|
|
||||||
searchedWord: string;
|
searchedWord: string;
|
||||||
queryParamName = 'q';
|
queryParamName = 'q';
|
||||||
data: NodePaging;
|
data: NodePaging;
|
||||||
totalResults = 0;
|
totalResults = 0;
|
||||||
|
hasSelectedFilters = false;
|
||||||
sorting = ['name', 'asc'];
|
sorting = ['name', 'asc'];
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
|
||||||
@@ -114,6 +118,7 @@ export class SearchResultsComponent extends PageComponent implements OnInit {
|
|||||||
onSearchResultLoaded(nodePaging: NodePaging) {
|
onSearchResultLoaded(nodePaging: NodePaging) {
|
||||||
this.data = nodePaging;
|
this.data = nodePaging;
|
||||||
this.totalResults = this.getNumberOfResults();
|
this.totalResults = this.getNumberOfResults();
|
||||||
|
this.hasSelectedFilters = this.isFiltered();
|
||||||
}
|
}
|
||||||
|
|
||||||
getNumberOfResults() {
|
getNumberOfResults() {
|
||||||
@@ -123,6 +128,18 @@ export class SearchResultsComponent extends PageComponent implements OnInit {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isFiltered(): boolean {
|
||||||
|
return this.searchFilter.selectedFacetQueries.length > 0
|
||||||
|
|| this.searchFilter.selectedBuckets.length > 0
|
||||||
|
|| this.hasCheckedCategories();
|
||||||
|
}
|
||||||
|
|
||||||
|
hasCheckedCategories() {
|
||||||
|
const checkedCategory = this.queryBuilder.categories
|
||||||
|
.find(category => !!this.queryBuilder.queryFragments[category.id]);
|
||||||
|
return !!checkedCategory;
|
||||||
|
}
|
||||||
|
|
||||||
onPaginationChanged(pagination: Pagination) {
|
onPaginationChanged(pagination: Pagination) {
|
||||||
this.queryBuilder.paging = {
|
this.queryBuilder.paging = {
|
||||||
maxItems: pagination.maxItems,
|
maxItems: pagination.maxItems,
|
||||||
@@ -156,4 +173,8 @@ export class SearchResultsComponent extends PageComponent implements OnInit {
|
|||||||
this.showPreview(node);
|
this.showPreview(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hideSearchFilter() {
|
||||||
|
return !this.totalResults && !this.hasSelectedFilters;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user