Skip to content

Commit

Permalink
feat: all day events
Browse files Browse the repository at this point in the history
  • Loading branch information
pateljannat committed Nov 30, 2023
1 parent 9619091 commit f1f9d97
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
38 changes: 38 additions & 0 deletions lms/lms/doctype/lms_batch/lms_batch.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ frappe.ui.form.on("LMS Batch", {
},
};
});

if (frm.doc.timetable.length && !frm.doc.timetable_legends.length) {
set_default_legends(frm);
}
},

timetable_template: function (frm) {
Expand Down Expand Up @@ -127,3 +131,37 @@ const add_legend_rows = (frm, legends) => {
frm.refresh_field("timetable_legends");
frm.save();
};

const set_default_legends = (frm) => {
const data = [
{
reference_doctype: "Course Lesson",
label: "Lesson",
color: "#449CF0",
},
{
reference_doctype: "LMS Quiz",
label: "LMS Quiz",
color: "#39E4A5",
},
{
reference_doctype: "LMS Assignment",
label: "LMS Assignment",
color: "#ECAD4B",
},
{
reference_doctype: "LMS Live Class",
label: "LMS Live Class",
color: "#bb8be8",
},
];

data.forEach((detail) => {
let child = frm.add_child("timetable_legends");
child.reference_doctype = detail.reference_doctype;
child.label = detail.label;
child.color = detail.color;
});
frm.refresh_field("timetable_legends");
frm.save();
};
4 changes: 4 additions & 0 deletions lms/public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2482,4 +2482,8 @@ select {

.text-color {
color: var(--text-color);
}

.toastui-calendar-weekday-event-block {
box-shadow: none !important;
}
7 changes: 6 additions & 1 deletion lms/www/batches/batch.js
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,11 @@ const get_calendar_options = (element, calendar_id) => {
template: {
time: function (event) {
let hide = event.raw.completed ? "" : "hide";
return `<div class="calendar-event-time">
return `<div class="calendar-event-time" title="${
event.title
} - ${frappe.datetime.get_time(
event.start.d.d
)} - ${frappe.datetime.get_time(event.end.d.d)}">
<img class='icon icon-sm pull-right ${hide}' src="/assets/lms/icons/check.svg">
<div> ${frappe.datetime.get_time(event.start.d.d)} -
${frappe.datetime.get_time(event.end.d.d)} </div>
Expand Down Expand Up @@ -739,6 +743,7 @@ const create_events = (calendar, events, calendar_id) => {
};

const format_time = (time) => {
if (!time) return "00:00:00";
let time_arr = time.split(":");
if (time_arr[0] < 10) time_arr[0] = "0" + time_arr[0];
return time_arr.join(":");
Expand Down

0 comments on commit f1f9d97

Please sign in to comment.