blob: ef83cf61d4456a11ac06dce419a6e48b49d3414d [file] [log] [blame]
Ankush Menat70458102023-09-15 20:46:39 +05301frappe.provide("erpnext.demo");
2
Ankush Menat8bdf2802023-08-10 17:55:15 +05303$(document).on("toolbar_setup", function () {
Deepesh Garg371413a2023-07-29 22:39:07 +05304 if (frappe.boot.sysdefaults.demo_company) {
Ankush Menat70458102023-09-15 20:46:39 +05305 render_clear_demo_action();
Deepesh Garg371413a2023-07-29 22:39:07 +05306 }
Deepesh Gargbb5387f2023-07-07 10:49:56 +05307});
8
Ankush Menat70458102023-09-15 20:46:39 +05309function render_clear_demo_action() {
10 let demo_action = $(
11 `<a class="dropdown-item" onclick="return erpnext.demo.clear_demo()">
12 ${__("Clear Demo Data")}
13 </a>`
Ankush Menat8bdf2802023-08-10 17:55:15 +053014 );
Ankush Menat2d3fa802023-08-12 11:33:35 +053015
Ankush Menat70458102023-09-15 20:46:39 +053016 demo_action.appendTo($("#toolbar-user"));
Ankush Menat6b464ed2023-08-12 11:21:33 +053017}
Ankush Menat70458102023-09-15 20:46:39 +053018
19erpnext.demo.clear_demo = function () {
20 frappe.confirm(__("Are you sure you want to clear all demo data?"), () => {
21 frappe.call({
22 method: "erpnext.setup.demo.clear_demo_data",
23 freeze: true,
24 freeze_message: __("Clearing Demo Data..."),
25 callback: function (r) {
26 frappe.ui.toolbar.clear_cache();
27 frappe.show_alert({
28 message: __("Demo data cleared"),
29 indicator: "green",
30 });
31 },
32 });
33 });
34};