fix: ui for course creation

This commit is contained in:
Jannat Patel
2022-08-10 19:45:58 +05:30
parent a4534d8f3e
commit 301664ce93
10 changed files with 144 additions and 70 deletions

View File

@@ -113,36 +113,7 @@
{% endif %}
{% if lesson.edit_mode %}
<div class="attachments-parent">
<div class="attachment-controls">
<div class="show-attachments" data-toggle="collapse" data-target="#collapse-attachments" aria-expanded="false">
<svg class="icon icon-sm">
<use class="" href="#icon-attachment">
</svg>
<span class="attachment-count" data-count="0">0 {{ _("attachments") }}</span>
</div>
<div class="add-attachment">
<span class="button is-secondary">
<svg class="icon icon-sm">
<use class="" href="#icon-upload">
</svg>
{{ _("Upload Attachments") }}
</span>
</div>
</div>
<table class="attachments common-card-style collapse hide" id="collapse-attachments"></table>
</div>
<label class="d-flex align-items-center mb-4 small">
<input {% if lesson.include_in_preview %} checked {% endif %}
type="checkbox" id="preview"> {{ _("Show preview of this lesson") }}
</label>
<div contenteditable="true" data-placeholder="{{ _('Enter the lesson content.') }}"
id="body"> {% if lesson.body %} {{ lesson.body }} {% endif %} </div>
<button class="btn btn-primary btn-md mt-8 btn-lesson pull-right"> {{ _("Save") }} </button>
{{ EditLesson(lesson) }}
{% else %}
{{ render_html(lesson.body) }}
{% endif %}
@@ -203,6 +174,42 @@
</div>
{% endmacro %}
{% macro EditLesson(lesson) %}
<div contenteditable="true" data-placeholder="{{ _('Enter the lesson content.') }}"
> {% if lesson.body %} {{ lesson.body }} {% endif %} </div>
<div id="body"></div>
<label class="preview">
<input {% if lesson.include_in_preview %} checked {% endif %}
type="checkbox" id="preview"> {{ _("Show preview of this lesson") }}
</label>
<div class="mt-8">
<button class="btn btn-primary btn-md btn-lesson pull-right"> {{ _("Save") }} </button>
<div class="attachments-parent">
<div class="attachment-controls">
<div class="show-attachments" data-toggle="collapse" data-target="#collapse-attachments" aria-expanded="false">
<svg class="icon icon-sm">
<use class="" href="#icon-attachment">
</svg>
<span class="attachment-count" data-count="0">0 {{ _("attachments") }}</span>
</div>
<div class="add-attachment">
<span class="btn btn-md btn-secondary">
<svg class="icon icon-sm">
<use class="" href="#icon-upload">
</svg>
{{ _("Upload Attachments") }}
</span>
</div>
</div>
<table class="attachments common-card-style collapse hide" id="collapse-attachments"></table>
</div>
</div>
{% endmacro %}
{% macro Discussions() %}
{% set topics_count = frappe.db.count("Discussion Topic",
{"reference_doctype": "Course Lesson", "reference_docname": lesson.name}) %}

View File

@@ -1,6 +1,7 @@
frappe.ready(() => {
localStorage.removeItem($("#quiz-title").text());
fetch_assignments();
save_current_lesson();
@@ -478,7 +479,7 @@ const save_lesson = (e) => {
method: "lms.lms.doctype.lms_course.lms_course.save_lesson",
args: {
"title": $("#title").text(),
"body": $("#body").text(),
"body": $("#body").find("br").replaceWith("\n\n").end().text(),
"chapter": $("#title").data("chapter"),
"preview": $("#preview").prop("checked") ? 1 : 0,
"idx": $("#title").data("index"),

View File

@@ -1,7 +1,6 @@
from re import I
import frappe
from lms.www.utils import get_common_context, redirect_to_lesson
from lms.lms.utils import get_lesson_url
from lms.lms.utils import get_lesson_url, is_instructor, redirect_to_courses_list
from frappe.utils import cstr, flt
def get_context(context):
@@ -28,6 +27,8 @@ def get_context(context):
context.lessom = frappe._dict()
if frappe.form_dict.get("edit"):
if not is_instructor(context.course.name):
redirect_to_courses_list()
context.lesson.edit_mode = True
neighbours = get_neighbours(lesson_number, context.lessons)

View File

@@ -307,7 +307,8 @@ data-placeholder="Description">{% if course.description %}{{ frappe.utils.md_to_
{% macro Save(course) %}
{% if course.edit_mode %}
<div>
<button class="btn btn-primary btn-md btn-save-course my-4"> {{ _("Save") }} </button>
<button class="btn btn-primary btn-md btn-save-course my-4">
{{ _("Save Course Details") }} </button>
</div>
{% endif %}
{% endmacro %}

View File

@@ -322,7 +322,7 @@ const clear_image = () => {
const add_tag = (e) => {
$(`<div class="course-card-pills" contenteditable="true"
data-placeholder="${__('Tags')}"></div>`).insertBefore(`.btn-tag`);
data-placeholder="${__('Tag')}"></div>`).insertBefore(`.btn-tag`);
};

View File

@@ -1,6 +1,6 @@
import frappe
from lms.lms.doctype.lms_settings.lms_settings import check_profile_restriction
from lms.lms.utils import get_membership, is_instructor, is_certified, get_evaluation_details
from lms.lms.utils import get_membership, is_instructor, is_certified, get_evaluation_details, redirect_to_courses_list
def get_context(context):
context.no_cache = 1
@@ -72,8 +72,3 @@ def get_user_interest(course):
def show_start_learing_cta(course, membership, restriction):
return not course.disable_self_learning and not membership and not course.upcoming and not restriction.get("restrict") and not is_instructor(course.name)
def redirect_to_courses_list():
frappe.local.flags.redirect_location = "/courses"
raise frappe.Redirect