From 06c06a81cb32ffb78c6437114736cd3a575acd59 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Thu, 6 Sep 2018 14:04:45 +0530 Subject: [PATCH] [fix] Use frappe.call to get report data on ReportPage --- ui/pages/Report/index.vue | 42 +++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/ui/pages/Report/index.vue b/ui/pages/Report/index.vue index f278b6fc..35a3eb05 100644 --- a/ui/pages/Report/index.vue +++ b/ui/pages/Report/index.vue @@ -25,17 +25,39 @@ export default { } }, methods: { - getReportData(filters) { - frappe.methods[this.reportConfig.method](filters).then(data => { - if (this.datatable) { - this.datatable.refresh(data || []); - } else { - this.datatable = new DataTable(this.$refs.datatable, { - columns: this.reportColumns, - data: data || [] - }); - } + async getReportData(filters) { + let data = await frappe.call({ + method: this.reportConfig.method, + args: filters }); + + let rows, columns; + if (data.rows) { + rows = data.rows; + } else { + rows = data; + } + + if (data.columns) { + columns = data.columns; + } + + if (!rows) { + rows = []; + } + + if (!columns) { + columns = this.reportColumns; + } + + if (this.datatable) { + this.datatable.refresh(rows, columns); + } else { + this.datatable = new DataTable(this.$refs.datatable, { + columns: columns, + data: rows + }); + } } }, components: {