2018-10-30 12:55:49 +00:00
|
|
|
<template>
|
|
|
|
<div class='card-deck mt-5'>
|
|
|
|
<div class="card">
|
2018-11-01 11:49:21 +00:00
|
|
|
<img :src="program.hero_image" style='height: 150px; width: auto'>
|
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>
|
|
|
|
<div class='card-footer text-right'>
|
|
|
|
<!-- <a class='video-btn btn btn-secondary btn-sm' data-toggle="modal" data-src=" insert jinja stuff here " data-target="#myModal">Watch Intro</a> -->
|
2018-11-08 07:31:55 +00:00
|
|
|
<a v-if="this.$root.$data.isLogin" class='btn btn-secondary btn-sm' @click="primaryAction()">{{ buttonName }}</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>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
export default {
|
2018-11-01 11:49:21 +00:00
|
|
|
props: ['program_code'],
|
2018-10-30 12:55:49 +00:00
|
|
|
name: "AcademyProgramCard",
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
program: ''
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
frappe.call({
|
|
|
|
method: "erpnext.www.academy.get_program_details",
|
|
|
|
args: {
|
2018-11-01 11:49:21 +00:00
|
|
|
program_name: this.program_code
|
2018-10-30 12:55:49 +00:00
|
|
|
}
|
|
|
|
}).then(r => {
|
|
|
|
this.program = r.message
|
|
|
|
})
|
|
|
|
},
|
2018-11-03 12:33:24 +00:00
|
|
|
methods: {
|
2018-11-08 07:31:55 +00:00
|
|
|
primaryAction(){
|
|
|
|
if(this.$root.$data.isLogin){
|
|
|
|
if(this.$root.$data.checkProgramEnrollment(program_code)){
|
|
|
|
this.$router.push('/Program/' + program.name)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.enroll()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-11-03 12:33:24 +00:00
|
|
|
enroll() {
|
|
|
|
frappe.call({
|
2018-11-03 14:03:51 +00:00
|
|
|
method: "erpnext.www.academy.enroll_in_program",
|
2018-11-03 12:33:24 +00:00
|
|
|
args:{
|
2018-11-03 14:03:51 +00:00
|
|
|
program_name: this.program_code,
|
2018-11-03 12:33:24 +00:00
|
|
|
student_email_id: frappe.session.user
|
|
|
|
}
|
|
|
|
})
|
2018-11-08 07:31:55 +00:00
|
|
|
this.$root.$data.enrolledPrograms.add(this.program_code)
|
|
|
|
this.$root.$data.updateEnrolledPrograms()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
computed: {
|
|
|
|
buttonName() {
|
|
|
|
if(this.$root.$data.isLogin){
|
|
|
|
if(this.$root.$data.checkProgramEnrollment(program_code)){
|
|
|
|
return "Start Course"
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return "Enroll"
|
|
|
|
}
|
|
|
|
}
|
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 {
|
|
|
|
text-decoration: none;
|
|
|
|
}
|
|
|
|
</style>
|