From 53c2d5db63623e170d64b1fba982e28db29b0565 Mon Sep 17 00:00:00 2001 From: scmmishra Date: Mon, 19 Nov 2018 17:08:40 +0530 Subject: [PATCH] Refactored lms store --- .../education/lms/components/ProgramCard.vue | 2 +- .../lms/components/TopSectionButton.vue | 4 ++-- erpnext/public/js/education/lms/lms.js | 8 ++----- .../js/education/lms/pages/ProgramPage.vue | 22 +++++++++---------- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/erpnext/public/js/education/lms/components/ProgramCard.vue b/erpnext/public/js/education/lms/components/ProgramCard.vue index d0df94dad0f..53905aa3534 100644 --- a/erpnext/public/js/education/lms/components/ProgramCard.vue +++ b/erpnext/public/js/education/lms/components/ProgramCard.vue @@ -63,7 +63,7 @@ export default { return this.programRoute }, isEnrolled() { - return lms.store.enrolledPrograms.has(this.program.name) + return lms.store.enrolledPrograms.includes(this.program.name) } }, components: { diff --git a/erpnext/public/js/education/lms/components/TopSectionButton.vue b/erpnext/public/js/education/lms/components/TopSectionButton.vue index 895cae8be0f..40ec4e5d67c 100644 --- a/erpnext/public/js/education/lms/components/TopSectionButton.vue +++ b/erpnext/public/js/education/lms/components/TopSectionButton.vue @@ -28,7 +28,7 @@ export default { methods: { computeButtons(){ if(this.isLoggedIn){ - if(lms.store.enrolledPrograms.has(this.$route.params.program_name)){ + if(lms.store.enrolledPrograms.includes(this.$route.params.program_name)){ if(this.$route.name == 'home'){ this.buttonName = 'Explore Courses' } @@ -56,7 +56,7 @@ export default { if(this.$route.name == 'home'){ return } - else if(this.$route.name == 'program' && lms.store.enrolledPrograms.has(this.$route.params.program_name)){ + else if(this.$route.name == 'program' && lms.store.enrolledPrograms.includes(this.$route.params.program_name)){ this.$router.push({ name: 'content', params: { program_name: this.$route.params.program_name, course: this.nextCourse, type: this.nextContentType, content: this.nextContent}}) } else { diff --git a/erpnext/public/js/education/lms/lms.js b/erpnext/public/js/education/lms/lms.js index 62cfcc2240f..8914e7bf768 100644 --- a/erpnext/public/js/education/lms/lms.js +++ b/erpnext/public/js/education/lms/lms.js @@ -9,7 +9,7 @@ Vue.use(VueRouter) var store = { isLogin: false, - enrolledPrograms: new Set(), + enrolledPrograms: [], enrolledCourses: {} } @@ -23,11 +23,7 @@ frappe.ready(() => { updateEnrolledPrograms() { if(this.isLogin) { lms.call("get_program_enrollments").then(data => { - if(data){ - data.forEach(element => { - this.enrolledPrograms.add(element) - }) - } + if(data) this.enrolledPrograms = data }); if (lms.debug) console.log('Updated Enrolled Programs', this.enrolledPrograms) } diff --git a/erpnext/public/js/education/lms/pages/ProgramPage.vue b/erpnext/public/js/education/lms/pages/ProgramPage.vue index 6fde566ea5b..1c90f73ac00 100644 --- a/erpnext/public/js/education/lms/pages/ProgramPage.vue +++ b/erpnext/public/js/education/lms/pages/ProgramPage.vue @@ -40,17 +40,17 @@ export default { // }); }, methods: { - startCourse() { - this.getContentForNextCourse() - .then((data) => - this.$router.push(`/Program/${this.program_name}/${data.course}/${data.content_type}/${data.content}`) - ) - }, - getContentForNextCourse() { - return lms.call('get_continue_data', { - program_name: this.program_name - }); - }, + // startCourse() { + // this.getContentForNextCourse() + // .then((data) => + // this.$router.push(`/Program/${this.program_name}/${data.course}/${data.content_type}/${data.content}`) + // ) + // }, + // getContentForNextCourse() { + // return lms.call('get_continue_data', { + // program_name: this.program_name + // }); + // }, getProgramDetails() { return lms.call('get_program_details', { program_name: this.program_name