Merge pull request #3764 from NoelDeMartin/MOBILE-4362
MOBILE-4362 timeline: Fix empty searchesmain
commit
ad3245136e
|
@ -252,29 +252,32 @@ export class AddonBlockTimelineComponent implements OnInit, ICoreBlockComponent
|
||||||
const courseIds = courses.map(course => course.id);
|
const courseIds = courses.map(course => course.id);
|
||||||
const gracePeriod = await this.getCoursesGracePeriod();
|
const gracePeriod = await this.getCoursesGracePeriod();
|
||||||
const courseEvents = await AddonBlockTimeline.getActionEventsByCourses(courseIds, search ?? '');
|
const courseEvents = await AddonBlockTimeline.getActionEventsByCourses(courseIds, search ?? '');
|
||||||
|
const sectionObservables = courses
|
||||||
|
.filter(
|
||||||
|
course =>
|
||||||
|
!course.hidden &&
|
||||||
|
!CoreCoursesHelper.isPastCourse(course, gracePeriod.after) &&
|
||||||
|
!CoreCoursesHelper.isFutureCourse(course, gracePeriod.after, gracePeriod.before) &&
|
||||||
|
courseEvents[course.id].events.length > 0,
|
||||||
|
)
|
||||||
|
.map(course => {
|
||||||
|
const section = new AddonBlockTimelineSection(
|
||||||
|
search,
|
||||||
|
overdue,
|
||||||
|
dateRange,
|
||||||
|
course,
|
||||||
|
courseEvents[course.id].events,
|
||||||
|
courseEvents[course.id].canLoadMore,
|
||||||
|
);
|
||||||
|
|
||||||
return combineLatest(
|
return section.data$.pipe(map(({ events }) => events.length > 0 ? section : null));
|
||||||
courses
|
});
|
||||||
.filter(
|
|
||||||
course =>
|
|
||||||
!course.hidden &&
|
|
||||||
!CoreCoursesHelper.isPastCourse(course, gracePeriod.after) &&
|
|
||||||
!CoreCoursesHelper.isFutureCourse(course, gracePeriod.after, gracePeriod.before) &&
|
|
||||||
courseEvents[course.id].events.length > 0,
|
|
||||||
)
|
|
||||||
.map(course => {
|
|
||||||
const section = new AddonBlockTimelineSection(
|
|
||||||
search,
|
|
||||||
overdue,
|
|
||||||
dateRange,
|
|
||||||
course,
|
|
||||||
courseEvents[course.id].events,
|
|
||||||
courseEvents[course.id].canLoadMore,
|
|
||||||
);
|
|
||||||
|
|
||||||
return section.data$.pipe(map(({ events }) => events.length > 0 ? section : null));
|
if (sectionObservables.length === 0) {
|
||||||
}),
|
return of([]);
|
||||||
).pipe(
|
}
|
||||||
|
|
||||||
|
return combineLatest(sectionObservables).pipe(
|
||||||
map(sections => sections.filter(
|
map(sections => sections.filter(
|
||||||
(section: AddonBlockTimelineSection | null): section is AddonBlockTimelineSection => !!section,
|
(section: AddonBlockTimelineSection | null): section is AddonBlockTimelineSection => !!section,
|
||||||
)),
|
)),
|
||||||
|
|
|
@ -91,3 +91,27 @@ Feature: Timeline block.
|
||||||
| assign | C1 | newassign | New Assignment | ##tomorrow## |
|
| assign | C1 | newassign | New Assignment | ##tomorrow## |
|
||||||
And I pull to refresh in the app
|
And I pull to refresh in the app
|
||||||
Then I should find "New Assignment" in the app
|
Then I should find "New Assignment" in the app
|
||||||
|
|
||||||
|
@lms_from4.0
|
||||||
|
Scenario: Search
|
||||||
|
Given I entered the app as "student1"
|
||||||
|
Then I should find "Assignment 00" within "Timeline" "ion-card" in the app
|
||||||
|
|
||||||
|
When I set the field "Search by activity type or name" to "thisdoesntexist" in the app
|
||||||
|
And I press "Search" in the app
|
||||||
|
Then I should find "No activities require action" in the app
|
||||||
|
But I should not find "Assignment 00" within "Timeline" "ion-card" in the app
|
||||||
|
|
||||||
|
When I press "Clear search" in the app
|
||||||
|
Then I should find "Assignment 00" within "Timeline" "ion-card" in the app
|
||||||
|
|
||||||
|
When I press "Sort by" in the app
|
||||||
|
And I press "Sort by courses" in the app
|
||||||
|
Then I should find "Course 1" in the app
|
||||||
|
And I should find "Assignment 02" within "Timeline" "ion-card" in the app
|
||||||
|
|
||||||
|
When I set the field "Search by activity type or name" to "thisdoesntexist" in the app
|
||||||
|
And I press "Search" in the app
|
||||||
|
Then I should find "No activities require action" in the app
|
||||||
|
But I should not find "Course 1" in the app
|
||||||
|
And I should not find "Assignment 02" within "Timeline" "ion-card" in the app
|
||||||
|
|
Loading…
Reference in New Issue