forked from EVOgeek/Vmeda.Online
		
	Merge pull request #1599 from crazyserver/MOBILE-2709
MOBILE-2709 courses: Filter courses using shortname
This commit is contained in:
		
						commit
						6516b283e2
					
				| @ -175,12 +175,20 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem | ||||
|         const newValue = event.target.value && event.target.value.trim().toLowerCase(); | ||||
|         if (!newValue || !this.courses[this.selectedFilter]) { | ||||
|             this.filteredCourses = this.courses[this.selectedFilter]; | ||||
|         } else { | ||||
|             // Use displayname if avalaible, or fullname if not.
 | ||||
|             if (this.courses[this.selectedFilter].length > 0 && | ||||
|                     typeof this.courses[this.selectedFilter][0].displayname != 'undefined') { | ||||
|                 this.filteredCourses = this.courses[this.selectedFilter].filter((course) => { | ||||
|                     return course.displayname.toLowerCase().indexOf(newValue) > -1; | ||||
|                 }); | ||||
|             } else { | ||||
|                 this.filteredCourses = this.courses[this.selectedFilter].filter((course) => { | ||||
|                     return course.fullname.toLowerCase().indexOf(newValue) > -1; | ||||
|                 }); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Initialize the prefetch icon for selected courses. | ||||
|  | ||||
| @ -172,12 +172,19 @@ export class CoreCoursesMyCoursesPage implements OnDestroy { | ||||
|         const newValue = event.target.value && event.target.value.trim().toLowerCase(); | ||||
|         if (!newValue || !this.courses) { | ||||
|             this.filteredCourses = this.courses; | ||||
|         } else { | ||||
|             // Use displayname if avalaible, or fullname if not.
 | ||||
|             if (this.courses.length > 0 && typeof this.courses[0].displayname != 'undefined') { | ||||
|                 this.filteredCourses = this.courses.filter((course) => { | ||||
|                     return course.displayname.toLowerCase().indexOf(newValue) > -1; | ||||
|                 }); | ||||
|             } else { | ||||
|                 this.filteredCourses = this.courses.filter((course) => { | ||||
|                     return course.fullname.toLowerCase().indexOf(newValue) > -1; | ||||
|                 }); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Prefetch all the courses. | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user