1 function oilsRptFolderManager(node) {
6 oilsRptFolderManager.prototype.draw = function(auth) {
7 var tree = oilsRptFolderTree =
8 new SlimTree(this.node, 'oilsRptFolderTree');
10 this.rootTreeId = oilsNextId();
11 this.templateTreeId = oilsNextId();
12 this.reportTreeId = oilsNextId();
13 this.outputTreeId = oilsNextId();
15 tree.addNode(this.rootTreeId, -1, 'Report Folders');
16 tree.addNode(this.templateTreeId, this.rootTreeId, 'Template Folders');
17 tree.addNode(this.reportTreeId, this.rootTreeId, 'Report Folders');
18 tree.addNode(this.outputTreeId, this.rootTreeId, 'Output Folders');
20 this.fetchFolders(auth);
23 oilsRptFolderManager.prototype.fetchFolders = function(auth) {
25 var req = new Request(OILS_RPT_FETCH_FOLDERS, auth, 'template');
26 req.callback( function(r) { obj.drawFolders('template', r.getResultObject()); } );
29 var req = new Request(OILS_RPT_FETCH_FOLDERS, auth, 'report');
30 req.callback( function(r) { obj.drawFolders('report', r.getResultObject()); } );
33 var req = new Request(OILS_RPT_FETCH_FOLDERS, auth, 'output');
34 req.callback( function(r) { obj.drawFolders('output', r.getResultObject()); } );
39 oilsRptFolderManager.prototype.drawFolders = function(type, folders) {
40 _debug('making folder tree '+type);
42 case 'template': tid = this.templateTreeId; break;
43 case 'report': tid = this.reportTreeId; break;
44 case 'output': tid = this.outputTreeId; break;
46 this.folderTree[type] = { children : [] };
47 this.makeTree(type, folders, this.folderTree[type], tid );
51 /* builds an in-memory version of the folder trees as well as the UI trees */
52 oilsRptFolderManager.prototype.makeTree = function(type, folders, node, parentId) {
58 childNodes = grep(folders, function(f){return (!f.parent())});
61 _debug("making subtree with folder "+node.folder.name());
64 oilsRptFolderTree.addNode(id, parentId, node.folder.name());
67 childNodes = grep(folders,
68 function(i){return (i.parent() == node.folder.id())});
70 var req = new Request(OILS_RPT_FETCH_FOLDER_DATA,SESSION,type,node.folder.id());
75 if(!childNodes) return;
76 for( var i = 0; i < childNodes.length; i++ )
77 this.makeTree( type, folders, { folder : childNodes[i] }, id );
80 //oilsRptFolderManager.prototype.make