From 7b3d2d8812d997c55a15e439d701265ef7d37e7e Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Tue, 18 Feb 2025 15:57:55 +0530 Subject: [PATCH] feat: filter certification batches --- frontend/src/pages/Batch.vue | 2 +- frontend/src/pages/BatchForm.vue | 13 +++++++- frontend/src/pages/Batches.vue | 20 ++++++++++- lms/lms/doctype/lms_batch/lms_batch.json | 35 ++++++++++++++++++-- lms/lms/doctype/lms_payment/lms_payment.json | 13 ++++++-- lms/lms/utils.py | 1 + 6 files changed, 76 insertions(+), 8 deletions(-) diff --git a/frontend/src/pages/Batch.vue b/frontend/src/pages/Batch.vue index 3382e370..ef38c899 100644 --- a/frontend/src/pages/Batch.vue +++ b/frontend/src/pages/Batch.vue @@ -6,7 +6,7 @@
@@ -293,6 +298,7 @@ const batch = reactive({ medium: '', category: '', allow_self_enrollment: false, + certification: false, image: null, paid_batch: false, currency: '', @@ -362,7 +368,12 @@ const batchDetail = createResource({ batch[key] = `${hours}:${minutes}` } else if (Object.hasOwn(batch, key)) batch[key] = data[key] }) - let checkboxes = ['published', 'paid_batch', 'allow_self_enrollment'] + let checkboxes = [ + 'published', + 'paid_batch', + 'allow_self_enrollment', + 'certification', + ] for (let idx in checkboxes) { let key = checkboxes[idx] batch[key] = batch[key] ? true : false diff --git a/frontend/src/pages/Batches.vue b/frontend/src/pages/Batches.vue index 0ecb561e..dd46a7bf 100644 --- a/frontend/src/pages/Batches.vue +++ b/frontend/src/pages/Batches.vue @@ -26,13 +26,19 @@ {{ __('All Batches') }}
+
{ let queries = new URLSearchParams(location.search) title.value = queries.get('title') || '' currentCategory.value = queries.get('category') || null + certification.value = queries.get('certification') || false } const batches = createListResource({ @@ -161,6 +169,7 @@ const updateBatches = () => { const updateFilters = () => { updateCategoryFilter() updateTitleFilter() + updateCertificationFilter() updateTabFilter() updateStudentFilter() setQueryParams() @@ -182,6 +191,14 @@ const updateTitleFilter = () => { } } +const updateCertificationFilter = () => { + if (certification.value) { + filters.value['certification'] = 1 + } else { + delete filters.value['certification'] + } +} + const updateTabFilter = () => { orderBy.value = 'start_date' if (!user.data) { @@ -222,6 +239,7 @@ const setQueryParams = () => { let filterKeys = { title: title.value, category: currentCategory.value, + certification: certification.value, } Object.keys(filterKeys).forEach((key) => { diff --git a/lms/lms/doctype/lms_batch/lms_batch.json b/lms/lms/doctype/lms_batch/lms_batch.json index c4de7840..02763855 100644 --- a/lms/lms/doctype/lms_batch/lms_batch.json +++ b/lms/lms/doctype/lms_batch/lms_batch.json @@ -8,15 +8,20 @@ "editable_grid": 1, "engine": "InnoDB", "field_order": [ - "published", + "section_break_earo", "title", "start_date", "end_date", "column_break_4", - "allow_self_enrollment", "start_time", "end_time", "timezone", + "section_break_cssv", + "published", + "column_break_wfkz", + "allow_self_enrollment", + "column_break_vnrp", + "certification", "section_break_6", "description", "column_break_hlqw", @@ -207,6 +212,7 @@ "default": "0", "fieldname": "published", "fieldtype": "Check", + "in_standard_filter": 1, "label": "Published" }, { @@ -325,6 +331,29 @@ "fieldtype": "Link", "label": "Confirmation Email Template", "options": "Email Template" + }, + { + "fieldname": "column_break_wfkz", + "fieldtype": "Column Break" + }, + { + "fieldname": "column_break_vnrp", + "fieldtype": "Column Break" + }, + { + "default": "0", + "fieldname": "certification", + "fieldtype": "Check", + "in_standard_filter": 1, + "label": "Certification" + }, + { + "fieldname": "section_break_earo", + "fieldtype": "Section Break" + }, + { + "fieldname": "section_break_cssv", + "fieldtype": "Section Break" } ], "index_web_pages_for_search": 1, @@ -342,7 +371,7 @@ "link_fieldname": "batch_name" } ], - "modified": "2025-02-17 17:48:12.949392", + "modified": "2025-02-18 15:43:18.512504", "modified_by": "Administrator", "module": "LMS", "name": "LMS Batch", diff --git a/lms/lms/doctype/lms_payment/lms_payment.json b/lms/lms/doctype/lms_payment/lms_payment.json index cdb3d751..67720a46 100644 --- a/lms/lms/doctype/lms_payment/lms_payment.json +++ b/lms/lms/doctype/lms_payment/lms_payment.json @@ -139,8 +139,17 @@ } ], "index_web_pages_for_search": 1, - "links": [], - "modified": "2025-02-11 14:48:27.801895", + "links": [ + { + "link_doctype": "LMS Batch Enrollment", + "link_fieldname": "payment" + }, + { + "link_doctype": "LMS Enrollment", + "link_fieldname": "payment" + } + ], + "modified": "2025-02-18 15:54:25.383353", "modified_by": "Administrator", "module": "LMS", "name": "LMS Payment", diff --git a/lms/lms/utils.py b/lms/lms/utils.py index 8ccbd4a0..fcd28289 100644 --- a/lms/lms/utils.py +++ b/lms/lms/utils.py @@ -1225,6 +1225,7 @@ def get_batch_details(batch): "paid_batch", "evaluation_end_date", "allow_self_enrollment", + "certification", "timezone", "category", ],