From 2d61ec98daea2b0278fdddb2a08a297cf304dfec Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 28 Mar 2012 11:25:02 -0400 Subject: [PATCH] grid column picker cleanup Signed-off-by: Bill Erickson --- .../web/js/dojo/openils/widget/GridColumnPicker.js | 27 ++++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/widget/GridColumnPicker.js b/Open-ILS/web/js/dojo/openils/widget/GridColumnPicker.js index 34ea285131..0b4c2b14a3 100644 --- a/Open-ILS/web/js/dojo/openils/widget/GridColumnPicker.js +++ b/Open-ILS/web/js/dojo/openils/widget/GridColumnPicker.js @@ -32,6 +32,7 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) { USER_PERSIST_SETTING : 'ui.grid_columns', constructor : function (authtoken, persistKey, grid, structure) { + var _this = this; this.grid = grid; this.persistKey = this.USER_PERSIST_SETTING+'.'+persistKey; this.authtoken = authtoken || openils.User.authtoken; @@ -41,10 +42,15 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) { this.dialog = this.buildDialog(); this.dialogTable = this.dialog.containerNode.getElementsByTagName('tbody')[0]; - // replace me - this.onSortChange = function(list) {console.log('onSortChange : ' + list)} + // replace: called after any sort changes + this.onSortChange = function(list) {console.log('onSortChange()')} + // replace: called after user settings are first retrieved + this.onLoad = function(opts) {console.log('onLoad()')}; + + // internal onload handler + this.loaded = false; + this._onLoad = function(opts) {_this.loaded = true; _this.onLoad(opts)}; - var _this = this; this.grid.onHeaderContextMenu = function(e) { _this.build(); _this.dialog.show(); @@ -187,7 +193,7 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) { // this must be added after its parent node is inserted into the DOM. var ns = new dijit.form.NumberSpinner( { constraints : {min : 0, places : 0}, - value : 0, + value : cell._sort, style : 'width:4em', name : 'sort' }, ipt3 @@ -333,9 +339,6 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) { this.structure[0].cells[0] = displayCells; this.grid.setStructure(this.structure); this.grid.update(); - - if (this.setting.sort && this.setting.sort.length > 0 && this.onSortChange) - this.onSortChange(this.buildSortList()); }, load : function() { @@ -347,13 +350,16 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) { var _this = this; openils.Util.addOnLoad(function() { _this.authtoken = openils.User.authtoken; - _this.load() + _this.load(); }); return; } - if(this.setting) - return this.loadColsFromSetting(this.setting); + if(this.setting) { + this.loadColsFromSetting(this.setting); + this._onLoad({sortFields : this.buildSortList()}); + return; + } fieldmapper.standardRequest( ['open-ils.actor', 'open-ils.actor.patron.settings.retrieve'], @@ -367,6 +373,7 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) { _this.grid.setStructure(_this.structure); _this.grid.update(); } + _this._onLoad({sortFields : _this.buildSortList()}); } } ); -- 2.11.0