diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aafbfa01..1c0c28c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: ports: - 12000:6379 mariadb: - image: anandology/mariadb-utf8mb4:10.3 + image: mariadb:10.6 ports: - 3306:3306 env: diff --git a/lms/lms/doctype/lms_batch/lms_batch.js b/lms/lms/doctype/lms_batch/lms_batch.js index f7273fc1..1a95c493 100644 --- a/lms/lms/doctype/lms_batch/lms_batch.js +++ b/lms/lms/doctype/lms_batch/lms_batch.js @@ -12,12 +12,16 @@ frappe.ui.form.on("LMS Batch", { }); frm.set_query("reference_doctype", "timetable", function () { - let doctypes = [ - "Course Lesson", - "LMS Quiz", - "LMS Assignment", - "LMS Live Class", - ]; + let doctypes = ["Course Lesson", "LMS Quiz", "LMS Assignment"]; + return { + filters: { + name: ["in", doctypes], + }, + }; + }); + + frm.set_query("reference_doctype", "timetable_legends", function () { + let doctypes = ["Course Lesson", "LMS Quiz", "LMS Assignment"]; return { filters: { name: ["in", doctypes], @@ -27,36 +31,41 @@ frappe.ui.form.on("LMS Batch", { }, timetable_template: function (frm) { - if (frm.doc.timetable_template) { - frm.clear_table("timetable"); - frm.refresh_fields(); - - frappe.call({ - method: "frappe.client.get_list", - args: { - doctype: "LMS Batch Timetable", - parent: "LMS Timetable Template", - fields: [ - "reference_doctype", - "reference_docname", - "day", - "start_time", - "end_time", - "duration", - ], - filters: { - parent: frm.doc.timetable_template, - }, - order_by: "idx", - }, - callback: (data) => { - add_timetable_rows(frm, data.message); - }, - }); - } + set_timetable(frm); }, }); +const set_timetable = (frm) => { + if (frm.doc.timetable_template) { + frm.clear_table("timetable"); + frm.refresh_fields(); + + frappe.call({ + method: "frappe.client.get_list", + args: { + doctype: "LMS Batch Timetable", + parent: "LMS Timetable Template", + fields: [ + "reference_doctype", + "reference_docname", + "day", + "start_time", + "end_time", + "duration", + ], + filters: { + parent: frm.doc.timetable_template, + parenttype: "LMS Timetable Template", + }, + order_by: "idx", + }, + callback: (data) => { + add_timetable_rows(frm, data.message); + }, + }); + } +}; + const add_timetable_rows = (frm, timetable) => { timetable.forEach((row) => { let child = frm.add_child("timetable"); @@ -75,5 +84,40 @@ const add_timetable_rows = (frm, timetable) => { child.duration = row.duration; }); frm.refresh_field("timetable"); + + set_legends(frm); +}; + +const set_legends = (frm) => { + if (frm.doc.timetable_template) { + frm.clear_table("timetable_legends"); + frm.refresh_fields(); + frappe.call({ + method: "frappe.client.get_list", + args: { + doctype: "LMS Timetable Legend", + parent: "LMS Timetable Template", + fields: ["reference_doctype", "label", "color"], + filters: { + parent: frm.doc.timetable_template, + parenttype: "LMS Timetable Template", + }, + order_by: "idx", + }, + callback: (data) => { + add_legend_rows(frm, data.message); + }, + }); + } +}; + +const add_legend_rows = (frm, legends) => { + legends.forEach((row) => { + let child = frm.add_child("timetable_legends"); + child.reference_doctype = row.reference_doctype; + child.label = row.label; + child.color = row.color; + }); + frm.refresh_field("timetable_legends"); frm.save(); }; diff --git a/lms/lms/doctype/lms_batch/lms_batch.json b/lms/lms/doctype/lms_batch/lms_batch.json index 4cdb1e0a..f0838a4b 100644 --- a/lms/lms/doctype/lms_batch/lms_batch.json +++ b/lms/lms/doctype/lms_batch/lms_batch.json @@ -35,8 +35,10 @@ "timetable_template", "column_break_anya", "show_live_class", + "allow_future", "section_break_ontp", "timetable", + "timetable_legends", "pricing_tab", "section_break_gsac", "paid_batch", @@ -220,7 +222,7 @@ "default": "0", "fieldname": "show_live_class", "fieldtype": "Check", - "label": "Show Live Class" + "label": "Show live class" }, { "fieldname": "section_break_ontp", @@ -263,11 +265,23 @@ "fieldtype": "Code", "label": "Custom Script (JavaScript)", "options": "Javascript" + }, + { + "fieldname": "timetable_legends", + "fieldtype": "Table", + "label": "Timetable Legends", + "options": "LMS Timetable Legend" + }, + { + "default": "1", + "fieldname": "allow_future", + "fieldtype": "Check", + "label": "Allow accessing future dates" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-09-28 12:18:34.418812", + "modified": "2023-10-12 12:53:37.351989", "modified_by": "Administrator", "module": "LMS", "name": "LMS Batch", diff --git a/lms/lms/doctype/lms_timetable_legend/__init__.py b/lms/lms/doctype/lms_timetable_legend/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/lms/lms/doctype/lms_timetable_legend/lms_timetable_legend.js b/lms/lms/doctype/lms_timetable_legend/lms_timetable_legend.js new file mode 100644 index 00000000..7a8a3684 --- /dev/null +++ b/lms/lms/doctype/lms_timetable_legend/lms_timetable_legend.js @@ -0,0 +1,8 @@ +// Copyright (c) 2023, Frappe and contributors +// For license information, please see license.txt + +// frappe.ui.form.on("LMS Timetable Legend", { +// refresh(frm) { + +// }, +// }); diff --git a/lms/lms/doctype/lms_timetable_legend/lms_timetable_legend.json b/lms/lms/doctype/lms_timetable_legend/lms_timetable_legend.json new file mode 100644 index 00000000..6ae0ffe4 --- /dev/null +++ b/lms/lms/doctype/lms_timetable_legend/lms_timetable_legend.json @@ -0,0 +1,52 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "hash", + "creation": "2023-10-11 16:36:45.079267", + "default_view": "List", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "reference_doctype", + "label", + "color" + ], + "fields": [ + { + "fieldname": "reference_doctype", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Reference DocType", + "options": "DocType", + "reqd": 1 + }, + { + "fieldname": "color", + "fieldtype": "Color", + "in_list_view": 1, + "label": "Color", + "reqd": 1 + }, + { + "fieldname": "label", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Label", + "reqd": 1 + } + ], + "index_web_pages_for_search": 1, + "istable": 1, + "links": [], + "modified": "2023-10-11 17:15:37.039139", + "modified_by": "Administrator", + "module": "LMS", + "name": "LMS Timetable Legend", + "naming_rule": "Random", + "owner": "Administrator", + "permissions": [], + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/lms/lms/doctype/lms_timetable_legend/lms_timetable_legend.py b/lms/lms/doctype/lms_timetable_legend/lms_timetable_legend.py new file mode 100644 index 00000000..c842e3a2 --- /dev/null +++ b/lms/lms/doctype/lms_timetable_legend/lms_timetable_legend.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, Frappe and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + + +class LMSTimetableLegend(Document): + pass diff --git a/lms/lms/doctype/lms_timetable_legend/test_lms_timetable_legend.py b/lms/lms/doctype/lms_timetable_legend/test_lms_timetable_legend.py new file mode 100644 index 00000000..816b1793 --- /dev/null +++ b/lms/lms/doctype/lms_timetable_legend/test_lms_timetable_legend.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, Frappe and Contributors +# See license.txt + +# import frappe +from frappe.tests.utils import FrappeTestCase + + +class TestLMSTimetableLegend(FrappeTestCase): + pass diff --git a/lms/lms/doctype/lms_timetable_template/lms_timetable_template.js b/lms/lms/doctype/lms_timetable_template/lms_timetable_template.js index a9bff04e..b5ec2d9b 100644 --- a/lms/lms/doctype/lms_timetable_template/lms_timetable_template.js +++ b/lms/lms/doctype/lms_timetable_template/lms_timetable_template.js @@ -11,5 +11,19 @@ frappe.ui.form.on("LMS Timetable Template", { }, }; }); + + frm.set_query("reference_doctype", "timetable_legends", function () { + let doctypes = [ + "Course Lesson", + "LMS Quiz", + "LMS Assignment", + "LMS Live Class", + ]; + return { + filters: { + name: ["in", doctypes], + }, + }; + }); }, }); diff --git a/lms/lms/doctype/lms_timetable_template/lms_timetable_template.json b/lms/lms/doctype/lms_timetable_template/lms_timetable_template.json index 99c88628..3b016b7a 100644 --- a/lms/lms/doctype/lms_timetable_template/lms_timetable_template.json +++ b/lms/lms/doctype/lms_timetable_template/lms_timetable_template.json @@ -8,7 +8,8 @@ "engine": "InnoDB", "field_order": [ "title", - "timetable" + "timetable", + "timetable_legends" ], "fields": [ { @@ -21,11 +22,17 @@ "fieldtype": "Table", "label": "Timetable", "options": "LMS Batch Timetable" + }, + { + "fieldname": "timetable_legends", + "fieldtype": "Table", + "label": "Timetable Legends", + "options": "LMS Timetable Legend" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-09-18 17:57:15.819072", + "modified": "2023-10-11 17:09:05.096243", "modified_by": "Administrator", "module": "LMS", "name": "LMS Timetable Template", diff --git a/lms/www/batches/batch.html b/lms/www/batches/batch.html index 2f78e0c6..86cb1202 100644 --- a/lms/www/batches/batch.html +++ b/lms/www/batches/batch.html @@ -552,7 +552,7 @@ {% for legend in legends %}