MOBILE-3281 search: Show clear button on all glossaries

main
Pau Ferrer Ocaña 2020-02-27 11:49:44 +01:00
parent 4f25af2618
commit 8f12c84b93
4 changed files with 15 additions and 3 deletions

View File

@ -32,7 +32,7 @@
<ion-icon name="warning"></ion-icon> {{ 'core.hasdatatosync' | translate:{$a: moduleName} }}
</ion-card>
<core-search-box *ngIf="isSearch" (onSubmit)="search($event)" [placeholder]="'addon.mod_glossary.searchquery' | translate" [autoFocus]="true" [lengthCheck]="2" [showClear]="false" searchArea="AddonModGlossary-{{module.id}}"></core-search-box>
<core-search-box *ngIf="isSearch" (onSubmit)="search($event)" [placeholder]="'addon.mod_glossary.searchquery' | translate" [autoFocus]="true" [lengthCheck]="2" (onClear)="toggleSearch($event)" searchArea="AddonModGlossary-{{module.id}}"></core-search-box>
<core-loading [hideUntil]="loaded" class="core-loading-center">

View File

@ -4,7 +4,7 @@
</ion-navbar>
</ion-header>
<ion-content>
<core-search-box (onSubmit)="search($event)" [placeholder]="'core.courses.search' | translate" [searchLabel]="'core.courses.search' | translate" autoFocus="true" showClear="false" searchArea="CoreCoursesSearch"></core-search-box>
<core-search-box (onSubmit)="search($event)" (onClear)="clearSearch($event)" [placeholder]="'core.courses.search' | translate" [searchLabel]="'core.courses.search' | translate" autoFocus="true" searchArea="CoreCoursesSearch"></core-search-box>
<div *ngIf="courses">
<ion-item-divider>{{ 'core.courses.totalcoursesearchresults' | translate:{$a: total} }}</ion-item-divider>

View File

@ -52,6 +52,18 @@ export class CoreCoursesSearchPage {
});
}
/**
* Clear search box.
*
* @param e The event object.
*/
clearSearch(e: Event): void {
this.currentSearch = '';
this.courses = undefined;
this.page = 0;
this.total = 0;
}
/**
* Load more results.
*

View File

@ -117,7 +117,7 @@ export class CoreSearchBoxComponent implements OnInit, OnDestroy {
*/
protected async saveSearchToHistory(text: string): Promise<void> {
try {
await this.searchHistoryProvider.insertOrUpdateSearchText(this.searchArea, text);
await this.searchHistoryProvider.insertOrUpdateSearchText(this.searchArea, text.toLowerCase());
} finally {
this.loadHistory();
}