fix: add form tour settings to desk module.

This commit is contained in:
Maharshi Patel 2023-05-23 15:18:15 +05:30
parent 028508c947
commit 4e74051732
8 changed files with 175 additions and 0 deletions

View file

@ -0,0 +1,12 @@
// Copyright (c) 2023, Frappe Technologies and contributors
// For license information, please see license.txt
frappe.ui.form.on("Form Tour Settings", {
refresh(frm) {
frm.dashboard.add_comment(
"This page is used to set priority for the UI form tours. If there are more than 1 matching tours found for the page, the tour with the highest priority will run.",
"blue",
true
);
},
});

View file

@ -0,0 +1,51 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-05-11 18:07:26.879273",
"default_view": "List",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"onboarding_tours",
"form_tours"
],
"fields": [
{
"fieldname": "form_tours",
"fieldtype": "Table",
"label": "Form Tours",
"options": "Form Tour Settings Item"
},
{
"default": "\"[]\"",
"fieldname": "onboarding_tours",
"fieldtype": "JSON",
"hidden": 1,
"label": "Onboarding Tours"
}
],
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2023-05-17 16:45:21.362524",
"modified_by": "Administrator",
"module": "Core",
"name": "Form Tour Settings",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"print": 1,
"read": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}

View file

@ -0,0 +1,33 @@
# Copyright (c) 2023, Frappe Technologies and contributors
# For license information, please see license.txt
import json
import frappe
from frappe.model.document import Document
class FormTourSettings(Document):
def before_save(self):
self.onboarding_tours = json.dumps(
[[tour.form_tour, json.loads(tour.page_route)] for tour in self.form_tours]
)
@frappe.whitelist()
def update_user_status(value, step):
from frappe.utils.telemetry import capture
step = frappe.parse_json(step)
tour = frappe.parse_json(value)
# from frappe.utils.telemetry import capture
capture(
frappe.scrub(f"{step.parent}_{step.title}"),
app="frappe_ui_tours",
properties={
"is_completed": tour.is_completed
},
)
frappe.db.set_value(
"User", frappe.session.user, "onboarding_status", value, update_modified=False
)

View file

@ -0,0 +1,9 @@
# Copyright (c) 2023, Frappe Technologies and Contributors
# See license.txt
# import frappe
from frappe.tests.utils import FrappeTestCase
class TestFormTourSettings(FrappeTestCase):
pass

View file

@ -0,0 +1,61 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-05-11 18:10:15.194034",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"form_tour",
"view",
"list_view",
"page_route"
],
"fields": [
{
"fieldname": "form_tour",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Form Tour",
"options": "Form Tour",
"read_only": 1
},
{
"fetch_from": "form_tour.view_name",
"fieldname": "view",
"fieldtype": "Data",
"in_list_view": 1,
"label": "View",
"read_only": 1
},
{
"fetch_from": "form_tour.list_name",
"fieldname": "list_view",
"fieldtype": "Data",
"in_list_view": 1,
"label": "List View",
"read_only": 1
},
{
"fetch_from": "form_tour.page_route",
"fieldname": "page_route",
"fieldtype": "Data",
"hidden": 1,
"in_list_view": 1,
"label": "Page Route",
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-05-17 22:22:58.507769",
"modified_by": "Administrator",
"module": "Core",
"name": "Form Tour Settings Item",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}

View file

@ -0,0 +1,9 @@
# Copyright (c) 2023, Frappe Technologies and contributors
# For license information, please see license.txt
# import frappe
from frappe.model.document import Document
class FormTourSettingsItem(Document):
pass