fix: validations and UI
This commit is contained in:
@@ -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