Skip to content

Commit

Permalink
Merge pull request #11283 from thanksameeelian/fix-broken-lesson-crea…
Browse files Browse the repository at this point in the history
…tion

coach routing - handle lesson creation and deletion
  • Loading branch information
rtibbles authored Sep 25, 2023
2 parents 1c886dd + 0abd546 commit 7b61c25
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,4 +332,5 @@ export function showExamCreationQuestionSelectionPage(store, toRoute, fromRoute)
store.commit('SET_PAGE_NAME', 'EXAM_CREATION_QUESTION_SELECTION');
store.commit('SET_TOOLBAR_ROUTE', { name: fromRoute.name, params: fromRoute.params });
store.dispatch('examCreation/updateSelectedQuestions');
store.dispatch('notLoading');
}
5 changes: 3 additions & 2 deletions kolibri/plugins/coach/assets/src/routes/planLessonsRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import LessonEditDetailsPage from '../views/plan/LessonEditDetailsPage';
import LessonCreationPage from '../views/plan/LessonCreationPage';
import { classIdParamRequiredGuard } from './utils';

const CLASS = '/:classId?/plan';
const OPTIONAL_CLASS = '/:classId?/plan';
const CLASS = '/:classId/plan';
const LESSON = '/lessons/:lessonId';
const ALL_LESSONS = '/lessons';
const SELECTION = '/selection';
Expand All @@ -39,7 +40,7 @@ const { showLessonsRootPage } = useLessons();
export default [
{
name: LessonsPageNames.PLAN_LESSONS_ROOT,
path: path(CLASS, ALL_LESSONS),
path: path(OPTIONAL_CLASS, ALL_LESSONS),
component: LessonsRootPage,
handler(toRoute, fromRoute, next) {
if (classIdParamRequiredGuard(toRoute, PageNames.PLAN_PAGE, next)) {
Expand Down
7 changes: 4 additions & 3 deletions kolibri/plugins/coach/assets/src/routes/reportRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import QuizEditDetailsPage from '../views/plan/QuizEditDetailsPage';
import { classIdParamRequiredGuard } from './utils';

const ACTIVITY = '/activity';
const CLASS = '/:classId?/reports';
const OPTIONAL_CLASS = '/:classId?/reports';
const CLASS = '/:classId/reports';
const GROUPS = '/groups';
const GROUP = '/groups/:groupId';
const LEARNERS = '/learners';
Expand Down Expand Up @@ -45,7 +46,7 @@ function defaultHandler() {
export default [
{
name: PageNames.REPORTS_PAGE,
path: path(CLASS),
path: path(OPTIONAL_CLASS),
redirect: { name: 'ReportsLessonListPage' },
},
{
Expand Down Expand Up @@ -444,7 +445,7 @@ export default [
},
},
{
path: path(CLASS, LESSONS),
path: path(OPTIONAL_CLASS, LESSONS),
component: pages.ReportsLessonListPage,
handler: (toRoute, fromRoute, next) => {
if (classIdParamRequiredGuard(toRoute, 'ReportsLessonListPage', next)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,12 @@
const { id } = this.currentLesson;
return LessonResource.deleteModel({ id })
.then(() => {
this.$router.replace(this.$router.getRoute('PLAN_LESSONS_ROOT'), () => {
this.showSnackbarNotification('lessonDeleted');
});
this.$router.replace(
this.$router.getRoute('PLAN_LESSONS_ROOT', { classId: this.classId }),
() => {
this.showSnackbarNotification('lessonDeleted');
}
);
})
.catch(error => {
this.$store.dispatch('handleApiError', { error });
Expand Down

0 comments on commit 7b61c25

Please sign in to comment.