fix: program title rename and program overlay
This commit is contained in:
@@ -176,6 +176,7 @@
|
|||||||
import {
|
import {
|
||||||
Breadcrumbs,
|
Breadcrumbs,
|
||||||
Button,
|
Button,
|
||||||
|
call,
|
||||||
createDocumentResource,
|
createDocumentResource,
|
||||||
Dialog,
|
Dialog,
|
||||||
FormControl,
|
FormControl,
|
||||||
@@ -305,25 +306,14 @@ const updateOrder = (e) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const saveProgram = () => {
|
const saveProgram = () => {
|
||||||
program.setValue.submit(
|
call('frappe.model.rename_doc.update_document_title', {
|
||||||
{
|
doctype: 'LMS Program',
|
||||||
title: program.doc.title,
|
docname: program.doc.name,
|
||||||
program_courses: program.doc.program_courses,
|
name: program.doc.title,
|
||||||
program_members: program.doc.program_members,
|
}).then((data) => {
|
||||||
},
|
console.log(data)
|
||||||
{
|
router.push({ name: 'ProgramForm', params: { programName: data } })
|
||||||
onSuccess(data) {
|
|
||||||
router.push({
|
|
||||||
name: 'ProgramsForm',
|
|
||||||
params: { programName: data.name },
|
|
||||||
})
|
})
|
||||||
showToast(__('Success'), __('Program saved successfully'), 'check')
|
|
||||||
},
|
|
||||||
onError(err) {
|
|
||||||
showToast('Error', err.messages?.[0] || err, 'x')
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const courseColumns = computed(() => {
|
const courseColumns = computed(() => {
|
||||||
|
|||||||
@@ -61,12 +61,23 @@
|
|||||||
v-if="program.courses?.length"
|
v-if="program.courses?.length"
|
||||||
class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-5 mt-5"
|
class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-5 mt-5"
|
||||||
>
|
>
|
||||||
|
<div v-for="course in program.courses" class="relative group">
|
||||||
<CourseCard
|
<CourseCard
|
||||||
v-for="course in program.courses"
|
|
||||||
:course="course"
|
:course="course"
|
||||||
@click="enrollMember(program.name, course.name)"
|
@click="enrollMember(program.name, course.name)"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
/>
|
/>
|
||||||
|
<div
|
||||||
|
v-if="lockCourse(course)"
|
||||||
|
class="absolute inset-0 bg-black-overlay-500 opacity-60 rounded-md"
|
||||||
|
></div>
|
||||||
|
<div
|
||||||
|
v-if="lockCourse(course)"
|
||||||
|
class="absolute inset-0 flex items-center justify-center"
|
||||||
|
>
|
||||||
|
<LockKeyhole class="size-10 text-white" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="text-sm italic text-gray-600 mt-4">
|
<div v-else class="text-sm italic text-gray-600 mt-4">
|
||||||
{{ __('No courses in this program') }}
|
{{ __('No courses in this program') }}
|
||||||
@@ -119,7 +130,7 @@ import {
|
|||||||
FormControl,
|
FormControl,
|
||||||
} from 'frappe-ui'
|
} from 'frappe-ui'
|
||||||
import { computed, inject, onMounted, ref } from 'vue'
|
import { computed, inject, onMounted, ref } from 'vue'
|
||||||
import { BookOpen, Edit, Plus } from 'lucide-vue-next'
|
import { BookOpen, Edit, Plus, LockKeyhole } from 'lucide-vue-next'
|
||||||
import CourseCard from '@/components/CourseCard.vue'
|
import CourseCard from '@/components/CourseCard.vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { showToast, singularize } from '@/utils'
|
import { showToast, singularize } from '@/utils'
|
||||||
@@ -189,6 +200,13 @@ const enrollMember = (program, course) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const lockCourse = (course) => {
|
||||||
|
if (user.data?.is_moderator || user.data?.is_instructor) return false
|
||||||
|
if (course.membership) return false
|
||||||
|
if (course.eligible) return false
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
const breadbrumbs = computed(() => [
|
const breadbrumbs = computed(() => [
|
||||||
{
|
{
|
||||||
label: 'Programs',
|
label: 'Programs',
|
||||||
|
|||||||
@@ -4,13 +4,13 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
from frappe.model.rename_doc import update_document_title
|
||||||
|
|
||||||
|
|
||||||
class LMSProgram(Document):
|
class LMSProgram(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_program_courses()
|
self.validate_program_courses()
|
||||||
self.validate_program_members()
|
self.validate_program_members()
|
||||||
self.validate_title()
|
|
||||||
|
|
||||||
def validate_program_courses(self):
|
def validate_program_courses(self):
|
||||||
courses = [row.course for row in self.program_courses]
|
courses = [row.course for row in self.program_courses]
|
||||||
@@ -31,7 +31,3 @@ class LMSProgram(Document):
|
|||||||
frappe.bold(next(iter(duplicates)))
|
frappe.bold(next(iter(duplicates)))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
def validate_title(self):
|
|
||||||
if self.has_value_changed("title"):
|
|
||||||
frappe.rename_doc(self.doctype, self.name, self.title)
|
|
||||||
|
|||||||
@@ -1771,8 +1771,18 @@ def get_programs():
|
|||||||
"LMS Program Course", {"parent": program.name}, ["course"], order_by="idx"
|
"LMS Program Course", {"parent": program.name}, ["course"], order_by="idx"
|
||||||
)
|
)
|
||||||
program.courses = []
|
program.courses = []
|
||||||
for course in program_courses:
|
previous_progress = 0
|
||||||
program.courses.append(get_course_details(course.course))
|
for i, course in enumerate(program_courses):
|
||||||
|
details = get_course_details(course.course)
|
||||||
|
if i == 0:
|
||||||
|
details.eligible = True
|
||||||
|
elif previous_progress == 100:
|
||||||
|
details.eligible = True
|
||||||
|
else:
|
||||||
|
details.eligible = False
|
||||||
|
|
||||||
|
previous_progress = details.membership.progress if details.membership else 0
|
||||||
|
program.courses.append(details)
|
||||||
|
|
||||||
program.members = frappe.db.count("LMS Program Member", {"parent": program.name})
|
program.members = frappe.db.count("LMS Program Member", {"parent": program.name})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user