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

84 lines
2.6 KiB
Vue
Raw Normal View History

2018-10-30 12:55:49 +00:00
<template>
2019-03-28 10:02:54 +00:00
<div class='mt-3'>
2018-10-30 12:55:49 +00:00
<div class="card">
<div class="card-hero-img" v-if="program.hero_image" v-bind:style="{ 'background-image': 'url(' + image + ')' }"></div>
2018-10-30 12:55:49 +00:00
<div class='card-body'>
<router-link :to="'/Program/' + program.name">
2018-11-01 11:49:21 +00:00
<h5 class='card-title'>{{ program.program_name }}</h5>
2018-10-30 12:55:49 +00:00
</router-link>
<div v-html="program.description"></div>
</div>
2019-02-26 11:18:12 +00:00
<div class='text-right p-3'>
2019-03-28 10:02:54 +00:00
<button v-if="program.intro_video" class='btn btn-secondary btn-sm text-white' data-toggle="modal" data-target="#videoModal">Watch Intro</button>
2019-03-27 12:44:41 +00:00
<a-button v-if="enrolled" type="dark" size="sm" :route="programPageRoute">
2019-03-28 06:50:24 +00:00
{{ buttonName }}
2018-11-09 12:55:19 +00:00
</a-button>
2018-11-15 05:43:56 +00:00
<a v-else-if="isLogin" class='btn btn-secondary btn-sm' @click="enroll()">{{ enrollButton }}</a>
2018-11-05 05:31:37 +00:00
<a v-else class='btn btn-secondary btn-sm' href="/login#signup">Sign Up</a>
2018-10-30 12:55:49 +00:00
</div>
2019-03-28 10:02:54 +00:00
<VideoModal v-if="program.intro_video" :title="program.program_name" :video="program.intro_video"/>
2018-10-30 12:55:49 +00:00
</div>
</div>
</template>
<script>
2018-11-09 12:55:19 +00:00
import AButton from './Button.vue';
2019-03-28 06:50:24 +00:00
import VideoModal from './VideoModal.vue';
2018-10-30 12:55:49 +00:00
export default {
2018-11-09 12:55:19 +00:00
props: ['program', 'enrolled'],
2018-11-13 11:54:07 +00:00
name: "ProgramCard",
2018-10-30 12:55:49 +00:00
data() {
return {
2019-02-26 11:18:12 +00:00
isLogin: frappe.is_user_logged_in(),
2018-11-15 05:43:56 +00:00
enrollButton: 'Enroll Now',
programRoute: { name: 'program', params: { program_name: this.program.name }},
image: "'" + this.program.hero_image + "'"
2018-10-30 12:55:49 +00:00
};
},
2018-11-03 12:33:24 +00:00
methods: {
enroll() {
2018-11-15 05:43:56 +00:00
this.enrollButton = 'Enrolling...'
2018-11-13 11:17:46 +00:00
lms.call('enroll_in_program', {
2018-11-09 12:55:19 +00:00
program_name: this.program.name,
2018-11-15 05:43:56 +00:00
}).then(data => {
2018-11-23 11:46:33 +00:00
lms.store.updateEnrolledPrograms()
2018-11-15 05:43:56 +00:00
this.$router.push(this.programRoute)
})
2018-11-08 07:31:55 +00:00
}
2018-11-09 06:17:09 +00:00
},
2018-11-08 07:31:55 +00:00
computed: {
buttonName() {
2019-03-27 12:44:41 +00:00
if(this.enrolled){
2019-03-28 10:02:54 +00:00
return "Start Program"
2019-03-27 12:44:41 +00:00
}
else {
return "Enroll"
}
2018-11-09 12:55:19 +00:00
},
programPageRoute() {
2018-11-15 05:43:56 +00:00
return this.programRoute
2018-11-09 12:55:19 +00:00
},
isEnrolled() {
2018-11-19 11:38:40 +00:00
return lms.store.enrolledPrograms.includes(this.program.name)
2018-11-03 12:33:24 +00:00
}
2018-11-09 12:55:19 +00:00
},
components: {
2019-03-28 06:50:24 +00:00
AButton,
VideoModal
2018-11-03 12:33:24 +00:00
}
2018-10-30 12:55:49 +00:00
};
2018-11-01 11:49:21 +00:00
</script>
<style lang="css" scoped>
a {
2018-11-15 05:43:56 +00:00
text-decoration: none;
2019-02-26 11:18:12 +00:00
color: black;
2018-11-15 05:43:56 +00:00
}
a.btn-secondary {
color: white !important;
}
div.card-hero-img {
height: 220px;
background-position: center
}
2018-11-01 11:49:21 +00:00
</style>