feat: skip onboarding
This commit is contained in:
@@ -170,4 +170,4 @@
|
||||
"sort_order": "DESC",
|
||||
"states": [],
|
||||
"track_changes": 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,39 +7,4 @@ from frappe.model.document import Document
|
||||
|
||||
|
||||
class LMSSettings(Document):
|
||||
|
||||
pages = [
|
||||
{"label": "Explore", "idx": 1},
|
||||
{"label": "Courses", "url": "/courses", "parent": "Explore", "idx": 2},
|
||||
{"label": "Classes", "url": "/classes", "parent": "Explore", "idx": 3},
|
||||
{"label": "Statistics", "url": "/statistics", "parent": "Explore", "idx": 4},
|
||||
{"label": "Jobs", "url": "/jobs", "parent": "Explore", "idx": 5},
|
||||
{"label": "People", "url": "/community", "parent": "Explore", "idx": 6},
|
||||
]
|
||||
|
||||
def on_update(self):
|
||||
self.update_navbar()
|
||||
|
||||
def update_navbar(self):
|
||||
for page in self.pages:
|
||||
filters = frappe._dict()
|
||||
if page.get("url"):
|
||||
filters["url"] = ["like", "%" + page.get("url") + "%"]
|
||||
else:
|
||||
filters["label"] = page.get("label")
|
||||
|
||||
if self.add_to_navbar and not frappe.db.exists("Top Bar Item", filters):
|
||||
frappe.get_doc(
|
||||
{
|
||||
"doctype": "Top Bar Item",
|
||||
"label": page.get("label"),
|
||||
"url": page.get("url"),
|
||||
"parent_label": page.get("parent"),
|
||||
"idx": page.get("idx"),
|
||||
"parent": "Website Settings",
|
||||
"parenttype": "Website Settings",
|
||||
"parentfield": "top_bar_items",
|
||||
}
|
||||
).save()
|
||||
elif not self.add_to_navbar and frappe.db.exists("Top Bar Item", filters):
|
||||
frappe.db.delete("Top Bar Item", filters)
|
||||
pass
|
||||
|
||||
@@ -1911,3 +1911,10 @@ select {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.onboarding-skip {
|
||||
font-size: var(--text-sm);
|
||||
float: right;
|
||||
cursor: pointer;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
{% if has_course_moderator_role() and not is_onboarding_complete %}
|
||||
|
||||
{% set course_created = frappe.db.count("LMS Course") %}
|
||||
{% set first_course = frappe.db.get_all("LMS Course", order_by="creation", pluck="name")[0] %}
|
||||
{% set chapter_created = frappe.db.count("Course Chapter") %}
|
||||
{% set lesson_created = frappe.db.count("Course Lesson") %}
|
||||
{% set quiz_created = frappe.db.count("LMS Quiz") %}
|
||||
@@ -10,6 +11,7 @@
|
||||
|
||||
<div class="onboarding-parent">
|
||||
<div class="container">
|
||||
<div class="onboarding-skip">{{ _("Skip") }}</div>
|
||||
<h3 class="mt-0"> {{ _("Welcome") }} 🎉</h3>
|
||||
<div class="onboarding-subtitle">
|
||||
{{ _("Lets start setting up your content on the LMS so that you can reclaim time and focus on growth.") }}
|
||||
@@ -22,21 +24,21 @@
|
||||
</svg>
|
||||
{{ _("Create a Course") }}
|
||||
</a>
|
||||
<a class="onboarding-steps-link" {% if course_created %} href="" {% endif %}>
|
||||
<a class="onboarding-steps-link" {% if course_created %} href="/courses/{{ first_course }}?edit=1" {% endif %}>
|
||||
<svg class="icon icon-md">
|
||||
<use href="{% if chapter_created %} #icon-green-check-circled {% else %} #icon-disabled-check {% endif %}">
|
||||
</use>
|
||||
</svg>
|
||||
{{ _("Add a Chapter") }}
|
||||
</a>
|
||||
<a class="onboarding-steps-link" {% if chapter_created %} href="" {% endif %}>
|
||||
<a class="onboarding-steps-link" {% if chapter_created %} href="/courses/{{ first_course }}?edit=1" {% endif %}>
|
||||
<svg class="icon icon-md">
|
||||
<use href="{% if lesson_created %} #icon-green-check-circled {% else %} #icon-disabled-check {% endif %}">
|
||||
</use>
|
||||
</svg>
|
||||
{{ _("Add a Lesson") }}
|
||||
</a>
|
||||
<a class="onboarding-steps-link" {% if lesson_created %} href="" {% endif %}>
|
||||
<a class="onboarding-steps-link" {% if lesson_created %} href="/quizzes/new-quiz" {% endif %}>
|
||||
<svg class="icon icon-md">
|
||||
<use href="{% if quiz_created %} #icon-green-check-circled {% else %} #icon-disabled-check {% endif %}">
|
||||
</use>
|
||||
@@ -48,3 +50,29 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<script>
|
||||
frappe.ready(() => {
|
||||
|
||||
$(".onboarding-skip").click((e) => {
|
||||
skip_onboarding(e);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
const skip_onboarding = (e) => {
|
||||
frappe.call({
|
||||
method: "frappe.client.set_value",
|
||||
args: {
|
||||
doctype: "LMS Settings",
|
||||
name: "LMS Settings",
|
||||
fieldname: "is_onboarding_complete",
|
||||
value: 1,
|
||||
},
|
||||
freeze: true,
|
||||
callback: function (data) {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user