feat: class dialog
This commit is contained in:
@@ -157,3 +157,18 @@ def authenticate():
|
||||
}
|
||||
response = requests.request("POST", authenticate_url, headers=headers)
|
||||
return response.json()["access_token"]
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def create_class(title, start_date, end_date, description):
|
||||
class_details = frappe.get_doc(
|
||||
{
|
||||
"doctype": "LMS Class",
|
||||
"title": title,
|
||||
"start_date": start_date,
|
||||
"end_date": end_date,
|
||||
"description": description,
|
||||
}
|
||||
)
|
||||
class_details.save()
|
||||
return class_details
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
frappe.ready(function () {
|
||||
// bind events here
|
||||
});
|
||||
@@ -1,87 +0,0 @@
|
||||
{
|
||||
"accept_payment": 0,
|
||||
"allow_comments": 0,
|
||||
"allow_delete": 0,
|
||||
"allow_edit": 0,
|
||||
"allow_incomplete": 0,
|
||||
"allow_multiple": 0,
|
||||
"allow_print": 0,
|
||||
"amount": 0.0,
|
||||
"amount_based_on_field": 0,
|
||||
"apply_document_permissions": 0,
|
||||
"button_label": "Save",
|
||||
"creation": "2022-11-11 12:10:29.640675",
|
||||
"custom_css": "",
|
||||
"doc_type": "LMS Class",
|
||||
"docstatus": 0,
|
||||
"doctype": "Web Form",
|
||||
"idx": 0,
|
||||
"is_standard": 1,
|
||||
"list_columns": [],
|
||||
"login_required": 0,
|
||||
"max_attachment_size": 0,
|
||||
"modified": "2022-11-21 10:56:01.627821",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "class",
|
||||
"owner": "Administrator",
|
||||
"payment_button_label": "Buy Now",
|
||||
"published": 1,
|
||||
"route": "class",
|
||||
"show_attachments": 0,
|
||||
"show_list": 0,
|
||||
"show_sidebar": 0,
|
||||
"success_title": "",
|
||||
"success_url": "/classes",
|
||||
"title": "Class",
|
||||
"web_form_fields": [
|
||||
{
|
||||
"allow_read_on_all_link_options": 0,
|
||||
"fieldname": "title",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"label": "Title",
|
||||
"max_length": 0,
|
||||
"max_value": 0,
|
||||
"read_only": 0,
|
||||
"reqd": 1,
|
||||
"show_in_filter": 0
|
||||
},
|
||||
{
|
||||
"allow_read_on_all_link_options": 0,
|
||||
"fieldname": "start_date",
|
||||
"fieldtype": "Date",
|
||||
"hidden": 0,
|
||||
"label": "Start Date",
|
||||
"max_length": 0,
|
||||
"max_value": 0,
|
||||
"read_only": 0,
|
||||
"reqd": 1,
|
||||
"show_in_filter": 0
|
||||
},
|
||||
{
|
||||
"allow_read_on_all_link_options": 0,
|
||||
"fieldname": "end_date",
|
||||
"fieldtype": "Date",
|
||||
"hidden": 0,
|
||||
"label": "End Date",
|
||||
"max_length": 0,
|
||||
"max_value": 0,
|
||||
"read_only": 0,
|
||||
"reqd": 1,
|
||||
"show_in_filter": 0
|
||||
},
|
||||
{
|
||||
"allow_read_on_all_link_options": 0,
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Small Text",
|
||||
"hidden": 0,
|
||||
"label": "Description",
|
||||
"max_length": 0,
|
||||
"max_value": 0,
|
||||
"read_only": 0,
|
||||
"reqd": 0,
|
||||
"show_in_filter": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def get_context(context):
|
||||
# do your magic here
|
||||
pass
|
||||
@@ -51,4 +51,5 @@ lms.patches.v0_0.rename_exercise_doctype
|
||||
lms.patches.v0_0.add_question_type
|
||||
lms.patches.v0_0.add_evaluator_to_assignment
|
||||
lms.patches.v0_0.convert_lesson_markdown_to_html #05-04-2023
|
||||
lms.patches.v0_0.convert_course_description_to_html
|
||||
lms.patches.v0_0.convert_course_description_to_html
|
||||
execute:frappe.delete_doc("Web Form", "class", ignore_missing=True, force=True)
|
||||
|
||||
@@ -1976,7 +1976,7 @@ select {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.common-page-style .tooltip-content {
|
||||
.tooltip-content {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,10 @@ frappe.ready(() => {
|
||||
$(".chapter-dropzone").each((i, el) => {
|
||||
setSortable(el);
|
||||
});
|
||||
|
||||
$("#create-class").click((e) => {
|
||||
open_class_dialog(e);
|
||||
});
|
||||
});
|
||||
|
||||
const setSortable = (el) => {
|
||||
@@ -385,3 +389,65 @@ const reorder_chapter = (e) => {
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const open_class_dialog = (e) => {
|
||||
let class_details = $(e.currentTarget).data("class");
|
||||
console.log(class_details);
|
||||
console.log(decodeURIComponent(class_details));
|
||||
console.log(JSON.parse(class_details));
|
||||
let dialog = new frappe.ui.Dialog({
|
||||
title: __("New Class"),
|
||||
fields: [
|
||||
{
|
||||
fieldtype: "Data",
|
||||
label: __("Title"),
|
||||
fieldname: "title",
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
fieldtype: "Date",
|
||||
label: __("Start Date"),
|
||||
fieldname: "start_date",
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
fieldtype: "Date",
|
||||
label: __("End Date"),
|
||||
fieldname: "end_date",
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
fieldtype: "Small Text",
|
||||
label: __("Description"),
|
||||
fieldname: "description",
|
||||
},
|
||||
],
|
||||
primary_action_label: __("Save"),
|
||||
primary_action: (values) => {
|
||||
create_class(values);
|
||||
},
|
||||
});
|
||||
dialog.show();
|
||||
};
|
||||
|
||||
const create_class = (values) => {
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.lms_class.lms_class.create_class",
|
||||
args: {
|
||||
title: values.title,
|
||||
start_date: values.start_date,
|
||||
end_date: values.end_date,
|
||||
description: values.description,
|
||||
},
|
||||
callback: (r) => {
|
||||
if (r.message) {
|
||||
frappe.show_alert({
|
||||
message: __("Class Created"),
|
||||
indicator: "green",
|
||||
});
|
||||
dialog.hide();
|
||||
window.location.href = `/classes/${r.message.name}`;
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@@ -61,6 +61,11 @@
|
||||
<!-- Class Sections -->
|
||||
{% macro ClassSections(class_info, class_courses, class_students, published_courses) %}
|
||||
<div class="mt-4">
|
||||
|
||||
<button class="btn btn-secondary btn-sm pull-right" id="create-class" data-class="{{ json.dumps(class_info) }}">
|
||||
{{ _("Edit") }}
|
||||
</button>
|
||||
|
||||
<ul class="nav lms-nav" id="classes-tab">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="tab" href="#courses">
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
<div class="common-page-style lms-page-style">
|
||||
<div class="container">
|
||||
{% if has_course_moderator_role() %}
|
||||
<a class="btn btn-secondary btn-sm pull-right" href="/class/new">
|
||||
<button class="btn btn-secondary btn-sm pull-right" id="create-class">
|
||||
{{ _("Create Class") }}
|
||||
</a>
|
||||
</button>
|
||||
{% endif %}
|
||||
<div class="course-home-headings"> {{ _("All Classes") }} </div>
|
||||
{% if classes %}
|
||||
@@ -27,6 +27,10 @@
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{%- block script %}
|
||||
{{ super() }}
|
||||
{{ include_script('controls.bundle.js') }}
|
||||
{% endblock %}
|
||||
|
||||
{% macro ClassCards(classes) %}
|
||||
<div class="lms-card-parent">
|
||||
|
||||
Reference in New Issue
Block a user