Merge pull request #933 from pateljannat/issues-25

fix: misc issues
This commit is contained in:
Jannat Patel
2024-07-17 11:40:35 +05:30
committed by GitHub
8 changed files with 54 additions and 45 deletions

View File

@@ -2,28 +2,23 @@
<div <div
v-if="course.title" v-if="course.title"
class="flex flex-col h-full rounded-md shadow-md text-base overflow-auto" class="flex flex-col h-full rounded-md shadow-md text-base overflow-auto"
style="min-height: 320px" style="min-height: 350px"
> >
<div <div
class="course-image" class="course-image"
:class="{ 'default-image': !course.image }" :class="{ 'default-image': !course.image }"
:style="{ backgroundImage: 'url(\'' + encodeURI(course.image) + '\')' }" :style="{ backgroundImage: 'url(\'' + encodeURI(course.image) + '\')' }"
> >
<div class="flex relative top-4 left-4 w-fit flex-wrap"> <div
<Badge class="flex items-center flex-wrap space-y-1 space-x-1 relative top-4 px-2 w-fit"
v-if="course.featured"
variant="subtle"
theme="green"
size="md"
class="mr-2"
> >
<Badge v-if="course.featured" variant="subtle" theme="green" size="md">
{{ __('Featured') }} {{ __('Featured') }}
</Badge> </Badge>
<Badge <Badge
variant="outline" variant="outline"
theme="gray" theme="gray"
size="md" size="md"
class="mr-2"
v-for="tag in course.tags" v-for="tag in course.tags"
> >
{{ tag }} {{ tag }}

View File

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

View File

@@ -18,7 +18,10 @@
</header> </header>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 m-5"> <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 <router-link
:to="{ :to="{
name: 'Profile', name: 'Profile',
@@ -59,12 +62,7 @@ const searchQuery = ref('')
const participants = createResource({ const participants = createResource({
url: 'lms.lms.api.get_certified_participants', url: 'lms.lms.api.get_certified_participants',
method: 'GET', method: 'GET',
debounce: 300, cache: 'certified-participants',
makeParams(values) {
return {
search_query: searchQuery.value,
}
},
auto: true, 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) updateDocumentTitle(pageMeta)
</script> </script>

View File

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

View File

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

View File

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

View File

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

View File

@@ -42,7 +42,7 @@ class LMSCertificateRequest(Document):
): ):
frappe.throw( 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(
format_date(unavailable.unavailable_from, "medium"), format_date(unavailable.unavailable_from, "medium"),
format_date(unavailable.unavailable_to, "medium"), format_date(unavailable.unavailable_to, "medium"),