fix: misc issues

This commit is contained in:
Jannat Patel
2024-07-16 16:11:24 +05:30
parent 0183677494
commit 25a2d82e82
7 changed files with 49 additions and 35 deletions

View File

@@ -130,11 +130,14 @@ function submitEvaluation(close) {
close()
},
onError(err) {
let message = err.messages?.[0] || err
let unavailabilityMessage = message.includes('unavailable')
createToast({
title: 'Error',
text: err.messages?.[0] || err,
icon: 'x',
iconClasses: 'bg-red-600 text-white rounded-md p-px',
title: unavailabilityMessage ? 'Evaluator is Unavailable' : 'Error',
text: message,
icon: unavailabilityMessage ? 'alert-circle' : 'x',
iconClasses: 'bg-yellow-600 text-white rounded-md p-px',
position: 'top-center',
timeout: 10,
})

View File

@@ -18,7 +18,10 @@
</header>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 m-5">
<div v-if="participants.data" v-for="participant in participants.data">
<div
v-if="participants.data?.length"
v-for="participant in participantsList"
>
<router-link
:to="{
name: 'Profile',
@@ -59,12 +62,7 @@ const searchQuery = ref('')
const participants = createResource({
url: 'lms.lms.api.get_certified_participants',
method: 'GET',
debounce: 300,
makeParams(values) {
return {
search_query: searchQuery.value,
}
},
cache: 'certified-participants',
auto: true,
})
@@ -79,5 +77,16 @@ const pageMeta = computed(() => {
}
})
const participantsList = computed(() => {
if (searchQuery.value) {
return participants.data.filter((participant) => {
return participant.full_name
.toLowerCase()
.includes(searchQuery.value.toLowerCase())
})
}
return participants.data
})
updateDocumentTitle(pageMeta)
</script>

View File

@@ -79,15 +79,18 @@ export function getFileSize(file_size) {
return value
}
export function showToast(title, text, icon) {
export function showToast(title, text, icon, iconClasses = null) {
if (!iconClasses) {
iconClasses =
icon == 'check'
? 'bg-green-600 text-white rounded-md p-px'
: 'bg-red-600 text-white rounded-md p-px'
}
createToast({
title: title,
text: htmlToText(text),
icon: icon,
iconClasses:
icon == 'check'
? 'bg-green-600 text-white rounded-md p-px'
: 'bg-red-600 text-white rounded-md p-px',
iconClasses: iconClasses,
position: icon == 'check' ? 'bottom-right' : 'top-center',
timeout: 5,
})

View File

@@ -330,13 +330,12 @@ def get_evaluator_details(evaluator):
@frappe.whitelist(allow_guest=True)
def get_certified_participants(search_query=""):
def get_certified_participants():
LMSCertificate = DocType("LMS Certificate")
participants = (
frappe.qb.from_(LMSCertificate)
.select(LMSCertificate.member)
.distinct()
.where(LMSCertificate.member_name.like(f"%{search_query}%"))
.where(LMSCertificate.published == 1)
.orderby(LMSCertificate.creation, order=frappe.qb.desc)
.run(as_dict=1)

View File

@@ -8,16 +8,16 @@
"field_order": [
"course",
"course_title",
"column_break_3",
"member",
"member_name",
"published",
"section_break_tnnm",
"template",
"batch_name",
"column_break_qtzo",
"column_break_vwbn",
"issue_date",
"expiry_date"
"template",
"published",
"section_break_scyf",
"expiry_date",
"column_break_slaw",
"batch_name"
],
"fields": [
{
@@ -27,10 +27,6 @@
"label": "Issue Date",
"reqd": 1
},
{
"fieldname": "column_break_3",
"fieldtype": "Column Break"
},
{
"fieldname": "course",
"fieldtype": "Link",
@@ -89,17 +85,21 @@
"read_only": 1
},
{
"fieldname": "section_break_tnnm",
"fieldname": "column_break_vwbn",
"fieldtype": "Column Break"
},
{
"fieldname": "section_break_scyf",
"fieldtype": "Section Break"
},
{
"fieldname": "column_break_qtzo",
"fieldname": "column_break_slaw",
"fieldtype": "Column Break"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-07-12 12:39:50.076937",
"modified": "2024-07-16 15:29:19.708888",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Certificate",

View File

@@ -47,7 +47,7 @@
"fieldtype": "Rating",
"in_list_view": 1,
"label": "Rating",
"mandatory_depends_on": "eval:doc.status != 'Pending' && doc.status != 'In Progress'"
"mandatory_depends_on": "eval:doc.status == 'Pass'"
},
{
"fieldname": "summary",
@@ -107,7 +107,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-04-15 11:22:43.189908",
"modified": "2024-07-16 14:06:11.977666",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Certificate Evaluation",

View File

@@ -42,7 +42,7 @@ class LMSCertificateRequest(Document):
):
frappe.throw(
_(
"Evaluator is unavailable from {0} to {1}. Please select a date after {1}"
"The evaluator of this course is unavailable from {0} to {1}. Please select a date after {1}"
).format(
format_date(unavailable.unavailable_from, "medium"),
format_date(unavailable.unavailable_to, "medium"),