From e06200400fc02e995c6a6f6fafebc9fbb7894f45 Mon Sep 17 00:00:00 2001 From: Vishnu VS Date: Mon, 30 Oct 2023 18:30:03 +0530 Subject: [PATCH] feat: added "Dashboard Chart" button (#22960) --- .../dashboard_chart_source.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/frappe/desk/doctype/dashboard_chart_source/dashboard_chart_source.js b/frappe/desk/doctype/dashboard_chart_source/dashboard_chart_source.js index 6f1fa36ffd..1349adaf74 100644 --- a/frappe/desk/doctype/dashboard_chart_source/dashboard_chart_source.js +++ b/frappe/desk/doctype/dashboard_chart_source/dashboard_chart_source.js @@ -1,4 +1,19 @@ // Copyright (c) 2019, Frappe Technologies and contributors // For license information, please see license.txt -frappe.ui.form.on("Dashboard Chart Source", {}); +frappe.ui.form.on("Dashboard Chart Source", { + refresh: function (frm) { + if (!frm.is_new()) { + frm.add_custom_button( + __("Dashboard Chart"), + function () { + let dashboard_chart = frappe.model.get_new_doc("Dashboard Chart"); + dashboard_chart.chart_type = "Custom"; + dashboard_chart.source = frm.doc.name; + frappe.set_route("Form", "Dashboard Chart", dashboard_chart.name); + }, + __("Create") + ); + } + }, +});