Merge pull request #794 from arunmathaisk/develop
feat: CertifiedParticipants.vue page is now searchable
This commit is contained in:
@@ -4,6 +4,20 @@
|
||||
>
|
||||
<Breadcrumbs :items="breadcrumbs" />
|
||||
</header>
|
||||
|
||||
<div class="m-5">
|
||||
<FormControl
|
||||
type="text"
|
||||
placeholder="Search Participants"
|
||||
v-model="searchQuery"
|
||||
@input="participants.reload()"
|
||||
size="md"
|
||||
>
|
||||
<template #prefix>
|
||||
<Search class="w-4" name="search" />
|
||||
</template>
|
||||
</FormControl>
|
||||
</div>
|
||||
<div class="grid grid-cols-3 gap-4 m-5">
|
||||
<div v-for="participant in participants.data">
|
||||
<router-link
|
||||
@@ -38,14 +52,22 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { Breadcrumbs, createResource } from 'frappe-ui'
|
||||
import { computed } from 'vue'
|
||||
import { Breadcrumbs, FormControl, createResource } from 'frappe-ui'
|
||||
import { ref, computed } from 'vue'
|
||||
import UserAvatar from '@/components/UserAvatar.vue'
|
||||
import { Search } from 'lucide-vue-next'
|
||||
|
||||
const searchQuery = ref('')
|
||||
|
||||
const participants = createResource({
|
||||
url: 'lms.lms.api.get_certified_participants',
|
||||
method: 'GET',
|
||||
makeParams() {
|
||||
return {
|
||||
search_query: searchQuery.value,
|
||||
}
|
||||
},
|
||||
auto: true,
|
||||
cache: ['certified-participants'],
|
||||
})
|
||||
|
||||
const breadcrumbs = computed(() => {
|
||||
|
||||
@@ -330,12 +330,13 @@ def get_evaluator_details(evaluator):
|
||||
|
||||
|
||||
@frappe.whitelist(allow_guest=True)
|
||||
def get_certified_participants():
|
||||
def get_certified_participants(search_query=""):
|
||||
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)
|
||||
@@ -355,7 +356,6 @@ def get_certified_participants():
|
||||
courses = []
|
||||
for course in course_names:
|
||||
courses.append(frappe.db.get_value("LMS Course", course, "title"))
|
||||
details.courses = courses
|
||||
details["courses"] = courses
|
||||
participant_details.append(details)
|
||||
|
||||
return participant_details
|
||||
|
||||
Reference in New Issue
Block a user