From e84fa8c0daa71be88d7e9ce2db152793e9127ab5 Mon Sep 17 00:00:00 2001 From: Alex Velez Date: Tue, 19 Nov 2024 12:31:13 -0500 Subject: [PATCH] Fix loading data management --- kolibri/plugins/coach/assets/src/app.js | 6 ++++++ .../coach/assets/src/routes/lessonsRoutes.js | 19 ------------------- .../views/lessons/LessonSummaryPage/index.vue | 15 +++++++++++---- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/kolibri/plugins/coach/assets/src/app.js b/kolibri/plugins/coach/assets/src/app.js index 0d9de3d8182..fc0d1f84f4e 100644 --- a/kolibri/plugins/coach/assets/src/app.js +++ b/kolibri/plugins/coach/assets/src/app.js @@ -65,6 +65,12 @@ class CoachToolsModule extends KolibriApp { PageNames.QUIZ_SECTION_ORDER, PageNames.QUIZ_BOOK_MARKED_RESOURCES, PageNames.QUIZ_LEARNER_REPORT, + PageNames.LESSON_SUMMARY, + PageNames.LESSON_SUMMARY_BETTER, + PageNames.LESSON_SELECT_RESOURCES, + PageNames.LESSON_EDIT_DETAILS_BETTER, + PageNames.LESSON_PREVIEW_SELECTED_RESOURCES, + PageNames.LESSON_PREVIEW_RESOURCE, ]; // If we're navigating to the same page for a quiz summary page, don't set loading if ( diff --git a/kolibri/plugins/coach/assets/src/routes/lessonsRoutes.js b/kolibri/plugins/coach/assets/src/routes/lessonsRoutes.js index 9c94acdb96b..cf688592915 100644 --- a/kolibri/plugins/coach/assets/src/routes/lessonsRoutes.js +++ b/kolibri/plugins/coach/assets/src/routes/lessonsRoutes.js @@ -8,7 +8,6 @@ import { showLessonResourceBookmarks, showLessonResourceBookmarksMain, } from '../modules/lessonResources/handlers'; -import { showLessonSummaryPage } from '../modules/lessonSummary/handlers'; import { PageNames } from '../constants'; import { useLessons } from '../composables/useLessons'; @@ -108,15 +107,6 @@ export default [ name: PageNames.LESSON_SUMMARY, path: CLASS + LESSON + '/:tabId?', component: LessonSummaryPage, - handler(toRoute, fromRoute) { - if ( - fromRoute.name !== PageNames.LESSON_SUMMARY || - toRoute.params.lessonId !== fromRoute.params.lessonId - ) { - return showLessonSummaryPage(store, toRoute.params); - } - store.dispatch('notLoading'); - }, meta: { titleParts: ['LESSON_NAME', 'CLASS_NAME'], }, @@ -128,15 +118,6 @@ export default [ props: { isTemp: true, }, - handler(toRoute, fromRoute) { - if ( - fromRoute.name !== PageNames.LESSON_SUMMARY || - toRoute.params.lessonId !== fromRoute.params.lessonId - ) { - return showLessonSummaryPage(store, toRoute.params); - } - store.dispatch('notLoading'); - }, meta: { titleParts: ['LESSON_NAME', 'CLASS_NAME'], }, diff --git a/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/index.vue b/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/index.vue index cdd5490d0bc..51151450bfe 100644 --- a/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/index.vue +++ b/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/index.vue @@ -89,11 +89,13 @@ import { mapState, mapActions, mapMutations } from 'vuex'; import commonCoreStrings from 'kolibri/uiText/commonCoreStrings'; import useSnackbar from 'kolibri/composables/useSnackbar'; + import { computed, getCurrentInstance, watch } from '@vue/composition-api'; import commonCoach from '../../common'; import CoachAppBarPage from '../../CoachAppBarPage'; import ReportsControls from '../../common/ReportsControls'; import { REPORTS_LESSON_TABS_ID, ReportsLessonTabs } from '../../../constants/tabsConstants'; import { PageNames } from '../../../constants'; + import { showLessonSummaryPage } from '../../../modules/lessonSummary/handlers'; import LessonResourcesTable from './tables/LessonResourcesTable'; import LessonLearnersTable from './tables/LessonLearnersTable'; import LessonOptionsDropdownMenu from './LessonOptionsDropdownMenu'; @@ -118,8 +120,16 @@ }, mixins: [commonCoach, commonCoreStrings], setup() { + const store = getCurrentInstance().proxy.$store; + const routeParams = computed(() => store.state.route.params); + const lessonId = computed(() => routeParams.value.lessonId); + + showLessonSummaryPage(store, routeParams.value); + + watch(lessonId, () => showLessonSummaryPage(store, routeParams.value)); + const { createSnackbar, clearSnackbar } = useSnackbar(); - return { createSnackbar, clearSnackbar }; + return { lessonId, createSnackbar, clearSnackbar }; }, props: { editable: { @@ -151,9 +161,6 @@ loading() { return this.$store.state.core.loading; }, - lessonId() { - return this.$route.params.lessonId; - }, lessonSelectionRootPage() { if (this.isTemp) { return this.classRoute(PageNames.LESSON_SELECT_RESOURCES, {