From ab8a2dc9ecff0bfb5c355d133b8b6f6d47b4a4bd Mon Sep 17 00:00:00 2001 From: jacob Date: Tue, 7 Sep 2021 07:44:38 -0700 Subject: [PATCH] MarkAsComplete modal in LearnImmersiveLayout flow - LearningActivityBar is hard coded to show when not in production - should be from content metadata. - Added GlobalSnackbar to LearnImmersiveLayout - MarkAsComplete modal now uses available Vuex action to dispatch progress update. --- .../assets/src/views/LearnImmersiveLayout.vue | 10 ++++++++- .../assets/src/views/LearningActivityBar.vue | 11 +++++++++- .../assets/src/views/MarkAsCompleteModal.vue | 20 ++---------------- .../test/views/mark-as-complete.spec.js | 21 ++++--------------- 4 files changed, 25 insertions(+), 37 deletions(-) diff --git a/kolibri/plugins/learn/assets/src/views/LearnImmersiveLayout.vue b/kolibri/plugins/learn/assets/src/views/LearnImmersiveLayout.vue index 2b0d7542fd2..a9f11989b5a 100644 --- a/kolibri/plugins/learn/assets/src/views/LearnImmersiveLayout.vue +++ b/kolibri/plugins/learn/assets/src/views/LearnImmersiveLayout.vue @@ -13,7 +13,7 @@ :learningActivities="mappedLearningActivities" :isLessonContext="true" :isBookmarked="true" - :allowMarkComplete="false" + :allowMarkComplete="allowMarkComplete" data-test="learningActivityBar" @navigateBack="navigateBack" /> @@ -46,6 +46,7 @@ data-test="contentPage" /> + @@ -59,6 +60,7 @@ import AuthMessage from 'kolibri.coreVue.components.AuthMessage'; import { LearningActivities } from 'kolibri.coreVue.vuex.constants'; import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings'; + import GlobalSnackbar from '../../../../../../kolibri/core/assets/src/views/GlobalSnackbar'; import SkipNavigationLink from '../../../../../../kolibri/core/assets/src/views/SkipNavigationLink'; import AppError from '../../../../../../kolibri/core/assets/src/views/AppError'; import ContentPage from './ContentPage'; @@ -93,6 +95,7 @@ AppError, AuthMessage, ContentPage, + GlobalSnackbar, LearningActivityBar, SkipNavigationLink, }, @@ -141,6 +144,11 @@ resourceTitle() { return this.content ? this.content.title : ''; }, + allowMarkComplete() { + // TODO: This should be determined by some other means. Content metadata? + const DEV_ONLY = process.env.NODE_ENV !== 'production'; + return DEV_ONLY; + }, mappedLearningActivities() { let learningActivities = []; if (this.content && this.content.kind) { diff --git a/kolibri/plugins/learn/assets/src/views/LearningActivityBar.vue b/kolibri/plugins/learn/assets/src/views/LearningActivityBar.vue index 1773698a694..0581356d609 100644 --- a/kolibri/plugins/learn/assets/src/views/LearningActivityBar.vue +++ b/kolibri/plugins/learn/assets/src/views/LearningActivityBar.vue @@ -78,6 +78,11 @@ + @@ -92,7 +97,8 @@ import UiToolbar from 'kolibri.coreVue.components.UiToolbar'; import TextTruncator from 'kolibri.coreVue.components.TextTruncator'; import { LearningActivities } from 'kolibri.coreVue.vuex.constants'; - import LearningActivityIcon from './LearningActivityIcon.vue'; + import LearningActivityIcon from './LearningActivityIcon'; + import MarkAsCompleteModal from './MarkAsCompleteModal'; export default { name: 'LearningActivityBar', @@ -102,6 +108,7 @@ UiToolbar, TextTruncator, LearningActivityIcon, + MarkAsCompleteModal, }, mixins: [KResponsiveWindowMixin], /** @@ -159,6 +166,7 @@ data() { return { isMenuOpen: false, + showMarkAsCompleteModal: false, }; }, computed: { @@ -224,6 +232,7 @@ }, created() { window.addEventListener('click', this.onWindowClick); + this.$on('markComplete', () => (this.showMarkAsCompleteModal = true)); }, beforeDestroy() { window.removeEventListener('click', this.onWindowClick); diff --git a/kolibri/plugins/learn/assets/src/views/MarkAsCompleteModal.vue b/kolibri/plugins/learn/assets/src/views/MarkAsCompleteModal.vue index 8da608714cb..7677c783000 100644 --- a/kolibri/plugins/learn/assets/src/views/MarkAsCompleteModal.vue +++ b/kolibri/plugins/learn/assets/src/views/MarkAsCompleteModal.vue @@ -1,7 +1,6 @@