From f9ae54628b508b099eb8feadf927897969209f75 Mon Sep 17 00:00:00 2001 From: Marcella Maki Date: Thu, 17 Mar 2022 16:42:21 -0400 Subject: [PATCH 01/20] Add new metadata details to the text of the resource panel --- .../channelEdit/components/ResourcePanel.vue | 114 +++++++++++++++++- 1 file changed, 111 insertions(+), 3 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/ResourcePanel.vue b/contentcuration/contentcuration/frontend/channelEdit/components/ResourcePanel.vue index 28614b8779..7878ddb288 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/ResourcePanel.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/components/ResourcePanel.vue @@ -140,6 +140,31 @@ + + + + +
{{ defaultText }} @@ -162,7 +187,11 @@
- + @@ -355,7 +273,6 @@ import { ContentLevel, Categories, - LearningActivities, AccessibilityCategories, CompletionCriteriaModels, } from '../../shared/constants'; @@ -624,18 +541,10 @@ return this.$tr('longActivity') } }, - level(level) { - const match = Object.keys(ContentLevel).find(k => ContentLevel[k] == level); - if (match) { - return this.translateMetadataString(camelCase(match)); - } else { - return '-'; - } - }, - learningActivity(options) { - const ids = Object.values(options); - const matches = Object.keys(LearningActivities).filter(k => - ids.includes(LearningActivities[k]) + level(levels) { + const ids = Object.keys(levels); + const matches = Object.keys(ContentLevel).filter(k => + ids.includes(ContentLevel[k]) ); if (matches && matches.length > 0) { return this.matchIdToString(matches); @@ -665,22 +574,18 @@ return '-'; }, accessibilityOptions(options) { - if (options) { - const ids = Object.values(options); - const matches = Object.keys(AccessibilityCategories).filter(k => - ids.includes(AccessibilityCategories[k]) - ); - if (matches) { - return this.matchIdToString(matches); - } else { - return '-'; - } + const ids = Object.keys(options); + const matches = Object.keys(AccessibilityCategories).filter(k => + ids.includes(AccessibilityCategories[k]) + ); + if (matches && matches.length > 0) { + return this.matchIdToString(matches); } else { return '-'; } }, category(options) { - const ids = Object.values(options); + const ids = Object.keys(options); const matches = Object.keys(Categories).filter(k => ids.includes(Categories[k])); if (matches && matches.length > 0) { return this.matchIdToString(matches); diff --git a/contentcuration/contentcuration/frontend/channelEdit/vuex/contentNode/getters.js b/contentcuration/contentcuration/frontend/channelEdit/vuex/contentNode/getters.js index e4e374062f..6403e1fd22 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/vuex/contentNode/getters.js +++ b/contentcuration/contentcuration/frontend/channelEdit/vuex/contentNode/getters.js @@ -157,6 +157,7 @@ function getStepDetail(state, getters, contentNodeId) { id: contentNodeId, title: '', kind: '', + learning_activities: '', parentTitle: '', }; @@ -166,8 +167,10 @@ function getStepDetail(state, getters, contentNodeId) { return stepDetail; } + stepDetail.title = node.title; stepDetail.kind = node.kind; + stepDetail.learning_activities = node.learning_activities; const parentNodeId = state.contentNodesMap[contentNodeId].parent; @@ -178,6 +181,8 @@ function getStepDetail(state, getters, contentNodeId) { } } + console.log(stepDetail) + return stepDetail; } diff --git a/contentcuration/contentcuration/frontend/shared/views/ContentNodeIcon.vue b/contentcuration/contentcuration/frontend/shared/views/ContentNodeIcon.vue index 874b084810..32e281968c 100644 --- a/contentcuration/contentcuration/frontend/shared/views/ContentNodeIcon.vue +++ b/contentcuration/contentcuration/frontend/shared/views/ContentNodeIcon.vue @@ -1,105 +1,92 @@ + + diff --git a/contentcuration/contentcuration/frontend/shared/views/files/Thumbnail.vue b/contentcuration/contentcuration/frontend/shared/views/files/Thumbnail.vue index ad4cee6e76..e872945a80 100644 --- a/contentcuration/contentcuration/frontend/shared/views/files/Thumbnail.vue +++ b/contentcuration/contentcuration/frontend/shared/views/files/Thumbnail.vue @@ -18,7 +18,7 @@
- import { constantsTranslationMixin, printingMixin } from 'shared/mixins'; - import ContentNodeIcon from 'shared/views/ContentNodeIcon'; + import ContentNodeLearningActivityIcon from 'shared/views/ContentNodeLearningActivityIcon'; export default { name: 'Thumbnail', components: { - ContentNodeIcon, + ContentNodeLearningActivityIcon, }, mixins: [constantsTranslationMixin, printingMixin], props: { diff --git a/contentcuration/contentcuration/frontend/shared/vuetify/icons.js b/contentcuration/contentcuration/frontend/shared/vuetify/icons.js index 65959a696d..5ad894742e 100644 --- a/contentcuration/contentcuration/frontend/shared/vuetify/icons.js +++ b/contentcuration/contentcuration/frontend/shared/vuetify/icons.js @@ -22,7 +22,12 @@ export const CONTENT_KIND_ICONS = { [ContentKindsNames.HTML5]: 'widgets', }; -export function getContentKindIcon(activity) { +export function getContentKindIcon(kind, isEmpty = false) { + const icon = (isEmpty ? [kind + EMPTY] : []).concat([kind]).find(k => k in CONTENT_KIND_ICONS); + return icon ? CONTENT_KIND_ICONS[icon] : 'error_outline'; +} + +export function getLearningActivityIcon(activity) { if (activity == 'Explore') { return 'interactShaded'; } else if (activity == 'Multiple learning activities') { From 843a2b5710bb9f8a9b9946e32a71255434aebeff Mon Sep 17 00:00:00 2001 From: Marcella Maki Date: Wed, 6 Jul 2022 11:03:49 -0400 Subject: [PATCH 09/20] Update to use International List Formatting --- .../channelEdit/components/ResourcePanel.vue | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/ResourcePanel.vue b/contentcuration/contentcuration/frontend/channelEdit/components/ResourcePanel.vue index 23192d430e..dad0652892 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/ResourcePanel.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/components/ResourcePanel.vue @@ -360,6 +360,11 @@ import { MasteryModelsNames } from 'shared/leUtils/MasteryModels'; import { ContentKindsNames } from 'shared/leUtils/ContentKinds'; + const formatter = new Intl.ListFormat(window.languageCode, { + style: 'long', + type: 'conjunction', + }); + export default { name: 'ResourcePanel', components: { @@ -581,8 +586,9 @@ getText(field) { return this.node[field] || this.defaultText; }, - matchIdToString(ids) { - return ids.map(i => this.translateMetadataString(camelCase(i))).join(', '); + metadataListText(ids) { + const list = ids.map(i => this.translateMetadataString(camelCase(i))); + return formatter.format(list); }, level(levels) { const ids = Object.keys(levels); @@ -590,7 +596,7 @@ .sort() .filter(k => ids.includes(ContentLevel[k])); if (matches && matches.length > 0) { - return this.matchIdToString(matches); + return this.metadataListText(matches); } else { return '-'; } @@ -601,7 +607,7 @@ .sort() .filter(k => ids.includes(AccessibilityCategories[k])); if (matches && matches.length > 0) { - return this.matchIdToString(matches); + return this.metadataListText(matches); } else { return '-'; } @@ -612,7 +618,7 @@ .sort() .filter(k => ids.includes(Categories[k])); if (matches && matches.length > 0) { - return this.matchIdToString(matches); + return this.metadataListText(matches); } else { return '-'; } From 8f01d115385c6acfccf3ad4e59bc53b0c7017f01 Mon Sep 17 00:00:00 2001 From: Marcella Maki Date: Wed, 6 Jul 2022 11:37:27 -0400 Subject: [PATCH 10/20] Fix tests --- .../components/ContentNodeListItem/index.spec.js | 9 +++++---- .../channelEdit/components/ContentNodeListItem/index.vue | 9 ++------- .../shared/views/ContentNodeLearningActivityIcon.vue | 6 ++++-- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/ContentNodeListItem/index.spec.js b/contentcuration/contentcuration/frontend/channelEdit/components/ContentNodeListItem/index.spec.js index 0fbea109a4..12bcc72415 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/ContentNodeListItem/index.spec.js +++ b/contentcuration/contentcuration/frontend/channelEdit/components/ContentNodeListItem/index.spec.js @@ -42,6 +42,11 @@ describe('ContentNodeListItem', () => { propsData: { node: DOCUMENT_NODE, }, + computed: { + hasMetadataToDisplay() { + return true + } + } }); }); it('smoke test', () => { @@ -63,10 +68,6 @@ describe('ContentNodeListItem', () => { expect(wrapper.contains('[data-test="btn-chevron"]')).toBe(false); }); - it("doesn't render a subtitle for a node different from topic and exercise", () => { - expect(wrapper.contains('[data-test="subtitle"]')).toBe(false); - }); - it('emits an event when list item is clicked', () => { wrapper.find('[data-test="content-item"]').trigger('click'); diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/ContentNodeListItem/index.vue b/contentcuration/contentcuration/frontend/channelEdit/components/ContentNodeListItem/index.vue index bbfe0721cc..39c5086c12 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/ContentNodeListItem/index.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/components/ContentNodeListItem/index.vue @@ -77,13 +77,13 @@ />