!grep(oilsRpt.def.where, func) &&
!grep(oilsRpt.def.having, func) ) {
+ debug('looks like we can prune ' + path);
+
oilsRptPruneFromClause(oilsRptPathRel(pathlist[j]));
}
}
from the "from" clause */
function oilsRptPruneFromClause(relation, node) {
- _debug("removing relation from 'from' clause: " + relation);
+
+ var keys = oilsRptObjectKeys(node);
+ _debug("trying to remove relation: " + relation+'\n\tthis object has keys: '+keys);
+
if(!node) node = oilsRpt.def.from.join;
if(!node) return false;
for( var i in node ) {
- _debug("from prune looking at node "+node[i].path);
- // first, descend into the tree, and prune leaves first
- if( node[i].join ) {
- oilsRptPruneFromClause(relation, node[i].join);
- if(oilsRptObjectKeys(node[i].join).length == 0)
- delete node[i].join;
- }
- }
+ var child_node = node[i];
+ _debug("\tanalyzing child node: "+child_node.path);
- if(!node.join) {
+ // first, descend into the tree, and prune leaves
+ if( child_node.join ) {
- var key = oilsRptObjectKeys(node)[0];
- var from_alias = node[key].alias;
- var func = function(n){ return (n.relation == from_alias)};
+ oilsRptPruneFromClause(relation, child_node.join);
+ var join_keys = oilsRptObjectKeys(child_node.join);
+ _debug("\tchild has a sub-join for items : ["+ join_keys+"]");
- _debug("pruning from clause with alias "+ from_alias);
+ if(join_keys.length == 0) {
+ _debug("\tdeleting join for object "+i);
+ delete child_node.join;
+ }
+ }
- if( !grep(oilsRpt.def.select, func) &&
- !grep(oilsRpt.def.where, func) &&
- !grep(oilsRpt.def.having, func) ) {
+ if( !child_node.join ) {
- // if we're at an unused empty leaf, remove it
- delete node[i];
- return true;
+ _debug("\tchild node has no sub-join, seeing if we should delete it");
+
+ var from_alias = child_node.alias;
+ var func = function(n){ return (n.relation == from_alias)};
+
+ if( !grep(oilsRpt.def.select, func) &&
+ !grep(oilsRpt.def.where, func) &&
+ !grep(oilsRpt.def.having, func) ) {
+
+ /* we are not used by any other clauses */
+ _debug("\tdeleting node with relation: "+ from_alias);
+ delete node[i];
+ return true;
+ }
}
}
var mine = ( this.folderNode.folder.owner().id() == USER.id() );
- if( mine && this.type == 'template')
+ _debug('drawing folder window with type '+this.type);
+ if(mine) _debug('folder is mine...');
+
+ if( mine && this.type == 'template')
unHideMe(DOM.oils_rpt_folder_window_contents_new_template.parentNode);
else hideMe(DOM.oils_rpt_folder_window_contents_new_template.parentNode);
var res = r.getResultObject();
if( res.length == 0 ) {
- hideMe(DOM.oils_rpt_content_count_row);
+ //hideMe(DOM.oils_rpt_content_count_row); /* this also hides the new-template link.. fix me */
hideMe(DOM.oils_rpt_content_row);
unHideMe(DOM.oils_rpt_content_row_empty);
} else {
return "";
}
-/*
-function print_tabs(t) {
- var r = '';
- for (var j = 0; j < t; j++ ) { r = r + " "; }
- return r;
-}
-*/
-
function oilsRptDebug() {
if(!oilsRptDebugEnabled) return;
}
-
-/* pretty print JSON */
-/*
-function formatJSON(s) {
- var r = ''; var t = 0;
- for (var i in s) {
- if (s[i] == '{' || s[i] == '[' ) {
- r = r + s[i] + "\n" + print_tabs(++t);
- } else if (s[i] == '}' || s[i] == ']') {
- t--; r = r + "\n" + print_tabs(t) + s[i];
- } else if (s[i] == ',') {
- r = r + s[i] + "\n" + print_tabs(t);
- } else {
- r = r + s[i];
- }
- }
- return r;
-}
-*/
-
-
function print_tabs_html(t) {
var r = '';
for (var j = 0; j < t; j++ ) { r = r + " "; }
req.send();
}
-/*
-function oilsRptFetchReport(id, callback) {
- var req = new Request(OILS_RPT_FETCH_REPORT, SESSION, id);
- req.callback(function(r){ callback(r.getResultObject());});
- req.send();
-}
-*/
-
function oilsRptFetchReport(id, callback) {
var r = oilsRptGetCache('rr', id);
if(r) return callback(r);