var stpicopen = '../../../../images/slimtree/folder.gif';
var stpicclose = '../../../../images/slimtree/folderopen.gif';
*/
-var stpicopen = '../../../../images/slimtree/folder2.gif';
-var stpicclose = '../../../../images/slimtree/folderopen2.gif';
-var stpicblank = '../../../../images/slimtree/page.gif';
-var stpicline = '../../../../images/slimtree/line.gif';
-var stpicjoin = '../../../../images/slimtree/join.gif';
-var stpicjoinb = '../../../../images/slimtree/joinbottom.gif';
+var stpicopen = '../opac/images/slimtree/folder2.gif';
+var stpicclose = '../opac/images/slimtree/folderopen2.gif';
+var stpicblank = '../opac/images/slimtree/page.gif';
+var stpicline = '../opac/images/slimtree/line.gif';
+var stpicjoin = '../opac/images/slimtree/join.gif';
+var stpicjoinb = '../opac/images/slimtree/joinbottom.gif';
var stimgopen = elem('img',{src:stpicopen,border:0});
this.cache[pid] = null;
}
-SlimTree.prototype.addNode = function( id, pid, name, action, title ) {
+SlimTree.prototype.addNode = function( id, pid, name, action, title, cls ) {
if( pid != -1 && !$(pid)) {
if(!this.cache[pid]) this.cache[pid] = new Array();
var actionref = elem('a',{href:action}, name);
var contdiv = elem('div',{id:'stcont_' + id});
+ if(cls) addCSSClass(actionref, cls);
+
actionref.setAttribute('href',action);
if(title) actionref.setAttribute('title',title);
else actionref.setAttribute('title',name);
+/** initializes reports, some basid display settings,
+ * grabs and builds the IDL tree
+ */
function oilsInitReportBuilder() {
oilsInitReports();
oilsRpt = new oilsReport();
);
}
+/* returns just the column name */
+function oilsRptPathCol(path) {
+ var parts = path.split(/-/);
+ return parts.pop();
+}
+/* returns the IDL class of the selected column */
+function oilsRptPathClass(path) {
+ var parts = path.split(/-/);
+ parts.pop();
+ return parts.pop();
+}
-function oilsRptSplitPath(path) {
+/* returns everything prior to the column name */
+function oilsRptPathRel(path) {
var parts = path.split(/-/);
- var column = parts.pop();
- return [ parts.join('-'), column ];
+ parts.pop();
+ return parts.join('-');
}
+/* creates a label "path" based on the column path */
function oilsRptMakeLabel(path) {
var parts = path.split(/-/);
var str = '';
} else {
var column = parts[i];
var data = oilsIDL[parts[i-1]];
- var f = grep(data.fields, function(j){return (j.name == column); })[0];
+ var f = grep(data.fields,
+ function(j){return (j.name == column); })[0];
str += ":"+f.label;
}
}
/* adds an item to the display window */
-function oilsAddRptDisplayItem(val, name) {
- if( ! oilsAddSelectorItem(oilsRptDisplaySelector, val, name) )
+function oilsAddRptDisplayItem(path, name) {
+ if( ! oilsAddSelectorItem(oilsRptDisplaySelector, path, name) )
return;
/* add the selected columns to the report output */
- var splitp = oilsRptSplitPath(val);
- name = (name) ? name : splitp[1];
+ name = (name) ? name : oilsRptPathCol(path);
var param = oilsRptNextParam();
- oilsRpt.def.select.push( {relation:splitp[0], column:splitp[1], alias:param} );
+
+ /* add this item to the select blob */
+ oilsRpt.def.select.push( {
+ relation:oilsRptPathRel(path),
+ column:oilsRptPathCol(path),
+ alias:param
+ });
+
+ mergeObjects( oilsRpt.def.from, oilsRptBuildFromClause(path));
oilsRpt.params[param] = name;
oilsRptDebug();
}
+/* takes a column path and builds a from-clause object for the path */
+function oilsRptBuildFromClause(path) {
+ var parts = path.split(/-/);
+ //var obj = {from : {}};
+ var obj = {};
+ var tobj = obj;
+ var newpath = "";
+ for( var i = 0; i < parts.length; i += 2 ) {
+ var cls = parts[i];
+ var col = parts[i+1];
+ var node = oilsIDL[parts[i]];
+ var field = oilsRptFindField(node, col);
+ newpath = (newpath) ? newpath + '-'+ cls : cls;
+
+ tobj.table = node.table;
+ tobj.alias = newpath;
+ _debug('field type is ' + field.type);
+ if( i == (parts.length - 2) ) break;
+
+ tobj.join = {};
+ tobj = tobj.join;
+ tobj[col] = {};
+ tobj = tobj[col];
+ if( field.type == 'link' )
+ tobj.key = field.key;
+
+ newpath = newpath + '-'+ col;
+ }
+
+ _debug("built 'from' clause: path="+path+"\n"+formatJSON(js2JSON(obj)));
+ return obj;
+}
+
+
/* removes a specific item from the display window */
function oilsDelDisplayItem(val) {
oilsDelSelectorItem(oilsRptDisplaySelector, val);
function(i) {
for( var j = 0; j < list.length; j++ ) {
var d = list[j];
- var arr = oilsRptSplitPath(d);
- if( arr[0] == i.relation && arr[1] == i.column ) {
+ if( oilsRptPathRel(d) == i.relation
+ && oilsRptPathCol(d) == i.column ) {
var param = (i.alias) ? i.alias.match(/::PARAM\d*/) : null;
if( param ) delete oilsRpt.params[param];
return false;
}
);
if(!oilsRpt.def.select) oilsRpt.def.select = [];
+
+ for( var j = 0; j < list.length; j++ )
+ oilsRptPruneFromClause(list[j]);
+
oilsRptDebug();
}
+/* for each item in the path list, remove the associated data
+from the "from" clause */
+function oilsRptPruneFromClause(pathlist) {
+}
/* adds an item to the display window */
function oilsAddRptFilterItem(val) {
return true;
}
+
/* removes a specific item from the display window */
function oilsDelSelectorItem(sel, val) {
_debug("deleting selector item "+val);
return list;
}
+
+/* hides the different field editor tabs */
function oilsRptHideEditorDivs() {
hideMe($('oils_rpt_tform_div'));
hideMe($('oils_rpt_filter_div'));
filter, and aggregate filter picker window
*/
function oilsRptDrawDataWindow(path) {
-
- var parts = path.split(/-/);
- var col = parts.pop();
- var cls = parts.pop();
+ var col = oilsRptPathCol(path);
+ var cls = oilsRptPathClass(path);
var field = grep(oilsIDL[cls].fields, function(f){return (f.name==col);})[0];
_debug("setting update data window for column "+col+' on class '+cls);
$('oils_rpt_tform_label_input').focus();
$('oils_rpt_tform_label_input').select();
+
+ if( field.datatype == 'timestamp' )
+ unHideMe($('oils_rpt_tform_date_div'));
}
r.send(null);
}
+function oilsRptFindField(node, field) {
+ return grep( node.fields,
+ function(f) {
+ return (f.name == field);
+ }
+ )[0];
+}
+
/* turns the IDL into a js object */
function oilsParseRptTree(IDL, callback) {
field : fields[i],
name : name,
label : field.getAttributeNS(oilsIDLReportsNS,'label'),
+ datatype : field.getAttributeNS(oilsIDLReportsNS,'datatype'),
type : 'field'
}
if( link ) {
obj.type = 'link';
- obj.reltype = link.getAttribute('reltype');
obj.key = link.getAttribute('key');
obj['class'] = link.getAttribute('class');
+ obj.reltype = link.getAttribute('reltype');
+ if( obj.reltype == 'might_have' ) continue;
} else {
if( fields[i].getAttributeNS(oilsIDLPersistNS, 'virtual') == 'true' )
continue;
}
obj.label = (obj.label) ? obj.label : obj.name;
+ obj.datatype = (obj.datatype) ? obj.datatype : 'string';
data.push(obj);
}
/* sort by field name */
data = data.sort(
function(a,b) {
- if( a.name > b.name ) return 1;
- if( a.name < b.name ) return -1;
+ if( a.label > b.label ) return 1;
+ if( a.label < b.name ) return -1;
return 0;
}
);
action = 'javascript:oilsAddLinkTree("' +
dataId+'","'+field['class']+'","'+fullpath+'");';
- oilsRptTree.addNode( dataId, subTreeId, field.label, action );
+ oilsRptTree.addNode( dataId, subTreeId, field.label, action, field.label,
+ (field.type == 'link') ? 'oils_rpt_tree_link_ref' : null );
}
}