[ACA-1489] Handling cleared searches and searches with no results (#460)

* skip search action when no searchTerm

* hide search filters when no results
This commit is contained in:
Suzana Dirla 2018-06-26 15:11:33 +03:00 committed by Denys Vuika
parent dd08d1b3a8
commit e600d437e3
4 changed files with 15 additions and 4 deletions

View File

@ -112,7 +112,9 @@ export class SearchInputComponent implements OnInit {
*/ */
onSearchSubmit(event: KeyboardEvent) { onSearchSubmit(event: KeyboardEvent) {
const searchTerm = (event.target as HTMLInputElement).value; const searchTerm = (event.target as HTMLInputElement).value;
this.store.dispatch(new SearchByTermAction(searchTerm)); if (searchTerm) {
this.store.dispatch(new SearchByTermAction(searchTerm));
}
} }
onSearchChange(searchTerm: string) { onSearchChange(searchTerm: string) {
@ -130,7 +132,9 @@ export class SearchInputComponent implements OnInit {
} }
this.navigationTimer = setTimeout(() => { this.navigationTimer = setTimeout(() => {
this.store.dispatch(new SearchByTermAction(searchTerm)); if (searchTerm) {
this.store.dispatch(new SearchByTermAction(searchTerm));
}
this.hasOneChange = false; this.hasOneChange = false;
}, 1000); }, 1000);
} }

View File

@ -66,7 +66,9 @@
<div class="inner-layout__content"> <div class="inner-layout__content">
<div class="inner-layout__panel"> <div class="inner-layout__panel">
<div class="adf-search-results"> <div class="adf-search-results">
<adf-search-filter #searchFilter></adf-search-filter> <adf-search-filter
#searchFilter
[ngClass]="{ 'adf-search-filter--hidden': !data?.list.entries.length }"></adf-search-filter>
<div class="adf-search-results__content"> <div class="adf-search-results__content">
<div class="adf-search-results__content-header content" *ngIf="data?.list.entries.length"> <div class="adf-search-results__content-header content" *ngIf="data?.list.entries.length">

View File

@ -34,6 +34,10 @@
padding: 5px; padding: 5px;
height: 100%; height: 100%;
overflow: scroll; overflow: scroll;
&--hidden {
display: none;
}
} }
.text--bold { .text--bold {

View File

@ -87,7 +87,8 @@ export class SearchComponent extends PageComponent implements OnInit {
this.queryBuilder.userQuery = query; this.queryBuilder.userQuery = query;
this.queryBuilder.update(); this.queryBuilder.update();
} else { } else {
this.onSearchResultLoaded( {list: { pagination: { totalItems: 0 }, entries: []}} ); this.queryBuilder.userQuery = null;
this.queryBuilder.executed.next( {list: { pagination: { totalItems: 0 }, entries: []}} );
} }
}); });
} }