diff --git a/frappe/core/page/dashboard/dashboard.css b/frappe/core/page/dashboard/dashboard.css index 4bf25592f6..66a7e8aa36 100644 --- a/frappe/core/page/dashboard/dashboard.css +++ b/frappe/core/page/dashboard/dashboard.css @@ -3,4 +3,14 @@ border-radius: 4px; margin: 15px 0; padding: 15px; +} + +.chart-actions { + position: absolute; + right: 30px; + top: 30px; +} + +.chart-column-container { + position: relative; } \ No newline at end of file diff --git a/frappe/core/page/dashboard/dashboard.js b/frappe/core/page/dashboard/dashboard.js index 58c14ce350..264498d30a 100644 --- a/frappe/core/page/dashboard/dashboard.js +++ b/frappe/core/page/dashboard/dashboard.js @@ -65,12 +65,49 @@ class Dashboard { } render_chart(chart, data) { + chart.filter_fields = JSON.parse(chart.filter_fields || '[]') + chart.filters_json = JSON.parse(chart.filters_json || '{}') + const column_width_map = { "Half": "6", "Full": "12", }; let columns = column_width_map[chart.width]; - let chart_container = $(`
`); + let actions = [ + { + label: __("More"), + action: "more", + handler() { + const d = new frappe.ui.Dialog({ + title: __('Set Filters'), + fields: chart.filter_fields + }) + d.set_values(chart.filters_json) + d.show(); + } + } + ] + + let chart_action = $(` + `); + + chart_action.find("a[data-action]").each((i, o) => { + const action = o.dataset.action + $(o).click(actions.find(a => a.action === action)) + }) + + + let chart_container = $(`
+
+
`); + chart_action.prependTo(chart_container) chart_container.appendTo(this.container); diff --git a/frappe/desk/doctype/dashboard_chart/dashboard_chart.json b/frappe/desk/doctype/dashboard_chart/dashboard_chart.json index 13f089d904..b6ac598854 100644 --- a/frappe/desk/doctype/dashboard_chart/dashboard_chart.json +++ b/frappe/desk/doctype/dashboard_chart/dashboard_chart.json @@ -129,6 +129,7 @@ "label": "Filters JSON", "length": 0, "no_copy": 0, + "options": "JSON", "permlevel": 0, "precision": "", "print_hide": 0, @@ -206,6 +207,39 @@ "set_only_once": 0, "translatable": 0, "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "filter_fields", + "fieldtype": "Code", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Filter Fields", + "length": 0, + "no_copy": 0, + "options": "JSON", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, + "unique": 0 } ], "has_web_view": 0, @@ -218,7 +252,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2019-01-16 14:33:08.565174", + "modified": "2019-01-16 15:22:10.760396", "modified_by": "Administrator", "module": "Desk", "name": "Dashboard Chart",