Internal: Add router guard to set course and session in store - refs BT#20933

pull/4862/head
Angel Fernando Quiroz Campos 1 year ago
parent 9b26d5e598
commit 686b969f10
  1. 14
      assets/vue/router/index.js
  2. 6
      assets/vue/views/ccalendarevent/CCalendarEventList.vue
  3. 3
      assets/vue/views/course/CourseHome.vue
  4. 4
      assets/vue/views/ctoolintro/Create.vue
  5. 4
      assets/vue/views/ctoolintro/Update.vue
  6. 4
      assets/vue/views/documents/DocumentsList.vue

@ -33,6 +33,7 @@ import CourseHome from "../views/course/CourseHome.vue"
import Index from "../pages/Index.vue"
import Home from "../pages/Home.vue"
import Login from "../pages/Login.vue"
import { useCidReqStore } from "../store/cidReq"
const router = createRouter({
history: createWebHistory(),
@ -161,4 +162,17 @@ router.beforeEach((to, from, next) => {
}
})
router.beforeResolve(async (to) => {
const cidReqStore = useCidReqStore()
const cid = parseInt(to.query?.cid ?? 0)
const sid = parseInt(to.query?.sid ?? 0)
if (cid) {
await cidReqStore.setCourseAndSessionById(cid, sid)
} else {
cidReqStore.resetCidReq()
}
})
export default router

@ -154,12 +154,6 @@ const sessionState = reactive({
const { cid, sid, gid } = useCidReq()
if (cid) {
cidReqStore.setCourseAndSessionById(cid, sid)
} else {
cidReqStore.resetCidReq()
}
async function getCalendarEvents({ startStr, endStr }) {
const calendarEvents = await cCalendarEventService
.findAll({

@ -284,9 +284,6 @@ const isCustomizing = ref(false)
provide("isSorting", isSorting)
provide("isCustomizing", isCustomizing)
// Remove the course session state.
cidReqStore.resetCidReq()
const courseItems = ref([])
const routerTools = ["document", "link", "glossary", "agenda", "student_publication", "course_homepage"]

@ -26,7 +26,6 @@ import { ENTRYPOINT } from "../../config/entrypoint"
import useNotification from "../../components/Notification"
import { useI18n } from "vue-i18n"
import { useCidReq } from "../../composables/cidReq"
import { useCidReqStore } from "../../store/cidReq"
const servicePrefix = "ctoolintro"
@ -52,7 +51,6 @@ export default {
const router = useRouter()
const { showNotification } = useNotification()
const { t } = useI18n()
const cidReqStore = useCidReqStore()
let id = route.params.id
if (isEmpty(id)) {
@ -61,8 +59,6 @@ export default {
const { cid } = useCidReq()
cidReqStore.setCourseAndSessionById(cid)
let toolId = route.params.courseTool
let ctoolId = route.query.ctoolId

@ -24,7 +24,6 @@ import axios from "axios"
import { ENTRYPOINT } from "../../config/entrypoint"
import { RESOURCE_LINK_PUBLISHED } from "../../components/resource_links/visibility"
import useNotification from "../../components/Notification"
import { useCidReqStore } from "../../store/cidReq"
import { useCidReq } from "../../composables/cidReq"
const servicePrefix = "ctoolintro"
@ -42,13 +41,10 @@ export default {
const route = useRoute()
const router = useRouter()
const { showNotification } = useNotification()
const cidReqStore = useCidReqStore()
const item = ref({})
const { cid, sid } = useCidReq()
const { t } = useI18n()
cidReqStore.setCourseAndSessionById(cid)
let toolId = route.query.ctoolId
let ctoolintroId = route.query.ctoolintroIid

@ -305,10 +305,8 @@ import BaseChart from "../../components/basecomponents/BaseChart.vue"
import DocumentAudioRecorder from "../../components/documents/DocumentAudioRecorder.vue"
import { useNotification } from "../../composables/notification"
import { useSecurityStore } from "../../store/securityStore"
import { useCidReqStore } from "../../store/cidReq"
const store = useStore()
const cidReqStore = useCidReqStore()
const route = useRoute()
const router = useRouter()
const securityStore = useSecurityStore()
@ -319,8 +317,6 @@ const notification = useNotification()
const { cid, sid, gid } = useCidReq()
const { isImage } = useFileUtils()
cidReqStore.setCourseAndSessionById(cid, sid)
const item = ref({})
const usageData = ref({})

Loading…
Cancel
Save