brotherton-erpnext/erpnext/public/js/education/lms/components/CourseCard.vue

96 lines
2.7 KiB
Vue
Raw Normal View History

2018-11-01 11:49:53 +00:00
<template>
<div class="card mt-3" data-list="getting-started">
<div class='card-body'>
<div class="row">
<div class="course-details col-xs-8 col-sm-9 col-md-10">
<h5 class="card-title">{{ course.course_name }}</h5>
<span class="course-list text-muted" id="getting-started">
2018-12-17 08:26:27 +00:00
Topics
2018-11-01 11:49:53 +00:00
<ul class="mb-0 mt-1">
2019-02-26 11:17:54 +00:00
<li v-for="topic in course.topics" :key="topic.name">
2018-12-17 08:26:27 +00:00
<div><span style="padding-right: 0.4em"></span>{{ topic.topic_name }}</div>
2018-11-21 09:51:57 +00:00
</li>
2018-11-01 11:49:53 +00:00
</ul>
</span>
</div>
2018-11-12 07:20:54 +00:00
<div class='course-buttons text-center col-xs-4 col-sm-3 col-md-2'>
<a-button
2019-02-28 09:51:43 +00:00
:type="buttonType"
2018-11-12 07:20:54 +00:00
size="sm btn-block"
2018-12-17 08:26:27 +00:00
:route="courseRoute"
2018-11-09 06:17:09 +00:00
>
2019-02-28 09:51:43 +00:00
{{ buttonName }}
2018-11-09 06:17:09 +00:00
</a-button>
2018-11-01 11:49:53 +00:00
</div>
</div>
</div>
</div>
</template>
<script>
2018-11-12 07:20:54 +00:00
import AButton from './Button.vue';
2018-11-02 15:21:24 +00:00
2018-11-01 11:49:53 +00:00
export default {
2018-11-22 10:03:30 +00:00
props: ['course', 'program_name'],
2018-11-13 11:54:07 +00:00
name: "CourseCard",
2018-11-02 15:21:24 +00:00
components: {
2018-11-09 06:17:09 +00:00
AButton
},
2019-02-28 09:51:43 +00:00
data() {
return {
courseMeta: {},
}
},
mounted() {
if(lms.store.checkLogin()) this.getCourseMeta().then(data => this.courseMeta = data)
},
2018-11-09 06:17:09 +00:00
computed: {
2018-12-17 08:26:27 +00:00
courseRoute() {
return `${this.program_name}/${this.course.name}`
},
2019-02-28 09:51:43 +00:00
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 09:51:43 +00:00
}
},
isLogin() {
return lms.store.checkLogin()
},
buttonName() {
if(lms.store.checkProgramEnrollment(this.program_name)){
2019-02-28 09:51:43 +00:00
return this.courseMeta.flag
}
else {
return "Explore"
2019-02-28 09:51:43 +00:00
}
}
},
methods: {
getCourseMeta() {
return lms.call('get_course_meta', {
course_name: this.course.name,
program_name: this.program_name
})
},
2018-11-01 11:49:53 +00:00
}
};
</script>
<style scoped>
@media only screen and (max-width: 576px) {
2018-11-21 09:51:57 +00:00
.course-buttons {
margin-top: 1em;
}
}
2018-11-01 11:49:53 +00:00
</style>