From 612cef53646cf85ebac4417bfeef9437368dac93 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 6 Oct 2014 14:55:44 +0530 Subject: [PATCH 1/2] [minor] fix ux for report --- frappe/core/doctype/report/report.js | 38 ++++++++++++++------------ frappe/core/doctype/report/report.json | 19 +++++++------ 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/frappe/core/doctype/report/report.js b/frappe/core/doctype/report/report.js index 47cc2c4706..54888bec88 100644 --- a/frappe/core/doctype/report/report.js +++ b/frappe/core/doctype/report/report.js @@ -1,3 +1,23 @@ +cur_frm.cscript.report_type = function(doc) { + cur_frm.set_intro(""); + switch(doc.report_type) { + case "Report Builder": + cur_frm.set_intro(__("Report Builder reports are managed directly by the report builder. Nothing to do.")); + break; + case "Query Report": + cur_frm.set_intro(__("Write a SELECT query. Note result is not paged (all data is sent in one go).") + + __("To format columns, give column labels in the query.") + "
" + + __("[Label]:[Field Type]/[Options]:[Width]") + "

" + + __("Example:") + "
" + + "Employee:Link/Employee:200" + "
" + + "Rate:Currency:120" + "
") + break; + case "Script Report": + cur_frm.set_intro(__("Write a Python file in the same folder where this is saved and return column and result.")) + break; + } +} + cur_frm.cscript.refresh = function(doc) { cur_frm.add_custom_button("Show Report", function() { switch(doc.report_type) { @@ -28,21 +48,5 @@ cur_frm.cscript.refresh = function(doc) { }, doc.disabled ? "icon-ok" : "icon-off"); } - cur_frm.set_intro(""); - switch(doc.report_type) { - case "Report Builder": - cur_frm.set_intro(__("Report Builder reports are managed directly by the report builder. Nothing to do.")); - break; - case "Query Report": - cur_frm.set_intro(__("Write a SELECT query. Note result is not paged (all data is sent in one go).") - + __("To format columns, give column labels in the query.") + "
" - + __("[Label]:[Field Type]/[Options]:[Width]") + "

" - + __("Example:") + "
" - + "Employee:Link/Employee:200" + "
" - + "Rate:Currency:120" + "
") - break; - case "Script Report": - cur_frm.set_intro(__("Write a Python file in the same folder where this is saved and return column and result.")) - break; - } + cur_frm.cscript.report_type(doc); } diff --git a/frappe/core/doctype/report/report.json b/frappe/core/doctype/report/report.json index 3851d07c40..4dc86838fb 100644 --- a/frappe/core/doctype/report/report.json +++ b/frappe/core/doctype/report/report.json @@ -33,6 +33,13 @@ "read_only": 0, "reqd": 1 }, + { + "fieldname": "module", + "fieldtype": "Link", + "label": "Module", + "options": "Module Def", + "permlevel": 0 + }, { "fieldname": "add_total_row", "fieldtype": "Check", @@ -85,10 +92,11 @@ "read_only": 0 }, { - "depends_on": "eval:doc.report_type==\"Query Report\"", + "depends_on": "", "description": "JavaScript Format: frappe.query_reports['REPORTNAME'] = {}", "fieldname": "javascript", "fieldtype": "Code", + "hidden": 1, "label": "Javascript", "permlevel": 0 }, @@ -99,18 +107,11 @@ "label": "JSON", "permlevel": 0, "read_only": 1 - }, - { - "fieldname": "module", - "fieldtype": "Link", - "label": "Module", - "options": "Module Def", - "permlevel": 0 } ], "icon": "icon-table", "idx": 1, - "modified": "2014-06-03 07:25:41.509885", + "modified": "2014-10-06 03:40:35.556364", "modified_by": "Administrator", "module": "Core", "name": "Report", From 33f8941f7ce57c39d524fc30e102f2d693d7e83e Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 6 Oct 2014 15:04:12 +0530 Subject: [PATCH 2/2] [minor] fix ux for report --- frappe/core/doctype/report/test_records.json | 9 +++++++++ frappe/core/doctype/report/test_report.py | 10 ++++++++++ frappe/public/js/frappe/form/control.js | 4 ++++ frappe/public/js/frappe/ui/messages.js | 4 +++- 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 frappe/core/doctype/report/test_records.json create mode 100644 frappe/core/doctype/report/test_report.py diff --git a/frappe/core/doctype/report/test_records.json b/frappe/core/doctype/report/test_records.json new file mode 100644 index 0000000000..a2dc7fb71f --- /dev/null +++ b/frappe/core/doctype/report/test_records.json @@ -0,0 +1,9 @@ +[ + { + "doctype": "Report", + "name": "_Test Report 1", + "report_type": "Query Report", + "is_standard": "No", + "ref_doctype": "Event" + } +] diff --git a/frappe/core/doctype/report/test_report.py b/frappe/core/doctype/report/test_report.py new file mode 100644 index 0000000000..a1f65fb682 --- /dev/null +++ b/frappe/core/doctype/report/test_report.py @@ -0,0 +1,10 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# See license.txt + +import frappe +import unittest + +test_records = frappe.get_test_records('Report') + +class TestReport(unittest.TestCase): + pass diff --git a/frappe/public/js/frappe/form/control.js b/frappe/public/js/frappe/form/control.js index 7c96c5f0f9..f331a47e3d 100644 --- a/frappe/public/js/frappe/form/control.js +++ b/frappe/public/js/frappe/form/control.js @@ -596,6 +596,10 @@ frappe.ui.form.ControlAttach = frappe.ui.form.ControlData.extend({ }) }, onclick: function() { + if(this.doc && this.doc.__islocal) { + frappe.msgprint(__("Please save the document before uploading.")); + return; + } if(!this.dialog) { this.dialog = new frappe.ui.Dialog({ title: __(this.df.label || __("Upload")), diff --git a/frappe/public/js/frappe/ui/messages.js b/frappe/public/js/frappe/ui/messages.js index 4d6e5c0f26..838c5a61c7 100644 --- a/frappe/public/js/frappe/ui/messages.js +++ b/frappe/public/js/frappe/ui/messages.js @@ -53,7 +53,7 @@ frappe.get_value = function(field, callback) { } var msg_dialog=null; -function msgprint(msg, title) { +frappe.msgprint = function(msg, title) { if(!msg) return; if(msg instanceof Array) { @@ -104,6 +104,8 @@ function msgprint(msg, title) { return msg_dialog; } +var msgprint = frappe.msgprint; + // Floating Message function show_alert(txt, seconds) { if(!$('#dialog-container').length) {