forked from EVOgeek/Vmeda.Online
		
	Merge pull request #2384 from crazyserver/kietchan-MOBILE-3249_integration
Kietchan mobile 3249 integration
This commit is contained in:
		
						commit
						4f9adba63e
					
				| @ -49,6 +49,7 @@ | ||||
|   "addon.block_myoverview.nocourses": "block_myoverview", | ||||
|   "addon.block_myoverview.past": "block_myoverview", | ||||
|   "addon.block_myoverview.pluginname": "block_myoverview", | ||||
|   "addon.block_myoverview.shortname": "block_myoverview", | ||||
|   "addon.block_myoverview.title": "block_myoverview", | ||||
|   "addon.block_newsitems.pluginname": "block_news_items", | ||||
|   "addon.block_onlineusers.pluginname": "block_online_users", | ||||
|  | ||||
| @ -11,7 +11,8 @@ | ||||
|     <core-context-menu item-end> | ||||
|         <core-context-menu-item *ngIf="loaded && showFilterSwitchButton()" [priority]="1000" [content]="'core.courses.filtermycourses' | translate" (action)="switchFilter()" iconAction="funnel" (onClosed)="switchFilterClosed()"></core-context-menu-item> | ||||
|         <core-context-menu-item *ngIf="loaded && showSortFilter" [priority]="900" content="{{('core.sortby' | translate) + ' ' + ('addon.block_myoverview.title' | translate)}}" (action)="switchSort('fullname')" [iconAction]="sort == 'fullname' ? 'radio-button-on' : 'radio-button-off'"></core-context-menu-item> | ||||
|         <core-context-menu-item *ngIf="loaded && showSortFilter" [priority]="800" content="{{('core.sortby' | translate) + ' ' + ('addon.block_myoverview.lastaccessed' | translate)}}" (action)="switchSort('lastaccess')" [iconAction]="sort == 'lastaccess' ? 'radio-button-on' : 'radio-button-off'"></core-context-menu-item> | ||||
|         <core-context-menu-item *ngIf="loaded && showSortFilter && showSortByShortName" [priority]="800" content="{{('core.sortby' | translate) + ' ' + ('addon.block_myoverview.shortname' | translate)}}" (action)="switchSort('shortname')" [iconAction]="sort == 'shortname' ? 'radio-button-on' : 'radio-button-off'"></core-context-menu-item> | ||||
|         <core-context-menu-item *ngIf="loaded && showSortFilter" [priority]="700" content="{{('core.sortby' | translate) + ' ' + ('addon.block_myoverview.lastaccessed' | translate)}}" (action)="switchSort('lastaccess')" [iconAction]="sort == 'lastaccess' ? 'radio-button-on' : 'radio-button-off'"></core-context-menu-item> | ||||
|     </core-context-menu> | ||||
| </ion-item-divider> | ||||
| <core-loading [hideUntil]="loaded" class="core-loading-center"> | ||||
|  | ||||
| @ -83,6 +83,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem | ||||
|     protected updateSiteObserver; | ||||
|     protected courseIds = []; | ||||
|     protected fetchContentDefaultError = 'Error getting my overview data.'; | ||||
|     protected showSortByShortName = false; | ||||
| 
 | ||||
|     constructor(injector: Injector, | ||||
|             protected coursesProvider: CoreCoursesProvider, | ||||
| @ -181,6 +182,18 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem | ||||
|         const showCategories = config && config.displaycategories && config.displaycategories.value == '1'; | ||||
| 
 | ||||
|         return this.coursesHelper.getUserCoursesWithOptions(this.sort, null, null, showCategories).then((courses) => { | ||||
|             // Check to show sort by short name only if the text is visible.
 | ||||
|             if (courses.length > 0) { | ||||
|                 const sampleCourse = courses[0]; | ||||
|                 this.showSortByShortName = sampleCourse.displayname && sampleCourse.shortname && | ||||
|                     sampleCourse.fullname != sampleCourse.displayname; | ||||
|             } | ||||
| 
 | ||||
|             // Rollback to sort by full name if user is sorting by short name then Moodle web change the config.
 | ||||
|             if (!this.showSortByShortName && this.sort === 'shortname') { | ||||
|                 this.switchSort('fullname'); | ||||
|             } | ||||
| 
 | ||||
|             this.courseIds = courses.map((course) => { | ||||
|                     return course.id; | ||||
|                 }); | ||||
| @ -395,7 +408,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem | ||||
|         this.courses.allincludinghidden = courses; | ||||
| 
 | ||||
|         if (this.showSortFilter) { | ||||
|                 if (this.sort == 'lastaccess') { | ||||
|             if (this.sort == 'lastaccess') { | ||||
|                 courses.sort((a, b) => { | ||||
|                     return b.lastaccess - a.lastaccess; | ||||
|                 }); | ||||
| @ -404,6 +417,14 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem | ||||
|                     const compareA = a.fullname.toLowerCase(), | ||||
|                         compareB = b.fullname.toLowerCase(); | ||||
| 
 | ||||
|                     return compareA.localeCompare(compareB); | ||||
|                 }); | ||||
|             } else if (this.sort == 'shortname') { | ||||
|                 courses.sort((a, b) => { | ||||
|                     const compareA = a.shortname.toLowerCase(), | ||||
|                         compareB = b.shortname.toLowerCase(); | ||||
|                     compareA.localeCompare(); | ||||
| 
 | ||||
|                     return compareA.localeCompare(compareB); | ||||
|                 }); | ||||
|             } | ||||
|  | ||||
| @ -10,5 +10,6 @@ | ||||
|     "nocourses": "No courses", | ||||
|     "past": "Past", | ||||
|     "pluginname": "Course overview", | ||||
|     "shortname": "Short name", | ||||
|     "title": "Course name" | ||||
| } | ||||
| } | ||||
|  | ||||
| @ -49,6 +49,7 @@ | ||||
|     "addon.block_myoverview.nocourses": "No courses", | ||||
|     "addon.block_myoverview.past": "Past", | ||||
|     "addon.block_myoverview.pluginname": "Course overview", | ||||
|     "addon.block_myoverview.shortname": "Short name", | ||||
|     "addon.block_myoverview.title": "Course name", | ||||
|     "addon.block_newsitems.pluginname": "Latest announcements", | ||||
|     "addon.block_onlineusers.pluginname": "Online users", | ||||
|  | ||||
| @ -212,6 +212,14 @@ export class CoreCoursesHelperProvider { | ||||
|                             return b.timemodified - a.timemodified; | ||||
|                         }); | ||||
|                         break; | ||||
|                     case 'shortname': | ||||
|                         courses.sort((a, b) => { | ||||
|                             const compareA = a.shortname.toLowerCase(), | ||||
|                                 compareB = b.shortname.toLowerCase(); | ||||
| 
 | ||||
|                             return compareA.localeCompare(compareB); | ||||
|                         }); | ||||
|                         break; | ||||
|                     default: | ||||
|                         // Sort not implemented. Do not sort.
 | ||||
|                 } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user