From a5ed0264355659d06ee87af201ff94d73151965e Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 28 Mar 2012 09:00:49 -0400 Subject: [PATCH] grid column picker cleanup Signed-off-by: Bill Erickson --- .../web/js/dojo/openils/widget/GridColumnPicker.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/widget/GridColumnPicker.js b/Open-ILS/web/js/dojo/openils/widget/GridColumnPicker.js index b8777034c9..00b5824bd4 100644 --- a/Open-ILS/web/js/dojo/openils/widget/GridColumnPicker.js +++ b/Open-ILS/web/js/dojo/openils/widget/GridColumnPicker.js @@ -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(); -- 2.11.0