Skip to content

Commit 107992d

Browse files
authored
Merge pull request #5568 from pauline2k/boac-6689
BOAC-6689 Include cohort id in history route
2 parents b66cf2f + 9fa8eae commit 107992d

3 files changed

Lines changed: 32 additions & 10 deletions

File tree

src/components/cohort/CohortPageHeader.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147
color="anchor"
148148
:disabled="isModifiedSinceLastSearch"
149149
variant="text"
150-
to="/cohort/history"
150+
:to="`/cohort/${cohortId}/history`"
151151
>
152152
<span class="sr-only">Cohort</span>&nbsp;History
153153
</v-btn>

src/router.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,16 @@ const routes:RouteRecordRaw[] = [
105105
component: BrowseAllGroups,
106106
meta: {groupsType: 'curated'}
107107
},
108-
{
109-
path: '/cohort/history',
110-
component: CohortHistory,
111-
name: 'Cohort History'
112-
},
113108
{
114109
path: '/cohort/:id',
115110
component: Cohort,
116111
name: 'Cohort'
117112
},
113+
{
114+
path: '/cohort/:id/history',
115+
component: CohortHistory,
116+
name: 'Cohort History'
117+
},
118118
{
119119
path: '/course/:termId/:sectionId',
120120
component: Course,

src/views/CohortHistory.vue

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,19 @@
8888

8989
<script setup>
9090
import {get, isEmpty} from 'lodash'
91-
import {onMounted, ref} from 'vue'
91+
import {computed, onMounted, ref} from 'vue'
92+
import {useRoute} from 'vue-router'
9293
import AdmitDataWarning from '@/components/admit/AdmitDataWarning.vue'
9394
import CohortPageHeader from '@/components/cohort/CohortPageHeader.vue'
9495
import Date from '@/components/util/Date.vue'
9596
import Pagination from '@/components/util/Pagination'
9697
import {getCohortEvents} from '@/api/cohort'
97-
import {lastNameFirst, putFocusNextTick, scrollToTop, studentRoutePath} from '@/lib/utils'
98+
import {lastNameFirst, putFocusNextTick, scrollToTop, studentRoutePath, toInt} from '@/lib/utils'
9899
import {useCohortStore} from '@/stores/cohort-edit-session'
100+
import {loadCohort} from '@/stores/cohort-edit-session/cohort-edit-session-utils'
99101
import {useContextStore} from '@/stores/context'
100102
103+
const cohortId = ref(0)
101104
const cohortStore = useCohortStore()
102105
const contextStore = useContextStore()
103106
@@ -110,17 +113,36 @@ const totalEventsCount = ref(0)
110113
111114
contextStore.loadingStart()
112115
116+
const sortByKey = computed(() => cohortStore.domain === 'admitted_students' ? 'admitSortBy' : 'sortBy')
117+
113118
onMounted(() => {
114-
goToPage(1)
119+
init().then(() => {
120+
goToPage(1)
121+
})
115122
})
116123
124+
const init = () => {
125+
return new Promise(resolve => {
126+
if (cohortStore && cohortStore.cohortId) {
127+
cohortId.value = cohortStore.cohortId
128+
resolve()
129+
} else {
130+
cohortId.value = toInt(get(useRoute(), 'params.id'))
131+
const orderBy = get(currentUser.preferences, sortByKey.value)
132+
const termId = get(currentUser.preferences, 'termId')
133+
cohortStore.resetSession()
134+
loadCohort(cohortId.value, orderBy, termId).then(resolve)
135+
}
136+
})
137+
}
138+
117139
const goToPage = page => {
118140
return new Promise(resolve => {
119141
currentPage.value = page
120142
offset.value = (page - 1) * itemsPerPage.value
121143
contextStore.loadingStart()
122144
scrollToTop(10)
123-
getCohortEvents(cohortStore.cohortId, offset.value, itemsPerPage.value).then(data => {
145+
getCohortEvents(cohortId.value, offset.value, itemsPerPage.value).then(data => {
124146
totalEventsCount.value = data.count
125147
events.value = data.events
126148
contextStore.loadingComplete()

0 commit comments

Comments
 (0)