dynamic loading for reports

This commit is contained in:
Rushabh Mehta 2012-10-04 09:57:00 +05:30
parent d171a06e61
commit fde26470e6
4 changed files with 9 additions and 79 deletions

View file

@ -26,6 +26,8 @@ wn.pages['query-report'].onload = function(wrapper) {
title: 'Query Report',
single_column: true
});
wn.require("lib/js/wn/views/query_report.js");
wn.query_report = new wn.views.QueryReport({
parent: wrapper,

View file

@ -34,6 +34,7 @@
{
"public/js/report-legacy.js": [
"lib/public/js/legacy/widgets/tabbedpage.js",
"lib/public/js/legacy/widgets/report_builder/report_builder.js",
"lib/public/js/legacy/widgets/report_builder/datatable.js",
"lib/public/js/legacy/widgets/report_builder/calculator.js",
@ -124,12 +125,9 @@
"lib/public/js/wn/misc/about.js",
"lib/public/js/wn/views/doclistview.js",
"lib/public/js/wn/views/formview.js",
"lib/public/js/wn/views/reportview.js",
"lib/public/js/wn/views/grid_report.js",
"lib/public/js/wn/views/query_report.js",
"lib/public/js/wn/views/load_reportview.js",
"lib/public/js/legacy/widgets/dialog.js",
"lib/public/js/legacy/widgets/layout.js",
"lib/public/js/legacy/widgets/tabbedpage.js",
"lib/public/js/legacy/webpage/page_header.js",
"lib/public/js/legacy/widgets/tags.js",
"lib/public/js/legacy/widgets/export_query.js",

View file

@ -83,6 +83,8 @@ wn.assets = {
// this is virtual page load, only get the the source
// *without* the template
var t = src;
set_loading();
$.ajax({
url: t,
@ -95,7 +97,9 @@ wn.assets = {
wn.assets.add(src, txt);
},
async: false
})
});
hide_loading();
},
// pass on to the handler to set

View file

@ -1,77 +1,3 @@
// Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
//
// MIT License (MIT)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
wn.views.reportview = {
show: function(dt, rep_name) {
wn.require('js/report-legacy.js');
dt = get_label_doctype(dt);
if(!_r.rb_con) {
// first load
_r.rb_con = new _r.ReportContainer();
}
_r.rb_con.set_dt(dt, function(rb) {
if(rep_name) {
var route_changed = (rb.current_route != wn.get_route_str())
rb.load_criteria(rep_name);
// if loaded, then run
if(rb.dt && route_changed) {
rb.dt.run();
}
}
// show
if(!rb.forbidden) {
wn.container.change_to('Report Builder');
}
} );
}
}
// Routing Rules
// --------------
// `Report` shows list of all pages from which you can start a report + all saved reports
// (module wise)
// `Report/[doctype]` shows report for that doctype
// `Report/[doctype]/[report_name]` loads report with that name
wn.views.reportview2 = {
show: function(dt) {
var page_name = wn.get_route_str();
if(wn.pages[page_name]) {
wn.container.change_to(wn.pages[page_name]);
} else {
var route = wn.get_route();
if(route[1]) {
new wn.views.ReportViewPage(route[1], route[2]);
} else {
wn.set_route('404');
}
}
}
}
wn.views.ReportViewPage = Class.extend({
init: function(doctype, docname) {
this.doctype = doctype;