122 lines
3.4 KiB
Vue
Raw Normal View History

2018-11-01 17:19:53 +05:30
<template>
2019-03-31 19:46:39 +05:30
<div class="mt-3 col-md-4 col-sm-12">
<div class="card h-100">
<div class="card-hero-img" v-if="course.hero_image" v-bind:style="{ 'background-image': 'url(' + image + ')' }"></div>
<div v-else class="card-image-wrapper">
<div class="image-body">{{ course.course_name }}</div>
</div>
<div class='card-body'>
2018-11-01 17:19:53 +05:30
<h5 class="card-title">{{ course.course_name }}</h5>
<span class="course-list text-muted" id="getting-started">
2018-12-17 13:56:27 +05:30
Topics
2018-11-01 17:19:53 +05:30
<ul class="mb-0 mt-1">
2019-02-26 16:47:54 +05:30
<li v-for="topic in course.topics" :key="topic.name">
2018-12-17 13:56:27 +05:30
<div><span style="padding-right: 0.4em"></span>{{ topic.topic_name }}</div>
2018-11-21 15:21:57 +05:30
</li>
2018-11-01 17:19:53 +05:30
</ul>
</span>
</div>
2019-03-31 19:46:39 +05:30
<div class='text-right p-3'>
<div class='course-buttons text-center'>
<a-button
:type="buttonType"
size="sm btn-block"
:route="courseRoute"
>
{{ buttonName }}
</a-button>
</div>
2018-11-01 17:19:53 +05:30
</div>
</div>
</div>
</template>
<script>
2018-11-12 12:50:54 +05:30
import AButton from './Button.vue';
2018-11-02 20:51:24 +05:30
2018-11-01 17:19:53 +05:30
export default {
2018-11-22 15:33:30 +05:30
props: ['course', 'program_name'],
2018-11-13 17:24:07 +05:30
name: "CourseCard",
2018-11-02 20:51:24 +05:30
components: {
2018-11-09 11:47:09 +05:30
AButton
},
2019-02-28 15:21:43 +05:30
data() {
return {
courseMeta: {},
}
},
mounted() {
if(lms.store.checkLogin()) this.getCourseMeta().then(data => this.courseMeta = data)
},
2018-11-09 11:47:09 +05:30
computed: {
2018-12-17 13:56:27 +05:30
courseRoute() {
return `${this.program_name}/${this.course.name}`
},
2019-02-28 15:21:43 +05:30
buttonType() {
if(lms.store.checkProgramEnrollment(this.program_name)){
if (this.courseMeta.flag == "Start Course" ){
return "primary"
}
else if (this.courseMeta.flag == "Completed" ) {
return "success"
}
else if (this.courseMeta.flag == "Continue" ) {
return "info"
}
}
else {
return "info"
2019-02-28 15:21:43 +05:30
}
},
isLogin() {
return lms.store.checkLogin()
},
buttonName() {
if(lms.store.checkProgramEnrollment(this.program_name)){
2019-02-28 15:21:43 +05:30
return this.courseMeta.flag
}
else {
return "Explore"
2019-02-28 15:21:43 +05:30
}
}
},
methods: {
getCourseMeta() {
return lms.call('get_course_meta', {
course_name: this.course.name,
program_name: this.program_name
})
},
2018-11-01 17:19:53 +05:30
}
};
</script>
<style scoped>
2019-03-31 19:46:39 +05:30
.course-buttons {
margin-bottom: 1em;
}
div.card-hero-img {
height: 220px;
background-size: cover;
background-repeat: no-repeat;
background-position: center;
background-color: rgb(250, 251, 252);
}
.card-image-wrapper {
display: flex;
overflow: hidden;
height: 220px;
background-color: rgb(250, 251, 252);
}
.image-body {
align-self: center;
color: #d1d8dd;
font-size: 24px;
font-weight: 600;
line-height: 1;
padding: 20px;
2018-11-21 15:21:57 +05:30
}
2018-11-01 17:19:53 +05:30
</style>