grid column picker cleanup
authorBill Erickson <berick@esilibrary.com>
Wed, 28 Mar 2012 13:00:49 +0000 (09:00 -0400)
committerBill Erickson <berick@esilibrary.com>
Wed, 28 Mar 2012 13:00:49 +0000 (09:00 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/web/js/dojo/openils/widget/GridColumnPicker.js

index b877703..00b5824 100644 (file)
@@ -222,6 +222,7 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) {
                         delete cell.width;
                     }
                     displayCells.push(cell);
+
                 } else {
                     cell._visible = false;
                     delete cell.width;
@@ -232,15 +233,10 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) {
             this.grid.setStructure(this.structure);
             this.grid.update();
 
-            if (sortUpdated && this.onSortChange) {
-                var sortList = this.cells.filter(
-                    function(cella) { return cella._sort > 0 }).sort(
-                        function(a, b) { if (a._sort < b._sort) return -1; return 1; });
+            if (sortUpdated && this.onSortChange) 
                 this.onSortChange(this.buildSortList());
-            }
 
-            if(persist) 
-                this.persist(true);
+            if (persist) this.persist(true);
         },
 
         // extract cells that have sorting applied, order lowest to highest
@@ -297,12 +293,12 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) {
             );
         }, 
 
-        _loadColsFromSetting : function(setting) {
+        loadColsFromSetting : function(setting) {
             var _this = this;
             this.setting = setting;
             var displayCells = [];
             
-            // new component, existing settings will not have this
+            // new component, existing settings may not have this
             if (!setting.sort) setting.sort = [];
 
             dojo.forEach(setting.columns,
@@ -311,6 +307,7 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) {
                     if (cell) {
                         cell._visible = true;
                         displayCells.push(cell);
+
                         if(setting.auto.indexOf(cell.field) > -1) {
                             cell.width = 'auto';
                         } else {
@@ -318,6 +315,7 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) {
                                 delete cell.width;
                         }
                         cell._sort = setting.sort.indexOf(cell.field) + 1;
+
                     } else {
                         console.log('Unknown setting column '+col+'.  Ignoring...');
                     }
@@ -355,7 +353,7 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) {
             }
 
             if(this.setting)
-                return this._loadColsFromSetting(this.setting);
+                return this.loadColsFromSetting(this.setting);
 
             fieldmapper.standardRequest(
                 ['open-ils.actor', 'open-ils.actor.patron.settings.retrieve'],
@@ -364,7 +362,7 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) {
                     oncomplete: function(r) {
                         var set = openils.Util.readResponse(r);
                         if(set) {
-                            _this._loadColsFromSetting(set);
+                            _this.loadColsFromSetting(set);
                         } else {
                             _this.grid.setStructure(_this.structure);
                             _this.grid.update();