From 5699c9b73896667ab4ee8b37cc8d1f5517531faa Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 3 Sep 2019 16:50:53 +0200 Subject: [PATCH] MOBILE-3109 badges: Fix badge alignment renamed in WS --- .../pages/issued-badge/issued-badge.html | 8 ++++---- src/addon/badges/providers/badges.ts | 20 ++++++++++++++++--- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/addon/badges/pages/issued-badge/issued-badge.html b/src/addon/badges/pages/issued-badge/issued-badge.html index 565993bec..0dcc1e810 100644 --- a/src/addon/badges/pages/issued-badge/issued-badge.html +++ b/src/addon/badges/pages/issued-badge/issued-badge.html @@ -172,14 +172,14 @@ - +

{{ 'addon.badges.alignment' | translate}}

- -

+
+

- +

{{ 'addon.badges.noalignment' | translate}}

diff --git a/src/addon/badges/providers/badges.ts b/src/addon/badges/providers/badges.ts index 6cf3a29bf..1bfe00eb6 100644 --- a/src/addon/badges/providers/badges.ts +++ b/src/addon/badges/providers/badges.ts @@ -86,8 +86,13 @@ export class AddonBadgesProvider { 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) { + // 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; } else { return Promise.reject(null); @@ -167,7 +172,7 @@ export type AddonBadgesUserBadge = { claimcomment: string; // Claim comment. 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. badgeid?: number; // Badge id. targetName?: string; // Target name. @@ -176,7 +181,16 @@ export type AddonBadgesUserBadge = { targetFramework?: string; // Target framework. 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. name: string; // Badge name. version?: string; // Version.