121121
122122 <div class =" mt-auto pt-2" >
123123 <router-link
124- v-if =" course.visibility === 3 || ( course.visibility === 2 && isUserInCourse )"
124+ v-if =" isUserInCourse && ( course.visibility === 2 || course.visibility === 3 )"
125125 :to =" { name: 'CourseHome', params: { id: course.id } }"
126126 >
127127 <Button
132132 </router-link >
133133
134134 <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"
136144 :label =" $t('Subscribe')"
137145 icon =" pi pi-sign-in"
138146 class =" w-full"
139147 @click =" subscribeToCourse"
140148 />
141149
142150 <Button
143- v-else-if =" course.visibility === 2 && !course.subscribe && !isUserInCourse "
151+ v-else-if =" course.visibility === 2 && !course.subscribe && props.currentUserId "
144152 :label =" $t('Subscription not allowed')"
145153 icon =" pi pi-ban"
146154 disabled
165173 </div >
166174 </div >
167175 </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+ />
168183 <Dialog
169184 v-model:visible =" showDescriptionDialog"
170185 :header =" course.title"
179194<script setup>
180195import Rating from " primevue/rating"
181196import 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 "
184199import { useRoute , useRouter } from " vue-router"
185200import { useNotification } from " ../../composables/notification"
186- import Dialog from " primevue/dialog"
187201import { usePlatformConfig } from " ../../store/platformConfig"
202+ import CatalogueRequirementModal from " ./CatalogueRequirementModal.vue"
203+ import courseRelUserService from " ../../services/courseRelUserService"
204+ import { useCourseRequirementStatus } from " ../../composables/course/useCourseRequirementStatus"
188205import { useLocale } from " ../../composables/locale"
189- const platformConfigStore = usePlatformConfig ()
190- const showDescriptionDialog = ref (false )
191206const { getOriginalLanguageName } = useLocale ()
192207
193- const allowDescription = computed (
194- () => platformConfigStore .getSetting (" course.show_courses_descriptions_in_catalog" ) !== " false" ,
195- )
196-
197208const props = defineProps ({
198209 course: Object ,
199210 currentUserId: {
@@ -212,6 +223,14 @@ const emit = defineEmits(["rate", "subscribed"])
212223const router = useRouter ()
213224const route = useRoute ()
214225const { 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+ )
215234
216235const isUserInCourse = computed (() => {
217236 if (! props .currentUserId ) return false
@@ -287,9 +306,7 @@ function routeExists(name) {
287306
288307const linkSettings = computed (() => {
289308 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 ?? {}
293310})
294311
295312const imageLink = computed (() => {
@@ -304,10 +321,6 @@ const imageLink = computed(() => {
304321 return { name: routeName, params: { id: props .course .id } }
305322 }
306323
307- if (routeName) {
308- console .warn (` [CatalogueCourseCard] Route '${ routeName} ' does not exist.` )
309- }
310-
311324 return null
312325})
313326
@@ -318,20 +331,21 @@ const titleLink = computed(() => {
318331 return { name: routeName, params: { id: props .course .id } }
319332 }
320333
321- if (routeName) {
322- console .warn (` [CatalogueCourseCard] Route '${ routeName} ' does not exist.` )
323- }
324-
325334 return null
326335})
327336
328337const showInfoPopup = computed (() => {
329338 const allowed = [" course_description_popup" ]
330339 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 ()
336350})
337351< / script>
0 commit comments