grid top-level wildcards
authorBill Erickson <berick@esilibrary.com>
Mon, 30 Jun 2014 20:21:57 +0000 (16:21 -0400)
committerBill Erickson <berick@esilibrary.com>
Mon, 30 Jun 2014 20:21:57 +0000 (16:21 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/web/js/ui/default/staff/services/grid.js

index a11c397..545312c 100644 (file)
@@ -957,7 +957,7 @@ angular.module('egGridMod',
         // position in the path.
         cols.expandPath = function(colSpec) {
 
-            var dotpath = colSpec.path.replace(/\.\*$/,'');
+            var dotpath = colSpec.path.replace(/\.?\*$/,'');
             var class_obj;
 
             if (colSpec.parentIdlClass) {
@@ -972,22 +972,24 @@ angular.module('egGridMod',
 
                 // find the IDL class definition for the last element in the
                 // path before the .*
-                var class_obj;
-                for (var path_idx in path_parts) {
-                    var part = path_parts[path_idx];
-                    var idl_field = class_obj.field_map[part];
-
-                    // unless we're at the end of the list, this field should
-                    // link to another class.
-                    if (idl_field && idl_field['class'] && (
-                        idl_field.datatype == 'link' || 
-                        idl_field.datatype == 'org_unit')) {
-                        class_obj = egCore.idl.classes[idl_field['class']];
-                    } else {
-                        if (path_idx < (path_parts.length - 1)) {
-                            // we ran out of classes to hop through before
-                            // we ran out of path components
-                            console.error("egGrid: invalid IDL path: " + path);
+                // an empty path_parts means expand the root class
+                if (path_parts) {
+                    for (var path_idx in path_parts) {
+                        var part = path_parts[path_idx];
+                        var idl_field = class_obj.field_map[part];
+
+                        // unless we're at the end of the list, this field should
+                        // link to another class.
+                        if (idl_field && idl_field['class'] && (
+                            idl_field.datatype == 'link' || 
+                            idl_field.datatype == 'org_unit')) {
+                            class_obj = egCore.idl.classes[idl_field['class']];
+                        } else {
+                            if (path_idx < (path_parts.length - 1)) {
+                                // we ran out of classes to hop through before
+                                // we ran out of path components
+                                console.error("egGrid: invalid IDL path: " + dotpath);
+                            }
                         }
                     }
                 }
@@ -1056,7 +1058,7 @@ angular.module('egGridMod',
 
             var column = fromExpand ? colSpec : cols.cloneFromScope(colSpec);
 
-            if (column.path && column.path.match(/\*/)) 
+            if (column.path && column.path.match(/\*$/)) 
                 return cols.expandPath(colSpec);
 
             if (!column.name) column.name = column.path;