brotherton-erpnext/erpnext/public/js/education/academy/components/AcademyProgramCard.vue

76 lines
2.2 KiB
Vue
Raw Normal View History

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>&nbsp;&nbsp; -->
2018-11-09 12:55:19 +00:00
<a-button
v-if="enrolled"
type="primary"
size="sm"
:route="programPageRoute"
>
{{ buttonName }}
</a-button>
<a v-else-if="isLogin" class='btn btn-secondary btn-sm' @click="enroll()">Enroll</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>
2018-11-09 12:55:19 +00:00
import AButton from './Button.vue';
2018-10-30 12:55:49 +00:00
export default {
2018-11-09 12:55:19 +00:00
props: ['program', 'enrolled'],
2018-10-30 12:55:49 +00:00
name: "AcademyProgramCard",
data() {
return {
2018-11-09 12:55:19 +00:00
isLogin: academy.store.isLogin
2018-10-30 12:55:49 +00:00
};
},
2018-11-09 12:55:19 +00:00
created() {
2018-10-30 12:55:49 +00:00
},
2018-11-03 12:33:24 +00:00
methods: {
enroll() {
2018-11-09 12:55:19 +00:00
academy.call('enroll_in_program', {
program_name: this.program.name,
}).then(
academy.store.enrolledPrograms.add(this.program.name),
academy.store.updateEnrolledPrograms(),
this.router.push('Program/' + this.program.name)
)
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() {
2018-11-09 12:55:19 +00:00
if(this.enrolled){
2018-11-08 07:31:55 +00:00
return "Start Course"
}
else {
return "Enroll"
}
2018-11-09 12:55:19 +00:00
},
programPageRoute() {
return `Program/${this.program.name}`
},
isEnrolled() {
return academy.store.enrolledPrograms.has(this.program.name)
2018-11-03 12:33:24 +00:00
}
2018-11-09 12:55:19 +00:00
},
components: {
AButton
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>