Skip to content

Commit 4c0d224

Browse files
committed
Glossary: Fix student view button #6722
1 parent bd88c8f commit 4c0d224

File tree

1 file changed

+48
-33
lines changed

1 file changed

+48
-33
lines changed

assets/vue/views/glossary/GlossaryList.vue

Lines changed: 48 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,42 @@
11
<template>
22
<div>
3-
<BaseToolbar v-if="securityStore.isAuthenticated && canEditGlossary">
4-
<BaseButton
5-
:label="t('Add new glossary term')"
6-
icon="plus"
7-
type="black"
8-
@click="addNewTerm"
9-
/>
10-
<BaseButton
11-
:label="t('Import glossary')"
12-
icon="import"
13-
type="black"
14-
@click="importGlossary"
15-
/>
16-
<BaseButton
17-
:label="t('Export glossary')"
18-
icon="file-export"
19-
type="black"
20-
@click="exportGlossary"
21-
/>
22-
<BaseButton
23-
:icon="view === 'table' ? 'list' : 'table'"
24-
:label="view === 'table' ? t('List view') : t('Table view')"
25-
type="black"
26-
@click="changeView(view)"
27-
/>
28-
<BaseButton
29-
:label="t('Export to documents')"
30-
icon="export"
31-
type="black"
32-
@click="exportToDocuments"
3+
<BaseToolbar v-if="securityStore.isAuthenticated">
4+
<template v-if="canEditGlossary">
5+
<BaseButton
6+
:label="t('Add new glossary term')"
7+
icon="plus"
8+
type="black"
9+
@click="addNewTerm"
10+
/>
11+
<BaseButton
12+
:label="t('Import glossary')"
13+
icon="import"
14+
type="black"
15+
@click="importGlossary"
16+
/>
17+
<BaseButton
18+
:label="t('Export glossary')"
19+
icon="file-export"
20+
type="black"
21+
@click="exportGlossary"
22+
/>
23+
<BaseButton
24+
:icon="view === 'table' ? 'list' : 'table'"
25+
:label="view === 'table' ? t('List view') : t('Table view')"
26+
type="black"
27+
@click="changeView(view)"
28+
/>
29+
<BaseButton
30+
:label="t('Export to documents')"
31+
icon="export"
32+
type="black"
33+
@click="exportToDocuments"
34+
/>
35+
</template>
36+
<StudentViewButton
37+
v-if="course"
38+
@change="onStudentViewChange"
3339
/>
34-
<StudentViewButton />
3540
</BaseToolbar>
3641

3742
<BaseInputText
@@ -121,6 +126,8 @@ import BaseCard from "../../components/basecomponents/BaseCard.vue"
121126
import Skeleton from "primevue/skeleton"
122127
import { useSecurityStore } from "../../store/securityStore"
123128
import { checkIsAllowedToEdit } from "../../composables/userPermissions"
129+
import { useCidReqStore } from "../../store/cidReq"
130+
import { storeToRefs } from "pinia"
124131
125132
const route = useRoute()
126133
const router = useRouter()
@@ -129,6 +136,10 @@ const notifications = useNotification()
129136
130137
const { t } = useI18n()
131138
139+
const cidReqStore = useCidReqStore()
140+
141+
const { course } = storeToRefs(cidReqStore)
142+
132143
const isLoading = ref(true)
133144
const isSearchLoading = ref(false)
134145
const searchTerm = ref("")
@@ -168,10 +179,14 @@ const canEditGlossary = computed(() => {
168179
169180
onMounted(async () => {
170181
isLoading.value = true
171-
fetchGlossaries()
172-
isAllowedToEdit.value = await checkIsAllowedToEdit(true, true, true)
182+
await fetchGlossaries()
183+
await onStudentViewChange()
173184
})
174185
186+
async function onStudentViewChange() {
187+
isAllowedToEdit.value = await checkIsAllowedToEdit(true, true, true)
188+
}
189+
175190
const debouncedSearch = debounce(() => {
176191
searchBoxTouched.value = true
177192
isSearchLoading.value = true

0 commit comments

Comments
 (0)