MOBILE-3213 badges: Don't show alignment if broken
This commit is contained in:
		
							parent
							
								
									4209dd1393
								
							
						
					
					
						commit
						268e45ef09
					
				@ -156,7 +156,7 @@
 | 
				
			|||||||
                <h2>{{ 'addon.badges.relatedbages' | translate}}</h2>
 | 
					                <h2>{{ 'addon.badges.relatedbages' | translate}}</h2>
 | 
				
			||||||
            </ion-item-divider>
 | 
					            </ion-item-divider>
 | 
				
			||||||
            <ion-item text-wrap *ngFor="let relatedBadge of badge.relatedbadges">
 | 
					            <ion-item text-wrap *ngFor="let relatedBadge of badge.relatedbadges">
 | 
				
			||||||
                <h2><{{ relatedBadge.name }}</h2>
 | 
					                <h2>{{ relatedBadge.name }}</h2>
 | 
				
			||||||
            </ion-item>
 | 
					            </ion-item>
 | 
				
			||||||
            <ion-item text-wrap *ngIf="badge.relatedbadges.length == 0">
 | 
					            <ion-item text-wrap *ngIf="badge.relatedbadges.length == 0">
 | 
				
			||||||
                <h2>{{ 'addon.badges.norelated' | translate}}</h2>
 | 
					                <h2>{{ 'addon.badges.norelated' | translate}}</h2>
 | 
				
			||||||
 | 
				
			|||||||
@ -91,6 +91,12 @@ export class AddonBadgesProvider {
 | 
				
			|||||||
                    // In 3.7, competencies was renamed to alignment. Rename the property in 3.6 too.
 | 
					                    // In 3.7, competencies was renamed to alignment. Rename the property in 3.6 too.
 | 
				
			||||||
                    response.badges.forEach((badge) => {
 | 
					                    response.badges.forEach((badge) => {
 | 
				
			||||||
                        badge.alignment = badge.alignment || badge.competencies;
 | 
					                        badge.alignment = badge.alignment || badge.competencies;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        // Check that the alignment is valid, they were broken in 3.7.
 | 
				
			||||||
 | 
					                        if (badge.alignment && badge.alignment[0] && typeof badge.alignment[0].targetname == 'undefined') {
 | 
				
			||||||
 | 
					                            // If any badge lacks targetname it means they are affected by the Moodle bug, don't display them.
 | 
				
			||||||
 | 
					                            delete badge.alignment;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
                    });
 | 
					                    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    return response.badges;
 | 
					                    return response.badges;
 | 
				
			||||||
@ -175,20 +181,20 @@ export type AddonBadgesUserBadge = {
 | 
				
			|||||||
    alignment?: { // @since 3.7. Calculated by the app for 3.6 sites. Badge alignments.
 | 
					    alignment?: { // @since 3.7. Calculated by the app for 3.6 sites. Badge alignments.
 | 
				
			||||||
        id?: number; // Alignment id.
 | 
					        id?: number; // Alignment id.
 | 
				
			||||||
        badgeid?: number; // Badge id.
 | 
					        badgeid?: number; // Badge id.
 | 
				
			||||||
        targetName?: string; // Target name.
 | 
					        targetname?: string; // Target name.
 | 
				
			||||||
        targetUrl?: string; // Target URL.
 | 
					        targeturl?: string; // Target URL.
 | 
				
			||||||
        targetDescription?: string; // Target description.
 | 
					        targetdescription?: string; // Target description.
 | 
				
			||||||
        targetFramework?: string; // Target framework.
 | 
					        targetframework?: string; // Target framework.
 | 
				
			||||||
        targetCode?: string; // Target code.
 | 
					        targetcode?: string; // Target code.
 | 
				
			||||||
    }[];
 | 
					    }[];
 | 
				
			||||||
    competencies?: { // @deprecated from 3.7. @since 3.6. In 3.7 it was renamed to alignment.
 | 
					    competencies?: { // @deprecated from 3.7. @since 3.6. In 3.7 it was renamed to alignment.
 | 
				
			||||||
        id?: number; // Alignment id.
 | 
					        id?: number; // Alignment id.
 | 
				
			||||||
        badgeid?: number; // Badge id.
 | 
					        badgeid?: number; // Badge id.
 | 
				
			||||||
        targetName?: string; // Target name.
 | 
					        targetname?: string; // Target name.
 | 
				
			||||||
        targetUrl?: string; // Target URL.
 | 
					        targeturl?: string; // Target URL.
 | 
				
			||||||
        targetDescription?: string; // Target description.
 | 
					        targetdescription?: string; // Target description.
 | 
				
			||||||
        targetFramework?: string; // Target framework.
 | 
					        targetframework?: string; // Target framework.
 | 
				
			||||||
        targetCode?: string; // Target code.
 | 
					        targetcode?: string; // Target code.
 | 
				
			||||||
    }[];
 | 
					    }[];
 | 
				
			||||||
    relatedbadges?: { // @since 3.6. Related badges.
 | 
					    relatedbadges?: { // @since 3.6. Related badges.
 | 
				
			||||||
        id: number; // Badge id.
 | 
					        id: number; // Badge id.
 | 
				
			||||||
 | 
				
			|||||||
@ -5,7 +5,7 @@
 | 
				
			|||||||
    <core-loading [hideUntil]="loaded" class="core-loading-center">
 | 
					    <core-loading [hideUntil]="loaded" class="core-loading-center">
 | 
				
			||||||
        <ion-item *ngIf="showMyEntriesToggle">
 | 
					        <ion-item *ngIf="showMyEntriesToggle">
 | 
				
			||||||
            <ion-label>{{ 'addon.blog.showonlyyourentries' | translate }}</ion-label>
 | 
					            <ion-label>{{ 'addon.blog.showonlyyourentries' | translate }}</ion-label>
 | 
				
			||||||
            <ion-toggle [(ngModel)]="onlyMyEntries" (ionChange)="onlyMyEntriesToggleChanged(onlyMyEntries)">></ion-toggle>
 | 
					            <ion-toggle [(ngModel)]="onlyMyEntries" (ionChange)="onlyMyEntriesToggleChanged(onlyMyEntries)"></ion-toggle>
 | 
				
			||||||
        </ion-item>
 | 
					        </ion-item>
 | 
				
			||||||
        <core-empty-box *ngIf="entries && entries.length == 0" icon="fa-newspaper-o" [message]="'addon.blog.noentriesyet' | translate"></core-empty-box>
 | 
					        <core-empty-box *ngIf="entries && entries.length == 0" icon="fa-newspaper-o" [message]="'addon.blog.noentriesyet' | translate"></core-empty-box>
 | 
				
			||||||
        <ng-container *ngFor="let entry of entries">
 | 
					        <ng-container *ngFor="let entry of entries">
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user