Push explicitly added columns to the top and keep the explicit order, then sort the... collab/miker/web-client-sprint1-cleanup
authorMike Rylander <mrylander@gmail.com>
Mon, 22 Sep 2014 16:03:48 +0000 (12:03 -0400)
committerMike Rylander <mrylander@gmail.com>
Mon, 22 Sep 2014 16:03:48 +0000 (12:03 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/web/js/ui/default/staff/services/grid.js

index 2dca409..9dc5b7d 100644 (file)
@@ -1039,6 +1039,15 @@ angular.module('egGridMod',
                         {idl_field : field, idl_class : class_obj});
                 });
 
+                cols.columns = cols.columns.sort(
+                    function(a, b) {
+                        if (a.explicit) return -1;
+                        if (b.explicit) return 1;
+                        return a.label < b.label ? -1 : 1;
+                    }
+                );
+
+
             } else {
                 console.error(
                     "egGrid: wildcard path does not resolve to an object: "
@@ -1090,6 +1099,8 @@ angular.module('egGridMod',
             if (column.path && column.path.match(/\*$/)) 
                 return cols.expandPath(colSpec);
 
+            if (!fromExpand) column.explicit = true;
+
             if (!column.name) column.name = column.path;
             if (!column.path) column.path = column.name;