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

74 lines
2.6 KiB
Vue
Raw Normal View History

2018-11-03 09:18:42 +00:00
<template>
2018-11-07 16:42:55 +00:00
<button v-if="isLoggedIn" class='btn btn-primary btn-lg' @click="primaryAction()">{{ buttonName }}</button>
2018-11-03 10:44:34 +00:00
<a v-else class='btn btn-primary btn-lg' href="/login#signup">{{ buttonName }}</a>
2018-11-03 09:18:42 +00:00
</template>
<script>
export default {
2018-11-13 11:54:07 +00:00
name: "TopSectionButton",
2018-11-03 09:18:42 +00:00
data() {
return {
buttonName: '',
2018-11-13 11:17:46 +00:00
isLoggedIn: lms.store.checkLogin(),
2018-11-03 12:33:01 +00:00
nextContent: '',
nextContentType: '',
nextCourse: '',
link: '',
2018-11-03 09:18:42 +00:00
}
},
mounted() {
2018-11-20 13:07:01 +00:00
// if(this.isLoggedIn && this.$route.name == 'program'){
// this.getContinueData().then( data => {
// this.nextContent = data.content,
// this.nextContentType = data.content_type,
// this.nextCourse = data.course
// })
// }
2018-11-19 09:42:39 +00:00
this.computeButtons()
},
methods: {
computeButtons(){
if(this.isLoggedIn){
2018-11-19 11:38:40 +00:00
if(lms.store.enrolledPrograms.includes(this.$route.params.program_name)){
2018-11-19 09:42:39 +00:00
if(this.$route.name == 'home'){
this.buttonName = 'Explore Courses'
}
2018-11-20 13:07:01 +00:00
// else if(this.$route.name == 'program'){
// this.buttonName = 'Start Course'
// }
2018-11-19 09:42:39 +00:00
}
else {
this.buttonName = 'Enroll Now'
2018-11-07 16:42:55 +00:00
}
}
2018-11-19 09:42:39 +00:00
else{
this.buttonName = 'Sign Up'
2018-11-03 10:44:34 +00:00
}
2018-11-19 09:42:39 +00:00
},
2018-11-20 13:07:01 +00:00
// getContinueData() {
// lms.call({
// method: "get_continue_data",
// args: {
// program_name: this.$route.params.program_name
// }
// })
// },
2018-11-07 16:42:55 +00:00
primaryAction() {
2018-11-03 10:44:34 +00:00
if(this.$route.name == 'home'){
2018-11-07 16:42:55 +00:00
return
2018-11-03 10:44:34 +00:00
}
2018-11-19 11:38:40 +00:00
else if(this.$route.name == 'program' && lms.store.enrolledPrograms.includes(this.$route.params.program_name)){
2018-11-12 07:20:54 +00:00
this.$router.push({ name: 'content', params: { program_name: this.$route.params.program_name, course: this.nextCourse, type: this.nextContentType, content: this.nextContent}})
2018-11-03 09:18:42 +00:00
}
2018-11-07 16:42:55 +00:00
else {
2018-11-20 12:06:57 +00:00
lms.call("enroll_in_program",
{
program_name: this.$route.params.program_name,
student_email_id: frappe.session.user
}
)
2018-11-13 11:17:46 +00:00
lms.store.updateEnrolledPrograms()
2018-11-07 16:42:55 +00:00
}
},
2018-11-03 09:18:42 +00:00
}
};
</script>