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

99 lines
3.1 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">
Course Content
<ul class="mb-0 mt-1">
2018-11-21 09:51:57 +00:00
<li v-for="content in course.course_content" :key="content.name">
2018-11-24 15:01:35 +00:00
<router-link v-if="isLogin" tag="a" :class="'text-muted'" :to="{name: 'content', params:{program_name: program_name, course: course.name, type:content.content_type, content: content.content} }">
2018-11-21 09:51:57 +00:00
<span style="padding-right: 0.4em"><i :class="iconClass(content.content_type)"></i></span>{{ content.content }}
</router-link>
2018-11-24 15:01:35 +00:00
<div v-else><span style="padding-right: 0.4em"><i :class="iconClass(content.content_type)"></i></span>{{ content.content }}</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'>
2018-11-09 06:17:09 +00:00
<a-button
2018-11-12 07:20:54 +00:00
:type="buttonType"
size="sm btn-block"
2018-11-09 06:17:09 +00:00
:route="firstContentRoute"
>
2018-11-12 07:20:54 +00:00
{{ courseMeta.flag }}
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-22 10:03:30 +00:00
data() {
return {
courseMeta: {}
}
},
mounted() {
2018-11-26 06:29:12 +00:00
this.getCourseMeta().then(data => this.courseMeta = data)
2018-11-22 10:03:30 +00:00
},
2018-11-02 15:21:24 +00:00
components: {
2018-11-09 06:17:09 +00:00
AButton
},
computed: {
firstContentRoute() {
2018-11-12 07:20:54 +00:00
return `${this.program_name}/${this.course.name}/${this.courseMeta.content_type}/${this.courseMeta.content}`
},
buttonType() {
2018-11-20 13:07:01 +00:00
if (this.courseMeta.flag == "Start Course" ){
2018-11-12 07:20:54 +00:00
return "primary"
}
else if (this.courseMeta.flag == "Complete" ) {
return "success"
}
2018-11-13 06:52:49 +00:00
else if (this.courseMeta.flag == "Continue" ) {
2018-11-12 07:20:54 +00:00
return "info"
}
2018-11-13 06:52:49 +00:00
else {
return " hidden"
}
2018-11-26 06:29:12 +00:00
},
isLogin() {
return lms.store.checkLogin()
2018-11-09 06:17:09 +00:00
}
2018-11-21 09:51:57 +00:00
},
methods: {
iconClass(content_type) {
if(content_type == 'Video') return 'fa fa-play'
if(content_type == 'Article') return 'fa fa-file-text-o'
if(content_type == 'Quiz') return 'fa fa-question-circle-o'
2018-11-22 10:03:30 +00:00
},
getCourseMeta() {
return lms.call('get_course_meta', {
course_name: this.course.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;
}
}
li {
list-style-type: none;
}
.fa {
font-size: 0.8em;
2018-11-01 11:49:53 +00:00
}
</style>