MOBILE-3109 badges: Fix badge alignment renamed in WS

main
Dani Palou 2019-09-03 16:50:53 +02:00
parent b2497a1dd0
commit 5699c9b738
2 changed files with 21 additions and 7 deletions

View File

@ -172,14 +172,14 @@
</ion-item-group> </ion-item-group>
<!-- Competencies alignment --> <!-- Competencies alignment -->
<ion-item-group *ngIf="badge && badge.competencies"> <ion-item-group *ngIf="badge && badge.alignment">
<ion-item-divider> <ion-item-divider>
<h2>{{ 'addon.badges.alignment' | translate}}</h2> <h2>{{ 'addon.badges.alignment' | translate}}</h2>
</ion-item-divider> </ion-item-divider>
<a ion-item text-wrap *ngFor="let competency of badge.competencies" [href]="competency.targeturl" core-link auto-login="no"> <a ion-item text-wrap *ngFor="let alignment of badge.alignment" [href]="alignment.targeturl" core-link auto-login="no">
<h2><core-format-text [text]="competency.targetname"></core-format-text></h2> <h2><core-format-text [text]="alignment.targetname"></core-format-text></h2>
</a> </a>
<ion-item text-wrap *ngIf="badge.competencies.length == 0"> <ion-item text-wrap *ngIf="badge.alignment.length == 0">
<h2>{{ 'addon.badges.noalignment' | translate}}</h2> <h2>{{ 'addon.badges.noalignment' | translate}}</h2>
</ion-item> </ion-item>
</ion-item-group> </ion-item-group>

View File

@ -86,8 +86,13 @@ export class AddonBadgesProvider {
updateFrequency: CoreSite.FREQUENCY_RARELY updateFrequency: CoreSite.FREQUENCY_RARELY
}; };
return site.read('core_badges_get_user_badges', data, preSets).then((response) => { return site.read('core_badges_get_user_badges', data, preSets).then((response: AddonBadgesGetUserBadgesResult) => {
if (response && response.badges) { if (response && response.badges) {
// In 3.7, competencies was renamed to alignment. Rename the property in 3.6 too.
response.badges.forEach((badge) => {
badge.alignment = badge.alignment || badge.competencies;
});
return response.badges; return response.badges;
} else { } else {
return Promise.reject(null); return Promise.reject(null);
@ -167,7 +172,7 @@ export type AddonBadgesUserBadge = {
claimcomment: string; // Claim comment. claimcomment: string; // Claim comment.
dateissued: number; // Date issued. dateissued: number; // Date issued.
}; };
alignment: { // @since 3.6. 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.
@ -176,7 +181,16 @@ export type AddonBadgesUserBadge = {
targetFramework?: string; // Target framework. targetFramework?: string; // Target framework.
targetCode?: string; // Target code. targetCode?: string; // Target code.
}[]; }[];
relatedbadges: { // @since 3.6. Related badges. competencies?: { // @deprecated from 3.7. @since 3.6. In 3.7 it was renamed to alignment.
id?: number; // Alignment id.
badgeid?: number; // Badge id.
targetName?: string; // Target name.
targetUrl?: string; // Target URL.
targetDescription?: string; // Target description.
targetFramework?: string; // Target framework.
targetCode?: string; // Target code.
}[];
relatedbadges?: { // @since 3.6. Related badges.
id: number; // Badge id. id: number; // Badge id.
name: string; // Badge name. name: string; // Badge name.
version?: string; // Version. version?: string; // Version.