Merge pull request #905 from pateljannat/search-course
feat: search courses
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="reviews.data" class="mt-20 mb-10">
|
<div v-if="reviews.data?.length || membership" class="mt-20 mb-10">
|
||||||
<Button
|
<Button
|
||||||
v-if="membership && !hasReviewed.data"
|
v-if="membership && !hasReviewed.data"
|
||||||
@click="openReviewModal()"
|
@click="openReviewModal()"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
@input="participants.reload()"
|
@input="participants.reload()"
|
||||||
>
|
>
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<Search class="w-4" name="search" />
|
<Search class="w-4 stroke-1.5 text-gray-600" name="search" />
|
||||||
</template>
|
</template>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</div>
|
</div>
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { Breadcrumbs, FormControl, createResource, debounce } from 'frappe-ui'
|
import { Breadcrumbs, FormControl, createResource } from 'frappe-ui'
|
||||||
import { ref, computed } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
import UserAvatar from '@/components/UserAvatar.vue'
|
import UserAvatar from '@/components/UserAvatar.vue'
|
||||||
import { Search } from 'lucide-vue-next'
|
import { Search } from 'lucide-vue-next'
|
||||||
@@ -59,8 +59,7 @@ const participants = createResource({
|
|||||||
url: 'lms.lms.api.get_certified_participants',
|
url: 'lms.lms.api.get_certified_participants',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
debounce: 300,
|
debounce: 300,
|
||||||
cache: ['certified_participants', searchQuery.value],
|
makeParams(values) {
|
||||||
makeParams() {
|
|
||||||
return {
|
return {
|
||||||
search_query: searchQuery.value,
|
search_query: searchQuery.value,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,17 @@
|
|||||||
class="h-7"
|
class="h-7"
|
||||||
:items="[{ label: __('All Courses'), route: { name: 'Courses' } }]"
|
:items="[{ label: __('All Courses'), route: { name: 'Courses' } }]"
|
||||||
/>
|
/>
|
||||||
<div class="flex">
|
<div class="flex space-x-2">
|
||||||
|
<FormControl
|
||||||
|
type="text"
|
||||||
|
placeholder="Search Course"
|
||||||
|
v-model="searchQuery"
|
||||||
|
@input="courses.reload()"
|
||||||
|
>
|
||||||
|
<template #prefix>
|
||||||
|
<Search class="w-4 stroke-1.5 text-gray-600" name="search" />
|
||||||
|
</template>
|
||||||
|
</FormControl>
|
||||||
<router-link
|
<router-link
|
||||||
:to="{
|
:to="{
|
||||||
name: 'CreateCourse',
|
name: 'CreateCourse',
|
||||||
@@ -97,17 +107,29 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { createListResource, Breadcrumbs, Tabs, Badge, Button } from 'frappe-ui'
|
import {
|
||||||
|
Breadcrumbs,
|
||||||
|
Tabs,
|
||||||
|
Badge,
|
||||||
|
Button,
|
||||||
|
FormControl,
|
||||||
|
createResource,
|
||||||
|
} from 'frappe-ui'
|
||||||
import CourseCard from '@/components/CourseCard.vue'
|
import CourseCard from '@/components/CourseCard.vue'
|
||||||
import { Plus } from 'lucide-vue-next'
|
import { Plus, Search } from 'lucide-vue-next'
|
||||||
import { ref, computed, inject } from 'vue'
|
import { ref, computed, inject } from 'vue'
|
||||||
import { updateDocumentTitle } from '@/utils'
|
import { updateDocumentTitle } from '@/utils'
|
||||||
|
|
||||||
const user = inject('$user')
|
const user = inject('$user')
|
||||||
const courses = createListResource({
|
const searchQuery = ref('')
|
||||||
type: 'list',
|
|
||||||
doctype: 'LMS Course',
|
const courses = createResource({
|
||||||
cache: ['courses', user?.data?.email],
|
debounce: 300,
|
||||||
|
makeParams(values) {
|
||||||
|
return {
|
||||||
|
search_query: searchQuery.value,
|
||||||
|
}
|
||||||
|
},
|
||||||
url: 'lms.lms.utils.get_courses',
|
url: 'lms.lms.utils.get_courses',
|
||||||
auto: true,
|
auto: true,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1251,10 +1251,12 @@ def change_currency(amount, currency, country=None):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist(allow_guest=True)
|
@frappe.whitelist(allow_guest=True)
|
||||||
def get_courses():
|
def get_courses(search_query=""):
|
||||||
"""Returns the list of courses."""
|
"""Returns the list of courses."""
|
||||||
courses = []
|
courses = []
|
||||||
course_list = frappe.get_all("LMS Course", pluck="name")
|
course_list = frappe.get_all(
|
||||||
|
"LMS Course", {"title": ["like", f"%{search_query}%"]}, pluck="name"
|
||||||
|
)
|
||||||
for course in course_list:
|
for course in course_list:
|
||||||
courses.append(get_course_details(course))
|
courses.append(get_course_details(course))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user