Skip to content

Commit

Permalink
MOBILE-3371 search: Improve course search
Browse files Browse the repository at this point in the history
  • Loading branch information
NoelDeMartin committed Oct 23, 2023
1 parent 1edc59f commit af00e8e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/addons/block/globalsearch/services/block-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ export class AddonBlockGlobalSearchHandlerService extends CoreBlockBaseHandler {
* @inheritdoc
*/
getDisplayData(block: CoreCourseBlock, contextLevel: string, instanceId: number): CoreBlockHandlerData | undefined {
const isCourseSearch = contextLevel === 'course';

return {
title: 'addon.block_globalsearch.pluginname',
title: isCourseSearch ? 'core.search' : 'addon.block_globalsearch.pluginname',
class: 'addon-block-globalsearch',
component: CoreBlockOnlyTitleComponent,
link: CORE_SEARCH_PAGE_NAME,
linkParams: contextLevel === 'course'
? { courseId: instanceId }
: {},
linkParams: isCourseSearch ? { courseId: instanceId } : {},
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class CoreSearchGlobalSearchFiltersComponent implements OnInit {
allCourses: boolean | null = true;
courses: Filter<CoreEnrolledCourseData>[] = [];

@Input() hideCourses?: boolean;
@Input() filters?: CoreSearchGlobalSearchFilters;

private newFilters: CoreSearchGlobalSearchFilters = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h1>{{ 'core.search.filterheader' | translate }}</h1>
(ionChange)="onSearchAreaCategoryInputChanged(searchAreaCategory)"></ion-checkbox>
</ion-item>
</ng-container>
<ng-container *ngIf="courses.length > 0">
<ng-container *ngIf="!hideCourses && courses.length > 0">
<core-spacer></core-spacer>
<ion-item class="ion-text-wrap help">
<ion-label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<ion-back-button [text]="'core.back' | translate"></ion-back-button>
</ion-buttons>
<ion-title>
<h1>{{ 'core.search.globalsearch' | translate }}</h1>
<h1 *ngIf="courseId">{{ 'core.search' | translate }}</h1>
<h1 *ngIf="!courseId">{{ 'core.search.globalsearch' | translate }}</h1>
</ion-title>
<ion-buttons slot="end">
<core-user-menu-button></core-user-menu-button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { CoreSearchBoxComponent } from '@features/search/components/search-box/s
})
export class CoreSearchGlobalSearchPage implements OnInit, OnDestroy, AfterViewInit {

courseId: number | null = null;
loadMoreError: string | null = null;
searchBanner: string | null = null;
resultsSource = new CoreSearchGlobalSearchResultsSource('', {});
Expand All @@ -56,6 +57,7 @@ export class CoreSearchGlobalSearchPage implements OnInit, OnDestroy, AfterViewI
}

if (courseId) {
this.courseId = courseId;
this.resultsSource.setFilters({ courseIds: [courseId] });
}

Expand Down Expand Up @@ -139,7 +141,10 @@ export class CoreSearchGlobalSearchPage implements OnInit, OnDestroy, AfterViewI

await CoreDomUtils.openSideModal<CoreSearchGlobalSearchFilters>({
component: CoreSearchGlobalSearchFiltersComponent,
componentProps: { filters: this.resultsSource.getFilters() },
componentProps: {
hideCourses: !!this.courseId,
filters: this.resultsSource.getFilters(),
},
});

if (!this.resultsSource.hasEmptyQuery() && this.resultsSource.isDirty()) {
Expand Down
6 changes: 3 additions & 3 deletions src/core/features/search/tests/behat/global-search.feature
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ Feature: Test Global Search
| globalsearch | Course | C1 |
And I entered the course "Course 1" as "student1" in the app
When I press "Open block drawer" in the app
And I press "Global search" in the app
And I press "Search" in the app
Then I should find "What are you searching for?" in the app

When I press "Filter" in the app
Then "C1" should be selected in the app
But "C2" should not be selected in the app
Then I should find "Filter results by" in the app
But I should not find "Search in" in the app

0 comments on commit af00e8e

Please sign in to comment.