Merge pull request #3834 from NoelDeMartin/MOBILE-3371

MOBILE-3371 search: Improve course search
main
Dani Palou 2023-10-24 08:03:30 +02:00 committed by GitHub
commit fc53f986a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 10 deletions

View File

@ -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 } : {},
};
}

View File

@ -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 = {};

View File

@ -35,7 +35,7 @@
(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>

View File

@ -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>

View File

@ -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('', {});
@ -56,6 +57,7 @@ export class CoreSearchGlobalSearchPage implements OnInit, OnDestroy, AfterViewI
}
if (courseId) {
this.courseId = courseId;
this.resultsSource.setFilters({ courseIds: [courseId] });
}
@ -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()) {

View File

@ -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