MOBILE-4081 database: Fix app restarted when resetting search

main
Dani Palou 2022-12-14 08:17:07 +01:00
parent 578c40f3d1
commit 4f630a5f72
2 changed files with 9 additions and 4 deletions

View File

@ -62,14 +62,14 @@
<!-- Reset search. -->
<ng-container *ngIf="search.searching && !isEmpty">
<ion-item (click)="searchReset()" button detail="false" *ngIf="!foundRecordsTranslationData">
<ion-item (click)="searchReset($event)" button detail="false" *ngIf="!foundRecordsTranslationData">
<ion-label color="info">
{{ 'addon.mod_data.resetsettings' | translate}}
</ion-label>
</ion-item>
<ion-card class="core-success-card" *ngIf="foundRecordsTranslationData">
<ion-item (click)="searchReset()" button detail="false">
<ion-item (click)="searchReset($event)" button detail="false">
<ion-label>
<p [innerHTML]="'addon.mod_data.foundrecords' | translate:{$a: foundRecordsTranslationData}"></p>
</ion-label>
@ -105,7 +105,7 @@
<core-empty-box *ngIf="isEmpty && search.searching" icon="fas-database" [message]="'addon.mod_data.nomatch' | translate"
class="core-empty-box-clickable">
<button class="as-link" (click)="searchReset()">{{ 'addon.mod_data.resetsettings' | translate}}</button>
<button class="as-link" (click)="searchReset($event)">{{ 'addon.mod_data.resetsettings' | translate}}</button>
</core-empty-box>
</core-loading>

View File

@ -426,8 +426,13 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
/**
* Reset all search filters and closes the modal.
*
* @param ev Event.
*/
searchReset(): void {
searchReset(ev: Event): void {
ev.preventDefault();
ev.stopPropagation();
this.search.sortBy = '0';
this.search.sortDirection = 'DESC';
this.search.text = '';