From c3f3a110c027529da33e476b4de87e54054d6bd7 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Thu, 11 May 2023 12:01:32 +0530 Subject: [PATCH] fix: validations and UI --- lms/lms/doctype/lms_course/lms_course.json | 4 ++-- lms/patches.txt | 1 + lms/public/css/style.css | 20 ++++++++--------- lms/www/courses/course.html | 21 +++++++++-------- lms/www/courses/create.js | 26 ++++++++++++++-------- 5 files changed, 40 insertions(+), 32 deletions(-) diff --git a/lms/lms/doctype/lms_course/lms_course.json b/lms/lms/doctype/lms_course/lms_course.json index daeec692..f951d788 100644 --- a/lms/lms/doctype/lms_course/lms_course.json +++ b/lms/lms/doctype/lms_course/lms_course.json @@ -58,7 +58,7 @@ }, { "fieldname": "description", - "fieldtype": "Markdown Editor", + "fieldtype": "Text Editor", "label": "Description", "reqd": 1 }, @@ -261,7 +261,7 @@ } ], "make_attachments_public": 1, - "modified": "2023-05-09 17:08:19.763405", + "modified": "2023-05-11 17:08:19.763405", "modified_by": "Administrator", "module": "LMS", "name": "LMS Course", diff --git a/lms/patches.txt b/lms/patches.txt index 3fe84429..dcd27ed3 100644 --- a/lms/patches.txt +++ b/lms/patches.txt @@ -53,3 +53,4 @@ lms.patches.v0_0.add_evaluator_to_assignment #09-04-2023 lms.patches.v0_0.share_certificates execute:frappe.delete_doc("Web Form", "class", ignore_missing=True, force=True) lms.patches.v0_0.amend_course_and_lesson_editor_fields +lms.patches.v0_0.convert_course_description_to_html #11-05-2023 diff --git a/lms/public/css/style.css b/lms/public/css/style.css index 51e97f51..f3b45f98 100644 --- a/lms/public/css/style.css +++ b/lms/public/css/style.css @@ -1398,16 +1398,16 @@ pre { } .course-overlay-card { - background-color: white; - border-radius: var(--border-radius-lg); - box-shadow: var(--shadow-sm); - overflow: auto; - width: fit-content; - position: absolute; - top: 10%; - right: 7%; - max-width: 350px; - z-index: 4; + background-color: white; + border-radius: var(--border-radius-lg); + border: 1px solid var(--gray-300); + overflow: auto; + width: fit-content; + position: absolute; + top: 10%; + right: 7%; + width: 350px; + z-index: 4; } @media (max-width: 1000px) { diff --git a/lms/www/courses/course.html b/lms/www/courses/course.html index b89868cb..f25be918 100644 --- a/lms/www/courses/course.html +++ b/lms/www/courses/course.html @@ -129,14 +129,12 @@ {{ format_number(get_students(course.name) | length) }} {{ _("Enrolled") }} - {% if get_lessons(course.name) | length %}
{{ get_lessons(course.name, None, False) }} {{ _("Lessons") }}
- {% endif %} {% if course.enable_certification %}
@@ -253,24 +251,25 @@ {% elif course.grant_certificate_after == "Completion" and progress == 100 %} -
+
{{ _("Get Certificate") }}
{% endif %} {% endif %} -
- -
{% if is_instructor(course.name) or has_course_moderator_role() %} - - - - - + + + {{ _("Edit") }} + {% endif %}
+ + + {% endmacro %} diff --git a/lms/www/courses/create.js b/lms/www/courses/create.js index abe1fb47..59efc788 100644 --- a/lms/www/courses/create.js +++ b/lms/www/courses/create.js @@ -94,22 +94,30 @@ const validate_mandatory = () => { let input = $(el).closest(".field-group").find(".field-input"); if (input.length && input.val().trim() == "") { if (input.siblings(".error-message").length == 0) { - let error = document.createElement("p"); - error.classList.add("error-message"); - error.innerText = `Please enter a ${$(el).text().trim()}`; - $(error).insertAfter($(input)); + scroll_to_element(input); + throw_error(el, input); } - scroll_to_element(input); - throw "Mandatory field missing"; + throw `${$(el).text().trim()} is mandatory`; } }); - console.log(this.description.fields_dict["description"].value); - if (!this.description.fields_dict["description"].value) { + + if (!strip_html(this.description.fields_dict["description"].value)) { scroll_to_element("#description"); - frappe.throw(__(`Please enter a description`)); + throw_error( + "#description", + this.description.fields_dict["description"].parent + ); + throw "Description is mandatory"; } }; +const throw_error = (el, input) => { + let error = document.createElement("p"); + error.classList.add("error-message"); + error.innerText = `Please enter a ${$(el).text().trim()}`; + $(error).insertAfter($(input)); +}; + const scroll_to_element = (element) => { if ($(element).length) { $([document.documentElement, document.body]).animate(