From b17d289bdae3f0ef104e9e9d4d75068c61f153b6 Mon Sep 17 00:00:00 2001 From: scmmishra Date: Thu, 28 Feb 2019 15:21:43 +0530 Subject: [PATCH] fix: Course card progress --- .../education/lms/components/CourseCard.vue | 49 +++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/erpnext/public/js/education/lms/components/CourseCard.vue b/erpnext/public/js/education/lms/components/CourseCard.vue index 29e2b67f88..b9cb548ef0 100644 --- a/erpnext/public/js/education/lms/components/CourseCard.vue +++ b/erpnext/public/js/education/lms/components/CourseCard.vue @@ -14,12 +14,12 @@
- - View Course + {{ buttonName }}
@@ -36,10 +36,53 @@ export default { components: { AButton }, + data() { + return { + courseMeta: {}, + } + }, + mounted() { + if(lms.store.checkLogin()) this.getCourseMeta().then(data => this.courseMeta = data) + }, computed: { courseRoute() { return `${this.program_name}/${this.course.name}` }, + buttonType() { + if(lms.store.checkProgramEnrollment(this.program_name)){ + if (this.courseMeta.flag == "Start Course" ){ + return "primary" + } + else if (this.courseMeta.flag == "Completed" ) { + return "success" + } + else if (this.courseMeta.flag == "Continue" ) { + return "info" + } + } + else { + return " hidden" + } + }, + isLogin() { + return lms.store.checkLogin() + }, + buttonName() { + if(lms.store.checkLogin()){ + return this.courseMeta.flag + } + else { + return "Enroll" + } + } + }, + methods: { + getCourseMeta() { + return lms.call('get_course_meta', { + course_name: this.course.name, + program_name: this.program_name + }) + }, } };