Refactored lms store
This commit is contained in:
parent
0a5c7a6b46
commit
53c2d5db63
@ -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: {
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user