Merge pull request #2292 from crazyserver/MOBILE-3281

MOBILE-3281 search: Show clear button on all glossaries
main
Juan Leyva 2020-02-27 11:51:42 +01:00 committed by GitHub
commit 29779f0c4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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-icon name="warning"></ion-icon> {{ 'core.hasdatatosync' | translate:{$a: moduleName} }}
</ion-card> </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"> <core-loading [hideUntil]="loaded" class="core-loading-center">

View File

@ -4,7 +4,7 @@
</ion-navbar> </ion-navbar>
</ion-header> </ion-header>
<ion-content> <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"> <div *ngIf="courses">
<ion-item-divider>{{ 'core.courses.totalcoursesearchresults' | translate:{$a: total} }}</ion-item-divider> <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. * Load more results.
* *

View File

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