Enable "map" field support in reporter user/tsbere/reporter_map
authorThomas Berezansky <tsbere@mvlc.org>
Tue, 24 Jan 2012 21:04:06 +0000 (16:04 -0500)
committerThomas Berezansky <tsbere@mvlc.org>
Tue, 24 Jan 2012 21:04:06 +0000 (16:04 -0500)
In the IDL the "map" lets you logically skip a table, but previously
blocked the reporter from accessing the link.

This enables use of those links in the reporting module.

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Open-ILS/web/reports/xul/source-browse.js

index 4075dd1..e823241 100644 (file)
@@ -41,8 +41,24 @@ function sourceTreeHandler (ev, dbl) {
                                var link = link_fields[i].getAttribute('field');
                                var key = link_fields[i].getAttribute('key');
                                var reltype = link_fields[i].getAttribute('reltype');
-
-                               if (map) continue;
+                               var via = null;
+                               var via_field = null;
+
+                               if (map) {
+                                       via = idlclass;
+                                       via_link = link;
+                                       via_field = field.getAttribute('name');
+                                       var temp_class = getIDLClass(via);
+                                       var temp_links = temp_class.getElementsByTagName('link');
+                                       for ( var j = 0; j < temp_links.length; j++ ) {
+                                               if (temp_links[j].getAttribute('field') == map) {
+                                                       idlclass = temp_links[j].getAttribute('class');
+                                                       link = temp_links[j].getAttribute('field');
+                                                       field = getIDLField( temp_class, link );
+                                                       if (!field) continue;
+                                               }
+                                       }
+                               }
 
                                var pathList = [];
                                findAncestorStack( item, 'treeitem', pathList );
@@ -52,7 +68,15 @@ function sourceTreeHandler (ev, dbl) {
                                for (var j in pathList.reverse()) {
                                        var n = pathList[j].getAttribute('idlclass');
                                        var f = pathList[j].getAttribute('field');
+                                       var v = pathList[j].getAttribute('via');
+                                       var vf = pathList[j].getAttribute('via_field');
                                        var j = pathList[j].getAttribute('join');
+                                       if (v) {
+                                               if (vf) fullpath += "-" + vf;
+                                               if (vf && j != 'undefined') fullpath += '>' + j;
+                                               if (fullpath) fullpath += ".";
+                                               fullpath += v;
+                                       }
 
                                        if (f) fullpath += "-" + f;
                                        if (f && j != 'undefined') fullpath += '>' + j;
@@ -62,6 +86,10 @@ function sourceTreeHandler (ev, dbl) {
 
                                }
 
+                               if(via) {
+                                       fullpath += "-" + via_field + "." + via;
+                               }
+
                                fullpath += "-" + link;
 
                                subtreeList.push(
@@ -73,7 +101,9 @@ function sourceTreeHandler (ev, dbl) {
                                          field : field.getAttribute('name'),
                                          reltype : reltype,
                                          link : link,
-                                         fullpath : fullpath
+                                         fullpath : fullpath,
+                                         via : via,
+                                         via_field : via_field
                                        }
                                );
 
@@ -89,7 +119,9 @@ function sourceTreeHandler (ev, dbl) {
                                                  field : field.getAttribute('name'),
                                                  reltype : reltype,
                                                  link : link,
-                                                 fullpath : fullpath + '>right'
+                                                 fullpath : fullpath + '>right',
+                                                 via : via,
+                                                 via_field : via_field
                                                }
                                        );
        
@@ -103,7 +135,9 @@ function sourceTreeHandler (ev, dbl) {
                                                  field : field.getAttribute('name'),
                                                  reltype : reltype,
                                                  link : link,
-                                                 fullpath : fullpath + '>inner'
+                                                 fullpath : fullpath + '>inner',
+                                                 via : via,
+                                                 via_field : via_field
                                                }
                                        );
        
@@ -118,7 +152,9 @@ function sourceTreeHandler (ev, dbl) {
                                                  field : field.getAttribute('name'),
                                                  reltype : reltype,
                                                  link : link,
-                                                 fullpath : fullpath + '>left'
+                                                 fullpath : fullpath + '>left',
+                                                 via : via,
+                                                 via_field : via_field
                                                }
                                        );
        
@@ -132,7 +168,9 @@ function sourceTreeHandler (ev, dbl) {
                                                  field : field.getAttribute('name'),
                                                  reltype : reltype,
                                                  link : link,
-                                                 fullpath : fullpath + '>inner'
+                                                 fullpath : fullpath + '>inner',
+                                                 via : via,
+                                                 via_field : via_field
                                                }
                                        );