brotherton-erpnext/erpnext/public/js/education/web-academy/components/AcademyTopSectionButton.vue

56 lines
1.7 KiB
Vue
Raw Normal View History

2018-11-03 09:18:42 +00:00
<template>
2018-11-03 12:33:01 +00:00
<button v-if="isLoggedIn" class='btn btn-primary btn-lg' @click="$router.push(getUrl())">{{ 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 {
name: "AcademyTopSectionButton",
data() {
return {
buttonName: '',
2018-11-03 12:33:01 +00:00
isLoggedIn: this.$root.$data.checkLogin(),
nextContent: '',
nextContentType: '',
nextCourse: '',
link: '',
2018-11-03 09:18:42 +00:00
}
},
mounted() {
2018-11-03 12:33:01 +00:00
if(this.isLoggedIn && this.$route.name == 'program'){
frappe.call({
method: "erpnext.www.academy.get_continue_data",
args: {
program_name: this.$route.params.code
}
}).then( r => {
this.nextContent = r.message.content,
this.nextContentType = r.message.content_type,
this.nextCourse = r.message.course
})
}
if(this.isLoggedIn){
2018-11-03 10:44:34 +00:00
if(this.$route.name == 'home'){
this.buttonName = 'Explore Courses'
}
else if(this.$route.name == 'program'){
this.buttonName = 'Start Course'
}
}
else{
this.buttonName = 'Sign Up'
}
},
methods: {
getUrl() {
if(this.$route.name == 'home'){
return ''
}
else if(this.$route.name == 'program'){
2018-11-03 12:33:01 +00:00
this.link = this.$route.params.code + '/' + this.nextCourse + '/' + this.nextContentType + '/' + this.nextContent
return this.link
2018-11-03 09:18:42 +00:00
}
}
}
};
</script>