106 lines
3.2 KiB
Vue
Raw Normal View History

2018-10-30 18:25:49 +05:30
<template>
2019-03-31 19:46:39 +05:30
<div class='mt-3 col-md-4 col-sm-12'>
<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>
<div v-else class="card-image-wrapper">
<div class="image-body">{{ program.program_name }}</div>
</div>
<div class='card-body'>
2018-11-01 17:19:21 +05:30
<h5 class='card-title'>{{ program.program_name }}</h5>
2019-03-31 19:46:39 +05:30
<div>{{ program.description.substring(0,200) }}...</div>
</div>
</router-link>
2019-02-26 16:48:12 +05:30
<div class='text-right p-3'>
2019-03-28 15:32:54 +05:30
<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 18:14:41 +05:30
<a-button v-if="enrolled" type="dark" size="sm" :route="programPageRoute">
2019-03-28 12:20:24 +05:30
{{ buttonName }}
2018-11-09 18:25:19 +05:30
</a-button>
2018-11-15 11:13:56 +05:30
<a v-else-if="isLogin" class='btn btn-secondary btn-sm' @click="enroll()">{{ enrollButton }}</a>
2018-11-05 11:01:37 +05:30
<a v-else class='btn btn-secondary btn-sm' href="/login#signup">Sign Up</a>
2018-10-30 18:25:49 +05:30
</div>
2019-03-28 15:32:54 +05:30
<VideoModal v-if="program.intro_video" :title="program.program_name" :video="program.intro_video"/>
2018-10-30 18:25:49 +05:30
</div>
</div>
</template>
<script>
2018-11-09 18:25:19 +05:30
import AButton from './Button.vue';
2019-03-28 12:20:24 +05:30
import VideoModal from './VideoModal.vue';
2018-10-30 18:25:49 +05:30
export default {
2018-11-09 18:25:19 +05:30
props: ['program', 'enrolled'],
2018-11-13 17:24:07 +05:30
name: "ProgramCard",
2018-10-30 18:25:49 +05:30
data() {
return {
2019-02-26 16:48:12 +05:30
isLogin: frappe.is_user_logged_in(),
2018-11-15 11:13:56 +05:30
enrollButton: 'Enroll Now',
programRoute: { name: 'program', params: { program_name: this.program.name }},
image: "'" + this.program.hero_image + "'"
2018-10-30 18:25:49 +05:30
};
},
2018-11-03 18:03:24 +05:30
methods: {
enroll() {
2018-11-15 11:13:56 +05:30
this.enrollButton = 'Enrolling...'
2018-11-13 16:47:46 +05:30
lms.call('enroll_in_program', {
2018-11-09 18:25:19 +05:30
program_name: this.program.name,
2018-11-15 11:13:56 +05:30
}).then(data => {
2018-11-23 17:16:33 +05:30
lms.store.updateEnrolledPrograms()
2018-11-15 11:13:56 +05:30
this.$router.push(this.programRoute)
})
2018-11-08 13:01:55 +05:30
}
2018-11-09 11:47:09 +05:30
},
2018-11-08 13:01:55 +05:30
computed: {
buttonName() {
2019-03-27 18:14:41 +05:30
if(this.enrolled){
2019-03-28 15:32:54 +05:30
return "Start Program"
2019-03-27 18:14:41 +05:30
}
else {
return "Enroll"
}
2018-11-09 18:25:19 +05:30
},
programPageRoute() {
2018-11-15 11:13:56 +05:30
return this.programRoute
2018-11-09 18:25:19 +05:30
},
isEnrolled() {
2018-11-19 17:08:40 +05:30
return lms.store.enrolledPrograms.includes(this.program.name)
2018-11-03 18:03:24 +05:30
}
2018-11-09 18:25:19 +05:30
},
components: {
2019-03-28 12:20:24 +05:30
AButton,
VideoModal
2018-11-03 18:03:24 +05:30
}
2018-10-30 18:25:49 +05:30
};
2018-11-01 17:19:21 +05:30
</script>
<style lang="css" scoped>
a {
2018-11-15 11:13:56 +05:30
text-decoration: none;
2019-02-26 16:48:12 +05:30
color: black;
2018-11-15 11:13:56 +05:30
}
a.btn-secondary {
color: white !important;
}
div.card-hero-img {
height: 220px;
2019-03-31 19:46:39 +05:30
background-size: cover;
background-repeat: no-repeat;
background-position: center;
background-color: rgb(250, 251, 252);
}
.card-image-wrapper {
display: flex;
overflow: hidden;
height: 220px;
background-color: rgb(250, 251, 252);
}
.image-body {
align-self: center;
color: #d1d8dd;
font-size: 24px;
font-weight: 600;
line-height: 1;
padding: 20px;
}
2018-11-01 17:19:21 +05:30
</style>