152
152
>
153
153
<template #body =" { data } " >
154
154
<router-link
155
- v-slot = " { navigate } "
155
+ v-if = " data.visibility === 3 "
156
156
:to =" { name: 'CourseHome', params: { id: data.id } }"
157
157
>
158
158
<Button
159
159
:label =" $t('Go to the course')"
160
160
class =" btn btn--primary text-white"
161
161
icon =" pi pi-external-link"
162
- @click =" navigate"
163
162
/>
164
163
</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
+ />
165
188
</template >
166
189
</Column >
167
190
<template #footer >
@@ -180,10 +203,13 @@ import DataTable from "primevue/datatable"
180
203
import Column from " primevue/column"
181
204
import Rating from " primevue/rating"
182
205
import { usePlatformConfig } from " ../../store/platformConfig"
206
+ import { useSecurityStore } from " ../../store/securityStore"
183
207
208
+ const securityStore = useSecurityStore ()
184
209
const status = ref (null )
185
210
const courses = ref ([])
186
211
const filters = ref (null )
212
+ const currentUserId = securityStore .user .id
187
213
188
214
const platformConfigStore = usePlatformConfig ()
189
215
const showCourseDuration = " true" === platformConfigStore .getSetting (" course.show_course_duration" )
@@ -257,6 +283,10 @@ const newRating = function (courseId, value) {
257
283
})
258
284
}
259
285
286
+ const isUserInCourse = (course ) => {
287
+ return course .users .some ((user ) => user .user .id === currentUserId)
288
+ }
289
+
260
290
const clearFilter = function () {
261
291
initFilters ()
262
292
}
0 commit comments