Merge pull request #873 from rmehta/6-oct

[fixes] report ui and allow attach after save
This commit is contained in:
Rushabh Mehta 2014-10-07 10:28:20 +05:30
commit 778d424e22
6 changed files with 57 additions and 27 deletions

View file

@ -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.") + "<br>"
+ __("[Label]:[Field Type]/[Options]:[Width]") + "<br><br>"
+ __("Example:") + "<br>"
+ "Employee:Link/Employee:200" + "<br>"
+ "Rate:Currency:120" + "<br>")
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.") + "<br>"
+ __("[Label]:[Field Type]/[Options]:[Width]") + "<br><br>"
+ __("Example:") + "<br>"
+ "Employee:Link/Employee:200" + "<br>"
+ "Rate:Currency:120" + "<br>")
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);
}

View file

@ -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",

View file

@ -0,0 +1,9 @@
[
{
"doctype": "Report",
"name": "_Test Report 1",
"report_type": "Query Report",
"is_standard": "No",
"ref_doctype": "Event"
}
]

View file

@ -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

View file

@ -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")),

View file

@ -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) {