Refactored lms store
This commit is contained in:
parent
0a5c7a6b46
commit
53c2d5db63
@ -63,7 +63,7 @@ export default {
|
|||||||
return this.programRoute
|
return this.programRoute
|
||||||
},
|
},
|
||||||
isEnrolled() {
|
isEnrolled() {
|
||||||
return lms.store.enrolledPrograms.has(this.program.name)
|
return lms.store.enrolledPrograms.includes(this.program.name)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
@ -28,7 +28,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
computeButtons(){
|
computeButtons(){
|
||||||
if(this.isLoggedIn){
|
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'){
|
if(this.$route.name == 'home'){
|
||||||
this.buttonName = 'Explore Courses'
|
this.buttonName = 'Explore Courses'
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ export default {
|
|||||||
if(this.$route.name == 'home'){
|
if(this.$route.name == 'home'){
|
||||||
return
|
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}})
|
this.$router.push({ name: 'content', params: { program_name: this.$route.params.program_name, course: this.nextCourse, type: this.nextContentType, content: this.nextContent}})
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -9,7 +9,7 @@ Vue.use(VueRouter)
|
|||||||
|
|
||||||
var store = {
|
var store = {
|
||||||
isLogin: false,
|
isLogin: false,
|
||||||
enrolledPrograms: new Set(),
|
enrolledPrograms: [],
|
||||||
enrolledCourses: {}
|
enrolledCourses: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,11 +23,7 @@ frappe.ready(() => {
|
|||||||
updateEnrolledPrograms() {
|
updateEnrolledPrograms() {
|
||||||
if(this.isLogin) {
|
if(this.isLogin) {
|
||||||
lms.call("get_program_enrollments").then(data => {
|
lms.call("get_program_enrollments").then(data => {
|
||||||
if(data){
|
if(data) this.enrolledPrograms = data
|
||||||
data.forEach(element => {
|
|
||||||
this.enrolledPrograms.add(element)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
if (lms.debug) console.log('Updated Enrolled Programs', this.enrolledPrograms)
|
if (lms.debug) console.log('Updated Enrolled Programs', this.enrolledPrograms)
|
||||||
}
|
}
|
||||||
|
@ -40,17 +40,17 @@ export default {
|
|||||||
// });
|
// });
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
startCourse() {
|
// startCourse() {
|
||||||
this.getContentForNextCourse()
|
// this.getContentForNextCourse()
|
||||||
.then((data) =>
|
// .then((data) =>
|
||||||
this.$router.push(`/Program/${this.program_name}/${data.course}/${data.content_type}/${data.content}`)
|
// this.$router.push(`/Program/${this.program_name}/${data.course}/${data.content_type}/${data.content}`)
|
||||||
)
|
// )
|
||||||
},
|
// },
|
||||||
getContentForNextCourse() {
|
// getContentForNextCourse() {
|
||||||
return lms.call('get_continue_data', {
|
// return lms.call('get_continue_data', {
|
||||||
program_name: this.program_name
|
// program_name: this.program_name
|
||||||
});
|
// });
|
||||||
},
|
// },
|
||||||
getProgramDetails() {
|
getProgramDetails() {
|
||||||
return lms.call('get_program_details', {
|
return lms.call('get_program_details', {
|
||||||
program_name: this.program_name
|
program_name: this.program_name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user