fix: validations and UI
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -129,14 +129,12 @@
|
||||
{{ format_number(get_students(course.name) | length) }} {{ _("Enrolled") }}
|
||||
</div>
|
||||
|
||||
{% if get_lessons(course.name) | length %}
|
||||
<div class="vertically-center mb-3">
|
||||
<svg class="icon icon-md mr-1">
|
||||
<use href="#icon-education"></use>
|
||||
</svg>
|
||||
{{ get_lessons(course.name, None, False) }} {{ _("Lessons") }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if course.enable_certification %}
|
||||
<div class="vertically-center mb-3">
|
||||
@@ -253,24 +251,25 @@
|
||||
</a>
|
||||
|
||||
{% elif course.grant_certificate_after == "Completion" and progress == 100 %}
|
||||
<div class="btn btn-secondary wide-button is-secondary mt-2" id="certification" data-course="{{ course.name }}">
|
||||
<div class="btn btn-secondary wide-button mt-2" id="certification" data-course="{{ course.name }}">
|
||||
{{ _("Get Certificate") }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
{% if is_instructor(course.name) or has_course_moderator_role() %}
|
||||
<a class="btn btn-default btn-sm pull-right ml-2" title="Edit Course" href="/courses/{{ course.name }}/edit">
|
||||
<svg class="icon icon-md">
|
||||
<use href="#icon-edit"></use>
|
||||
</svg>
|
||||
</a>
|
||||
<a class="btn btn-secondary wide-button mt-2" title="Edit Course" href="/courses/{{ course.name }}/edit">
|
||||
<!-- <svg class="icon icon-md">
|
||||
<use href="#icon-edit"></use>
|
||||
</svg> -->
|
||||
{{ _("Edit") }}
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user