From e7b8e4e86b410d7b3e7b1648ab7d712217c537d3 Mon Sep 17 00:00:00 2001 From: Alex Velez Date: Mon, 18 Nov 2024 09:41:43 -0500 Subject: [PATCH] Lesson Summary children routes refactor --- .../coach/assets/src/constants/index.js | 2 +- .../coach/assets/src/routes/lessonsRoutes.js | 61 ++++++++++++------- .../src/views/lessons/LessonCreationPage.vue | 24 -------- .../EditLessonDetails.vue | 16 ----- .../LessonResourceSelection.vue | 16 ----- .../PreviewSelectedResources.vue | 16 ----- .../views/lessons/LessonSummaryPage/index.vue | 10 +++ .../sidePanels/EditLessonDetails.vue | 34 +++++++++++ .../sidePanels/LessonResourceSelection.vue | 34 +++++++++++ .../sidePanels/PreviewSelectedResources.vue | 27 ++++++++ 10 files changed, 144 insertions(+), 96 deletions(-) delete mode 100644 kolibri/plugins/coach/assets/src/views/lessons/LessonEditDetailsPage/EditLessonDetails.vue delete mode 100644 kolibri/plugins/coach/assets/src/views/lessons/LessonResourceSelectionPage/LessonResourceSelection.vue delete mode 100644 kolibri/plugins/coach/assets/src/views/lessons/LessonSelectionContentPreviewPage/LessonContentPreview/PreviewSelectedResources.vue create mode 100644 kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/sidePanels/EditLessonDetails.vue create mode 100644 kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/sidePanels/LessonResourceSelection.vue create mode 100644 kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/sidePanels/PreviewSelectedResources.vue diff --git a/kolibri/plugins/coach/assets/src/constants/index.js b/kolibri/plugins/coach/assets/src/constants/index.js index acaf63f8d16..80f1dfb72c8 100644 --- a/kolibri/plugins/coach/assets/src/constants/index.js +++ b/kolibri/plugins/coach/assets/src/constants/index.js @@ -22,8 +22,8 @@ export const PageNames = { LESSONS_ROOT: 'LESSONS_ROOT', LESSONS_ROOT_BETTER: 'LESSONS_ROOT_BETTER', LESSON_SUMMARY: 'LESSON_SUMMARY', + LESSON_SUMMARY_BETTER: 'LESSON_SUMMARY_BETTER', LESSON_CREATION_ROOT: 'LESSON_CREATION_ROOT', - LESSON_CREATION_ROOT_BETTER: 'LESSON_CREATION_ROOT_BETTER', RESOURCE_CONTENT_PREVIEW: 'RESOURCE_CONTENT_PREVIEW', // exclusively a route name LESSON_RESOURCE_SELECTION_ROOT: 'LESSON_RESOURCE_SELECTION_ROOT', LESSON_RESOURCE_SELECTION: 'LESSON_RESOURCE_SELECTION', diff --git a/kolibri/plugins/coach/assets/src/routes/lessonsRoutes.js b/kolibri/plugins/coach/assets/src/routes/lessonsRoutes.js index ea3f9d3fe24..9c94acdb96b 100644 --- a/kolibri/plugins/coach/assets/src/routes/lessonsRoutes.js +++ b/kolibri/plugins/coach/assets/src/routes/lessonsRoutes.js @@ -19,9 +19,6 @@ import LessonResourceSelectionPage from '../views/lessons/LessonResourceSelectio import LessonSelectionContentPreviewPage from '../views/lessons/LessonSelectionContentPreviewPage'; import LessonEditDetailsPage from '../views/lessons/LessonEditDetailsPage'; import LessonCreationPage from '../views/lessons/LessonCreationPage'; -import EditLessonDetails from '../views/lessons/LessonEditDetailsPage/EditLessonDetails'; -import PreviewSelectedResources from '../views/lessons/LessonSelectionContentPreviewPage/LessonContentPreview/PreviewSelectedResources'; -import LessonResourceSelection from '../views/lessons/LessonResourceSelectionPage/LessonResourceSelection'; import { generateResourceHandler } from '../modules/resourceDetail/handlers'; import LessonResourceLearnersPage from '../views/lessons/reports/LessonResourceLearnersPage'; @@ -40,6 +37,9 @@ import { } from '../modules/questionDetail/handlers'; import LessonLearnerExercisePage from '../views/lessons/reports/LessonLearnerExercisePage.vue'; import QuestionLearnersPage from '../views/common/reports/QuestionLearnersPage.vue'; +import EditLessonDetails from '../views/lessons/LessonSummaryPage/sidePanels/EditLessonDetails'; +import PreviewSelectedResources from '../views/lessons/LessonSummaryPage/sidePanels/PreviewSelectedResources'; +import LessonResourceSelection from '../views/lessons/LessonSummaryPage/sidePanels/LessonResourceSelection'; import { classIdParamRequiredGuard, RouteSegments } from './utils'; const { @@ -105,9 +105,41 @@ export default [ component: LessonCreationPage, }, { - name: PageNames.LESSON_CREATION_ROOT_BETTER, - path: CLASS + LESSONS_TEMP + '/edit', - component: LessonCreationPage, + 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'], + }, + }, + { + name: PageNames.LESSON_SUMMARY_BETTER, + path: CLASS + LESSONS_TEMP + '/:tabId?', + component: LessonSummaryPage, + 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'], + }, children: [ { name: PageNames.LESSON_EDIT_DETAILS_BETTER, @@ -134,23 +166,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'], - }, - }, { name: PageNames.LESSON_EDIT_DETAILS, path: CLASS + LESSON + '/edit', diff --git a/kolibri/plugins/coach/assets/src/views/lessons/LessonCreationPage.vue b/kolibri/plugins/coach/assets/src/views/lessons/LessonCreationPage.vue index 22c0645f4cd..a719a9e3b0c 100644 --- a/kolibri/plugins/coach/assets/src/views/lessons/LessonCreationPage.vue +++ b/kolibri/plugins/coach/assets/src/views/lessons/LessonCreationPage.vue @@ -20,24 +20,6 @@ @cancel="() => $router.go(-1)" /> - - - - @@ -48,24 +30,18 @@ import { ERROR_CONSTANTS } from 'kolibri/constants'; import CatchErrors from 'kolibri/utils/CatchErrors'; import commonCoreStrings from 'kolibri/uiText/commonCoreStrings'; - import SidePanelModal from 'kolibri-common/components/SidePanelModal'; import AssignmentDetailsModal from '../common/assignments/AssignmentDetailsModal'; import commonCoach from '../common'; import CoachImmersivePage from '../CoachImmersivePage'; - import { PageNames } from '../../constants'; export default { name: 'LessonCreationPage', components: { AssignmentDetailsModal, CoachImmersivePage, - SidePanelModal, }, mixins: [commonCoach, commonCoreStrings], computed: { - showSidePanel() { - return this.$route.name === PageNames.LESSON_CREATION_ROOT_BETTER; - }, classId() { return this.$route.params.classId; }, diff --git a/kolibri/plugins/coach/assets/src/views/lessons/LessonEditDetailsPage/EditLessonDetails.vue b/kolibri/plugins/coach/assets/src/views/lessons/LessonEditDetailsPage/EditLessonDetails.vue deleted file mode 100644 index 430157f6c0d..00000000000 --- a/kolibri/plugins/coach/assets/src/views/lessons/LessonEditDetailsPage/EditLessonDetails.vue +++ /dev/null @@ -1,16 +0,0 @@ - - - - diff --git a/kolibri/plugins/coach/assets/src/views/lessons/LessonResourceSelectionPage/LessonResourceSelection.vue b/kolibri/plugins/coach/assets/src/views/lessons/LessonResourceSelectionPage/LessonResourceSelection.vue deleted file mode 100644 index 6963c1b89e5..00000000000 --- a/kolibri/plugins/coach/assets/src/views/lessons/LessonResourceSelectionPage/LessonResourceSelection.vue +++ /dev/null @@ -1,16 +0,0 @@ - - - - diff --git a/kolibri/plugins/coach/assets/src/views/lessons/LessonSelectionContentPreviewPage/LessonContentPreview/PreviewSelectedResources.vue b/kolibri/plugins/coach/assets/src/views/lessons/LessonSelectionContentPreviewPage/LessonContentPreview/PreviewSelectedResources.vue deleted file mode 100644 index 4d69ff11eea..00000000000 --- a/kolibri/plugins/coach/assets/src/views/lessons/LessonSelectionContentPreviewPage/LessonContentPreview/PreviewSelectedResources.vue +++ /dev/null @@ -1,16 +0,0 @@ - - - - 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 42e7d7c1a26..cdd5490d0bc 100644 --- a/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/index.vue +++ b/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/index.vue @@ -77,6 +77,7 @@ + @@ -125,6 +126,10 @@ type: Boolean, default: true, }, + isTemp: { + type: Boolean, + default: false, + }, }, data() { const workingResourcesBackup = [...(this.$store.state.lessonSummary.workingResources || [])]; @@ -150,6 +155,11 @@ return this.$route.params.lessonId; }, lessonSelectionRootPage() { + if (this.isTemp) { + return this.classRoute(PageNames.LESSON_SELECT_RESOURCES, { + lessonId: this.lessonId, + }); + } return this.classRoute(PageNames.LESSON_RESOURCE_SELECTION_ROOT, { lessonId: this.lessonId, }); diff --git a/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/sidePanels/EditLessonDetails.vue b/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/sidePanels/EditLessonDetails.vue new file mode 100644 index 00000000000..d10355ae6c0 --- /dev/null +++ b/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/sidePanels/EditLessonDetails.vue @@ -0,0 +1,34 @@ + + + + diff --git a/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/sidePanels/LessonResourceSelection.vue b/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/sidePanels/LessonResourceSelection.vue new file mode 100644 index 00000000000..ca637df2b55 --- /dev/null +++ b/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/sidePanels/LessonResourceSelection.vue @@ -0,0 +1,34 @@ + + + + diff --git a/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/sidePanels/PreviewSelectedResources.vue b/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/sidePanels/PreviewSelectedResources.vue new file mode 100644 index 00000000000..ab66b490d4c --- /dev/null +++ b/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/sidePanels/PreviewSelectedResources.vue @@ -0,0 +1,27 @@ + + + +