From d997937e1a3778c3ec5837c9ee3c476b01489fee Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 26 Dec 2008 19:53:50 +0000 Subject: [PATCH] column settings are loaded and applied at page load time git-svn-id: svn://svn.open-ils.org/ILS/trunk@11682 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../web/js/dojo/openils/widget/GridColumnPicker.js | 42 ++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/widget/GridColumnPicker.js b/Open-ILS/web/js/dojo/openils/widget/GridColumnPicker.js index e0866c0a9d..632b96e260 100644 --- a/Open-ILS/web/js/dojo/openils/widget/GridColumnPicker.js +++ b/Open-ILS/web/js/dojo/openils/widget/GridColumnPicker.js @@ -35,6 +35,10 @@ if(!dojo._hasResource['openils.widget.GridColumnPicker']) { USER_PERSIST_SETTING : 'ui.grid_columns', + /** + * Load the fields from the grid and map them to the MenuItem's. + * Load settings from server + */ init : function(grid, persistPrefix, authtoken) { this.grid = grid; @@ -54,6 +58,7 @@ if(!dojo._hasResource['openils.widget.GridColumnPicker']) { } } ); + this.load(); }, onClose : function() { @@ -61,6 +66,9 @@ if(!dojo._hasResource['openils.widget.GridColumnPicker']) { this.persist(); }, + /** + * Save new settings on the server + */ persist : function() { var selected = []; var autoFields = []; @@ -82,7 +90,37 @@ if(!dojo._hasResource['openils.widget.GridColumnPicker']) { } } ); - } - } + }, + + /** + * Load existing settings from the server + */ + load : function() { + var self = this; + fieldmapper.standardRequest( + ['open-ils.actor', 'open-ils.actor.patron.settings.retrieve'], + { async: true, + params: [this.authtoken, null, this.USER_PERSIST_SETTING+'.'+this.persistPrefix], + oncomplete: function(r) { self._loadCallback(r); } + } + ); + }, + + _loadCallback : function(r) { + if(settings = openils.Util.readResponse(r)) { + dojo.forEach(this.getChildren(), + function(child) { + if(child.field) { + if(!openils.Util.arrayContains(settings.columns, child.field.ident)) { + child.attr("checked", false); + child.onChange(child.checked); + } + } + } + ); + } + }, + + } // class def ); } -- 2.11.0