From 1b56d9b2edbb5a19662654724fd38b5f02c86a57 Mon Sep 17 00:00:00 2001 From: Samson Akol Date: Wed, 31 May 2023 13:17:29 +0300 Subject: [PATCH 1/2] Fixes loading issue --- .../channelEdit/components/ResourcePanel.vue | 314 ++++++++++++++---- .../contentcuration/frontend/shared/mixins.js | 7 +- 2 files changed, 260 insertions(+), 61 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/ResourcePanel.vue b/contentcuration/contentcuration/frontend/channelEdit/components/ResourcePanel.vue index 834a19190d..a7afdab919 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/ResourcePanel.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/components/ResourcePanel.vue @@ -1,12 +1,27 @@ @@ -445,7 +639,7 @@ return '-'; }, hasLearningActivities() { - return this.node && Object.keys(this.node.learning_activities).length > 0; + return this.node && Object.keys(this.node.learning_activities || []).length > 0; }, assessmentItems() { return this.getAssessmentItems(this.nodeId); @@ -591,7 +785,7 @@ return formatter.format(list); }, level(levels) { - const ids = Object.keys(levels); + const ids = Object.keys(levels || []); const matches = Object.keys(ContentLevels) .sort() .filter(k => ids.includes(ContentLevels[k])); @@ -616,7 +810,7 @@ } }, accessibilityOptions(options) { - const ids = Object.keys(options); + const ids = Object.keys(options || []); const matches = Object.keys(AccessibilityCategories) .sort() .filter(k => ids.includes(AccessibilityCategories[k])); @@ -627,7 +821,7 @@ } }, category(options) { - const ids = Object.keys(options); + const ids = Object.keys(options || []); const matches = Object.keys(Categories) .sort() .filter(k => ids.includes(Categories[k])); diff --git a/contentcuration/contentcuration/frontend/shared/mixins.js b/contentcuration/contentcuration/frontend/shared/mixins.js index b2efe145dc..e8cf695fc0 100644 --- a/contentcuration/contentcuration/frontend/shared/mixins.js +++ b/contentcuration/contentcuration/frontend/shared/mixins.js @@ -180,7 +180,12 @@ export const constantStrings = createTranslator('ConstantStrings', { export const constantsTranslationMixin = { methods: { translateConstant(constant) { - return constantStrings.$tr(constant); + /* + * Prevent translation of unknown keys. Initially, translation + * would default to `ConstantStrings.` if not found, which + * is not desired on the front-end. + */ + return constant && constantStrings.$tr(constant); }, translateLanguage(language) { return Languages.has(language) && Languages.get(language).native_name; From 80831240cdba1fc936aea10c754eab847aa61d52 Mon Sep 17 00:00:00 2001 From: Samson Akol Date: Wed, 31 May 2023 13:34:51 +0300 Subject: [PATCH 2/2] Updates comments --- contentcuration/contentcuration/frontend/shared/mixins.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/contentcuration/contentcuration/frontend/shared/mixins.js b/contentcuration/contentcuration/frontend/shared/mixins.js index e8cf695fc0..cb452bcd4d 100644 --- a/contentcuration/contentcuration/frontend/shared/mixins.js +++ b/contentcuration/contentcuration/frontend/shared/mixins.js @@ -181,9 +181,8 @@ export const constantsTranslationMixin = { methods: { translateConstant(constant) { /* - * Prevent translation of unknown keys. Initially, translation - * would default to `ConstantStrings.` if not found, which - * is not desired on the front-end. + * Prevent translation of null, undefined and empty keys. Initially, translation would + * default to `ConstantStrings.` if not found, which is not desired on the front-end. */ return constant && constantStrings.$tr(constant); },