2018-10-30 12:55:49 +00:00
|
|
|
<template>
|
2019-04-25 14:03:22 +00:00
|
|
|
<div class='py-3 col-md-4 col-sm-12'>
|
2019-03-31 14:16:39 +00:00
|
|
|
<div class="card h-100">
|
|
|
|
<router-link :to="'/Program/' + program.name">
|
|
|
|
<div class="card-hero-img" v-if="program.hero_image" v-bind:style="{ 'background-image': 'url(' + image + ')' }"></div>
|
2019-04-22 12:21:30 +00:00
|
|
|
<div v-else class="card-image-wrapper text-center">
|
2019-03-31 14:16:39 +00:00
|
|
|
<div class="image-body">{{ program.program_name }}</div>
|
|
|
|
</div>
|
|
|
|
<div class='card-body'>
|
2018-11-01 11:49:21 +00:00
|
|
|
<h5 class='card-title'>{{ program.program_name }}</h5>
|
2019-04-22 12:21:30 +00:00
|
|
|
<div class="text-muted">{{ program.description.substring(0,200) }}...</div>
|
2019-03-31 14:16:39 +00:00
|
|
|
</div>
|
|
|
|
</router-link>
|
2019-02-26 11:18:12 +00:00
|
|
|
<div class='text-right p-3'>
|
2019-04-08 14:26:21 +00:00
|
|
|
<button v-if="program.intro_video" class='btn btn-light btn-sm' 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>
|
2019-04-08 14:26:21 +00:00
|
|
|
<button v-else-if="isLogin" class='btn btn-dark btn-sm' @click="enroll()">{{ enrollButton }}</button>
|
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',
|
2019-03-28 08:45:30 +00:00
|
|
|
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;
|
|
|
|
}
|
2018-11-01 11:49:21 +00:00
|
|
|
</style>
|