MOBILE-3833 my: Move search to empty box on my overview

main
Pau Ferrer Ocaña 2022-03-31 16:53:24 +02:00
parent 6d13fdf6a7
commit 2ce808dfab
4 changed files with 16 additions and 15 deletions

View File

@ -70,6 +70,11 @@
<core-empty-box *ngIf="filteredCourses.length == 0" image="assets/img/icons/courses.svg" <core-empty-box *ngIf="filteredCourses.length == 0" image="assets/img/icons/courses.svg"
[message]="'addon.block_myoverview.nocourses' | translate"> [message]="'addon.block_myoverview.nocourses' | translate">
<ion-button *ngIf="searchEnabled" (click)="openSearch()" fill="outline">
<ion-icon name="fas-search" slot="start" aria-hidden="true">
</ion-icon>
{{'core.courses.searchcourses' | translate}}
</ion-button>
</core-empty-box> </core-empty-box>
<!-- List of courses. --> <!-- List of courses. -->

View File

@ -30,6 +30,7 @@ import { AddonCourseCompletion } from '@addons/coursecompletion/services/coursec
import { AddonBlockMyOverviewFilterOptionsComponent } from '../filteroptions/filteroptions'; import { AddonBlockMyOverviewFilterOptionsComponent } from '../filteroptions/filteroptions';
import { IonSearchbar } from '@ionic/angular'; import { IonSearchbar } from '@ionic/angular';
import moment from 'moment'; import moment from 'moment';
import { CoreNavigator } from '@services/navigator';
const FILTER_PRIORITY: AddonBlockMyOverviewTimeFilters[] = ['all', 'inprogress', 'future', 'past']; const FILTER_PRIORITY: AddonBlockMyOverviewTimeFilters[] = ['all', 'inprogress', 'future', 'past'];
@ -88,6 +89,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
textFilter = ''; textFilter = '';
hasCourses = false; hasCourses = false;
searchEnabled = false;
protected currentSite!: CoreSite; protected currentSite!: CoreSite;
protected allCourses: CoreEnrolledCourseDataWithOptions[] = []; protected allCourses: CoreEnrolledCourseDataWithOptions[] = [];
@ -110,12 +112,13 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
// Refresh the enabled flags if enabled. // Refresh the enabled flags if enabled.
this.downloadCourseEnabled = !CoreCourses.isDownloadCourseDisabledInSite(); this.downloadCourseEnabled = !CoreCourses.isDownloadCourseDisabledInSite();
this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite(); this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite();
this.searchEnabled = !CoreCourses.isSearchCoursesDisabledInSite();
// Refresh the enabled flags if site is updated. // Refresh the enabled flags if site is updated.
this.updateSiteObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, () => { this.updateSiteObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, () => {
this.downloadCourseEnabled = !CoreCourses.isDownloadCourseDisabledInSite(); this.downloadCourseEnabled = !CoreCourses.isDownloadCourseDisabledInSite();
this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite(); this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite();
this.searchEnabled = !CoreCourses.isSearchCoursesDisabledInSite();
}, CoreSites.getCurrentSiteId()); }, CoreSites.getCurrentSiteId());
this.coursesObserver = CoreEvents.on( this.coursesObserver = CoreEvents.on(
@ -676,6 +679,13 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
this.filterCourses(); this.filterCourses();
} }
/**
* Go to search courses.
*/
async openSearch(): Promise<void> {
CoreNavigator.navigateToSitePath('/list', { params : { mode: 'search' } });
}
/** /**
* @inheritdoc * @inheritdoc
*/ */

View File

@ -11,9 +11,6 @@
</h1> </h1>
</ion-title> </ion-title>
<ion-buttons slot="end"> <ion-buttons slot="end">
<ion-button *ngIf="searchEnabled" (click)="openSearch()" [attr.aria-label]="'core.courses.searchcourses' | translate">
<ion-icon name="fas-search" slot="icon-only" aria-hidden="true"></ion-icon>
</ion-button>
<core-user-menu-button></core-user-menu-button> <core-user-menu-button></core-user-menu-button>
</ion-buttons> </ion-buttons>
</ion-toolbar> </ion-toolbar>

View File

@ -19,7 +19,6 @@ import { CoreCourseBlock } from '@features/course/services/course';
import { CoreCoursesDashboard, CoreCoursesDashboardProvider } from '@features/courses/services/dashboard'; import { CoreCoursesDashboard, CoreCoursesDashboardProvider } from '@features/courses/services/dashboard';
import { CoreMainMenuDeepLinkManager } from '@features/mainmenu/classes/deep-link-manager'; import { CoreMainMenuDeepLinkManager } from '@features/mainmenu/classes/deep-link-manager';
import { IonRefresher } from '@ionic/angular'; import { IonRefresher } from '@ionic/angular';
import { CoreNavigator } from '@services/navigator';
import { CoreSites } from '@services/sites'; import { CoreSites } from '@services/sites';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreEventObserver, CoreEvents } from '@singletons/events';
@ -38,7 +37,6 @@ export class CoreCoursesMyCoursesPage implements OnInit, OnDestroy {
@ViewChild(CoreBlockComponent) block!: CoreBlockComponent; @ViewChild(CoreBlockComponent) block!: CoreBlockComponent;
siteName = ''; siteName = '';
searchEnabled = false;
downloadCoursesEnabled = false; downloadCoursesEnabled = false;
userId: number; userId: number;
loadedBlock?: Partial<CoreCourseBlock>; loadedBlock?: Partial<CoreCourseBlock>;
@ -50,7 +48,6 @@ export class CoreCoursesMyCoursesPage implements OnInit, OnDestroy {
constructor() { constructor() {
// Refresh the enabled flags if site is updated. // Refresh the enabled flags if site is updated.
this.updateSiteObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, () => { this.updateSiteObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, () => {
this.searchEnabled = !CoreCourses.isSearchCoursesDisabledInSite();
this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite(); this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite();
this.loadSiteName(); this.loadSiteName();
@ -63,7 +60,6 @@ export class CoreCoursesMyCoursesPage implements OnInit, OnDestroy {
* @inheritdoc * @inheritdoc
*/ */
ngOnInit(): void { ngOnInit(): void {
this.searchEnabled = !CoreCourses.isSearchCoursesDisabledInSite();
this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite(); this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite();
const deepLinkManager = new CoreMainMenuDeepLinkManager(); const deepLinkManager = new CoreMainMenuDeepLinkManager();
@ -122,13 +118,6 @@ export class CoreCoursesMyCoursesPage implements OnInit, OnDestroy {
}; };
} }
/**
* Go to search courses.
*/
async openSearch(): Promise<void> {
CoreNavigator.navigateToSitePath('/list', { params : { mode: 'search' } });
}
/** /**
* Refresh the data. * Refresh the data.
* *