Skip to content

Commit d90fa84

Browse files
Merge pull request #5806 from christianbeeznest/GH-1402
Course: Improve course access and button labels in course catalog - refs #1402
2 parents 272dfb7 + 9215b64 commit d90fa84

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

assets/vue/views/course/CatalogueCourses.vue

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,39 @@
152152
>
153153
<template #body="{ data }">
154154
<router-link
155-
v-slot="{ navigate }"
155+
v-if="data.visibility === 3"
156156
:to="{ name: 'CourseHome', params: { id: data.id } }"
157157
>
158158
<Button
159159
:label="$t('Go to the course')"
160160
class="btn btn--primary text-white"
161161
icon="pi pi-external-link"
162-
@click="navigate"
163162
/>
164163
</router-link>
164+
<router-link
165+
v-else-if="data.visibility === 2 && isUserInCourse(data)"
166+
:to="{ name: 'CourseHome', params: { id: data.id } }"
167+
>
168+
<Button
169+
:label="$t('Go to the course')"
170+
class="btn btn--primary text-white"
171+
icon="pi pi-external-link"
172+
/>
173+
</router-link>
174+
<Button
175+
v-else-if="data.visibility === 2 && !isUserInCourse(data)"
176+
:label="$t('Not subscribed')"
177+
class="btn btn--primary text-white"
178+
icon="pi pi-times"
179+
disabled
180+
/>
181+
<Button
182+
v-else
183+
:label="$t('Private course')"
184+
class="btn btn--primary text-white"
185+
icon="pi pi-lock"
186+
disabled
187+
/>
165188
</template>
166189
</Column>
167190
<template #footer>
@@ -180,10 +203,13 @@ import DataTable from "primevue/datatable"
180203
import Column from "primevue/column"
181204
import Rating from "primevue/rating"
182205
import { usePlatformConfig } from "../../store/platformConfig"
206+
import { useSecurityStore } from "../../store/securityStore"
183207
208+
const securityStore = useSecurityStore()
184209
const status = ref(null)
185210
const courses = ref([])
186211
const filters = ref(null)
212+
const currentUserId = securityStore.user.id
187213
188214
const platformConfigStore = usePlatformConfig()
189215
const showCourseDuration = "true" === platformConfigStore.getSetting("course.show_course_duration")
@@ -257,6 +283,10 @@ const newRating = function (courseId, value) {
257283
})
258284
}
259285
286+
const isUserInCourse = (course) => {
287+
return course.users.some((user) => user.user.id === currentUserId)
288+
}
289+
260290
const clearFilter = function () {
261291
initFilters()
262292
}

0 commit comments

Comments
 (0)