forked from EVOgeek/Vmeda.Online
		
	MOBILE-4270 wiki: Fix subwiki ordering
This commit is contained in:
		
							parent
							
								
									4ab33b8784
								
							
						
					
					
						commit
						2bfc9c73cc
					
				| @ -885,7 +885,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp | |||||||
|         await Promise.all(this.loadedSubwikis.map(async (subwiki) => { |         await Promise.all(this.loadedSubwikis.map(async (subwiki) => { | ||||||
|             let groupLabel = ''; |             let groupLabel = ''; | ||||||
| 
 | 
 | ||||||
|             if (subwiki.groupid == 0 && subwiki.userid == 0) { |             if (subwiki.groupid === 0 && subwiki.userid === 0) { | ||||||
|                 // Add 'All participants' subwiki if needed at the start.
 |                 // Add 'All participants' subwiki if needed at the start.
 | ||||||
|                 if (!allParticipants) { |                 if (!allParticipants) { | ||||||
|                     subwikiList.unshift({ |                     subwikiList.unshift({ | ||||||
| @ -899,7 +899,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp | |||||||
|                     allParticipants = true; |                     allParticipants = true; | ||||||
|                 } |                 } | ||||||
|             } else { |             } else { | ||||||
|                 if (subwiki.groupid != 0 && userGroups.length > 0) { |                 if (subwiki.groupid !== 0 && userGroups.length > 0) { | ||||||
|                     // Get groupLabel if it has groupId.
 |                     // Get groupLabel if it has groupId.
 | ||||||
|                     const group = userGroups.find(group => group.id == subwiki.groupid); |                     const group = userGroups.find(group => group.id == subwiki.groupid); | ||||||
|                     groupLabel = group?.name ?? ''; |                     groupLabel = group?.name ?? ''; | ||||||
| @ -907,7 +907,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp | |||||||
|                     groupLabel = Translate.instant('addon.mod_wiki.notingroup'); |                     groupLabel = Translate.instant('addon.mod_wiki.notingroup'); | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 if (subwiki.userid != 0) { |                 if (subwiki.userid !== 0) { | ||||||
|                     if (!multiLevelList && subwiki.groupid != 0) { |                     if (!multiLevelList && subwiki.groupid != 0) { | ||||||
|                         multiLevelList = true; |                         multiLevelList = true; | ||||||
|                     } |                     } | ||||||
| @ -953,8 +953,6 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp | |||||||
|         showMyGroupsLabel: boolean, |         showMyGroupsLabel: boolean, | ||||||
|         multiLevelList: boolean, |         multiLevelList: boolean, | ||||||
|     ): void { |     ): void { | ||||||
|         subwikiList.sort((a, b) => a.groupid - b.groupid); |  | ||||||
| 
 |  | ||||||
|         this.groupWiki = showMyGroupsLabel; |         this.groupWiki = showMyGroupsLabel; | ||||||
|         this.subwikiData.count = subwikiList.length; |         this.subwikiData.count = subwikiList.length; | ||||||
| 
 | 
 | ||||||
| @ -1036,34 +1034,39 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp | |||||||
|                 grouping.subwikis.push(subwiki); |                 grouping.subwikis.push(subwiki); | ||||||
|             }); |             }); | ||||||
|         } else if (showMyGroupsLabel) { |         } else if (showMyGroupsLabel) { | ||||||
|             const noGrouping: AddonModWikiSubwikiListGrouping = { label: '', subwikis: [] }; |             const noGroupSubwikis: AddonModWikiSubwikiListSubwiki[] = []; | ||||||
|             const myGroupsGrouping: AddonModWikiSubwikiListGrouping = { label: Translate.instant('core.mygroups'), subwikis: [] }; |             const myGroupsSubwikis: AddonModWikiSubwikiListSubwiki[] = []; | ||||||
|             const otherGroupsGrouping: AddonModWikiSubwikiListGrouping = { |             const otherGroupsSubwikis: AddonModWikiSubwikiListSubwiki[] = []; | ||||||
|                 label: Translate.instant('core.othergroups'), |  | ||||||
|                 subwikis: [], |  | ||||||
|             }; |  | ||||||
| 
 | 
 | ||||||
|             // As we loop over each subwiki, add it to the current group
 |             // As we loop over each subwiki, add it to the current group.
 | ||||||
|             subwikiList.forEach((subwiki) => { |             subwikiList.forEach((subwiki) => { | ||||||
|                 // Add the subwiki to the currently active grouping.
 |                 // Add the subwiki to the currently active grouping.
 | ||||||
|                 if (subwiki.canedit === undefined) { |                 if (subwiki.groupid === 0 && subwiki.userid === 0) { | ||||||
|                     noGrouping.subwikis.push(subwiki); |                     // All participants
 | ||||||
|  |                     noGroupSubwikis.push(subwiki); | ||||||
|                 } else if (subwiki.canedit) { |                 } else if (subwiki.canedit) { | ||||||
|                     myGroupsGrouping.subwikis.push(subwiki); |                     myGroupsSubwikis.push(subwiki); | ||||||
|                 } else { |                 } else { | ||||||
|                     otherGroupsGrouping.subwikis.push(subwiki); |                     otherGroupsSubwikis.push(subwiki); | ||||||
|                 } |                 } | ||||||
|             }); |             }); | ||||||
| 
 | 
 | ||||||
|             // Add each grouping to the subwikis
 |             if (myGroupsSubwikis.length > 0 && otherGroupsSubwikis.length > 0) { | ||||||
|             if (noGrouping.subwikis.length > 0) { |                 // Add each grouping to the subwikis.
 | ||||||
|                 this.subwikiData.subwikis.push(noGrouping); |                 if (noGroupSubwikis.length > 0) { | ||||||
|  |                     this.subwikiData.subwikis.push({ label: '', subwikis: noGroupSubwikis }); | ||||||
|                 } |                 } | ||||||
|             if (myGroupsGrouping.subwikis.length > 0) { | 
 | ||||||
|                 this.subwikiData.subwikis.push(myGroupsGrouping); |                 if (myGroupsSubwikis.length > 0) { | ||||||
|  |                     this.subwikiData.subwikis.push({ label: Translate.instant('core.mygroups'), subwikis: myGroupsSubwikis }); | ||||||
|                 } |                 } | ||||||
|             if (otherGroupsGrouping.subwikis.length > 0) { | 
 | ||||||
|                 this.subwikiData.subwikis.push(otherGroupsGrouping); |                 if (otherGroupsSubwikis.length > 0) { | ||||||
|  |                     this.subwikiData.subwikis.push({ label: Translate.instant('core.othergroups'), subwikis: otherGroupsSubwikis }); | ||||||
|  |                 } | ||||||
|  |             } else { | ||||||
|  |                 // Mix it again since it does not have groups and other groups.
 | ||||||
|  |                 this.subwikiData.subwikis.push({ label: '', subwikis: subwikiList }); | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|             this.subwikiData.subwikis.push({ label: '', subwikis: subwikiList }); |             this.subwikiData.subwikis.push({ label: '', subwikis: subwikiList }); | ||||||
|  | |||||||
| @ -38,10 +38,10 @@ export class AddonModWikiSubwikiPickerComponent { | |||||||
|     isSubwikiSelected(subwiki: AddonModWikiSubwiki): boolean { |     isSubwikiSelected(subwiki: AddonModWikiSubwiki): boolean { | ||||||
| 
 | 
 | ||||||
|         if (subwiki.id > 0 && this.currentSubwiki.id > 0) { |         if (subwiki.id > 0 && this.currentSubwiki.id > 0) { | ||||||
|             return subwiki.id == this.currentSubwiki.id; |             return subwiki.id === this.currentSubwiki.id; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         return subwiki.userid == this.currentSubwiki.userid && subwiki.groupid == this.currentSubwiki.groupid; |         return subwiki.userid === this.currentSubwiki.userid && subwiki.groupid === this.currentSubwiki.groupid; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user