121
121
122
122
<div class =" mt-auto pt-2" >
123
123
<router-link
124
- v-if =" course.visibility === 3 || ( course.visibility === 2 && isUserInCourse )"
124
+ v-if =" isUserInCourse && ( course.visibility === 2 || course.visibility === 3 )"
125
125
:to =" { name: 'CourseHome', params: { id: course.id } }"
126
126
>
127
127
<Button
132
132
</router-link >
133
133
134
134
<Button
135
- v-else-if =" course.visibility === 2 && course.subscribe && !isUserInCourse"
135
+ v-else-if =" isLocked && hasRequirements"
136
+ :label =" $t('Check requirements')"
137
+ icon =" mdi mdi-shield-check"
138
+ class =" w-full p-button-warning"
139
+ @click =" showDependenciesModal = true"
140
+ />
141
+
142
+ <Button
143
+ v-else-if =" course.subscribe && props.currentUserId"
136
144
:label =" $t('Subscribe')"
137
145
icon =" pi pi-sign-in"
138
146
class =" w-full"
139
147
@click =" subscribeToCourse"
140
148
/>
141
149
142
150
<Button
143
- v-else-if =" course.visibility === 2 && !course.subscribe && !isUserInCourse "
151
+ v-else-if =" course.visibility === 2 && !course.subscribe && props.currentUserId "
144
152
:label =" $t('Subscription not allowed')"
145
153
icon =" pi pi-ban"
146
154
disabled
165
173
</div >
166
174
</div >
167
175
</div >
176
+ <CatalogueRequirementModal
177
+ v-model =" showDependenciesModal"
178
+ :course-id =" course.id"
179
+ :session-id =" course.sessionId || 0"
180
+ :requirements =" requirementList"
181
+ :graph-image =" graphImage"
182
+ />
168
183
<Dialog
169
184
v-model:visible =" showDescriptionDialog"
170
185
:header =" course.title"
179
194
<script setup>
180
195
import Rating from " primevue/rating"
181
196
import Button from " primevue/button"
182
- import { computed , ref } from " vue "
183
- import courseRelUserService from " ../../services/courseRelUserService "
197
+ import Dialog from " primevue/dialog "
198
+ import { computed , ref , onMounted } from " vue "
184
199
import { useRoute , useRouter } from " vue-router"
185
200
import { useNotification } from " ../../composables/notification"
186
- import Dialog from " primevue/dialog"
187
201
import { usePlatformConfig } from " ../../store/platformConfig"
202
+ import CatalogueRequirementModal from " ./CatalogueRequirementModal.vue"
203
+ import courseRelUserService from " ../../services/courseRelUserService"
204
+ import { useCourseRequirementStatus } from " ../../composables/course/useCourseRequirementStatus"
188
205
import { useLocale } from " ../../composables/locale"
189
- const platformConfigStore = usePlatformConfig ()
190
- const showDescriptionDialog = ref (false )
191
206
const { getOriginalLanguageName } = useLocale ()
192
207
193
- const allowDescription = computed (
194
- () => platformConfigStore .getSetting (" course.show_courses_descriptions_in_catalog" ) !== " false" ,
195
- )
196
-
197
208
const props = defineProps ({
198
209
course: Object ,
199
210
currentUserId: {
@@ -212,6 +223,14 @@ const emit = defineEmits(["rate", "subscribed"])
212
223
const router = useRouter ()
213
224
const route = useRoute ()
214
225
const { showErrorNotification , showSuccessNotification } = useNotification ()
226
+ const platformConfigStore = usePlatformConfig ()
227
+
228
+ const showDescriptionDialog = ref (false )
229
+ const showDependenciesModal = ref (false )
230
+
231
+ const allowDescription = computed (
232
+ () => platformConfigStore .getSetting (" course.show_courses_descriptions_in_catalog" ) !== " false" ,
233
+ )
215
234
216
235
const isUserInCourse = computed (() => {
217
236
if (! props .currentUserId ) return false
@@ -287,9 +306,7 @@ function routeExists(name) {
287
306
288
307
const linkSettings = computed (() => {
289
308
const settings = platformConfigStore .getSetting (" course.course_catalog_settings" )
290
- const result = settings? .link_settings ?? {}
291
- console .log (" Link settings:" , result)
292
- return result
309
+ return settings? .link_settings ?? {}
293
310
})
294
311
295
312
const imageLink = computed (() => {
@@ -304,10 +321,6 @@ const imageLink = computed(() => {
304
321
return { name: routeName, params: { id: props .course .id } }
305
322
}
306
323
307
- if (routeName) {
308
- console .warn (` [CatalogueCourseCard] Route '${ routeName} ' does not exist.` )
309
- }
310
-
311
324
return null
312
325
})
313
326
@@ -318,20 +331,21 @@ const titleLink = computed(() => {
318
331
return { name: routeName, params: { id: props .course .id } }
319
332
}
320
333
321
- if (routeName) {
322
- console .warn (` [CatalogueCourseCard] Route '${ routeName} ' does not exist.` )
323
- }
324
-
325
334
return null
326
335
})
327
336
328
337
const showInfoPopup = computed (() => {
329
338
const allowed = [" course_description_popup" ]
330
339
const value = linkSettings .value .info_url
331
- if (value && ! allowed .includes (value)) {
332
- console .warn (` [CatalogueCourseCard] info_url '${ value} ' is not a recognized option.` )
333
- return false
334
- }
335
- return value === " course_description_popup"
340
+ return value && allowed .includes (value)
341
+ })
342
+
343
+ const { isLocked , hasRequirements , requirementList , graphImage , fetchStatus } = useCourseRequirementStatus (
344
+ props .course .id ,
345
+ props .course .sessionId || 0 ,
346
+ )
347
+
348
+ onMounted (() => {
349
+ fetchStatus ()
336
350
})
337
351
< / script>
0 commit comments