From 02e81f62cfc5cf477ef0f7eadbc0566bf58301c8 Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 26 May 2009 17:46:50 +0000 Subject: [PATCH] gave autogrid the ability to turn on the column picker git-svn-id: svn://svn.open-ils.org/ILS/trunk@13234 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/dojo/openils/widget/AutoGrid.js | 17 ++++++++++++++++- Open-ILS/web/js/dojo/openils/widget/GridColumnPicker.js | 14 ++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js b/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js index f98421645..9908e4eee 100644 --- a/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js +++ b/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js @@ -5,6 +5,7 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) { dojo.require('openils.widget.AutoFieldWidget'); dojo.require('openils.widget.EditPane'); dojo.require('openils.widget.EditDialog'); + dojo.require('openils.widget.GridColumnPicker'); dojo.require('openils.Util'); dojo.declare( @@ -19,6 +20,8 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) { suppressFields : null, hideSelector : false, selectorWidth : '1.5', + showColumnPicker : false, + columnPickerPrefix : null, /* by default, don't show auto-generated (sequence) fields */ showSequenceFields : false, @@ -31,8 +34,19 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) { this.initAutoEnv(); this.attr('structure', this._compileStructure()); this.setStore(this.buildAutoStore()); + + if(this.showColumnPicker) { + if(!this.columnPickerPrefix) { + console.error("No columnPickerPrefix defined"); + } else { + new openils.widget.GridColumnPicker( + openils.User.authtoken, this.columnPickerPrefix, this).load(); + } + } + this.overrideEditWidgets = {}; this.overrideEditWidgetClass = {}; + if(this.editOnEnter) this._applyEditOnEnter(); else if(this.singleEditStyle) @@ -77,7 +91,8 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) { formatter : function(rowIdx) { return self._formatRowSelectInput(rowIdx); }, get : function(rowIdx, item) { if(item) return rowIdx; }, width : this.selectorWidth, - name : '✓' + name : '✓', + nonSelectable : true }); } diff --git a/Open-ILS/web/js/dojo/openils/widget/GridColumnPicker.js b/Open-ILS/web/js/dojo/openils/widget/GridColumnPicker.js index ae1924dd6..394a49571 100644 --- a/Open-ILS/web/js/dojo/openils/widget/GridColumnPicker.js +++ b/Open-ILS/web/js/dojo/openils/widget/GridColumnPicker.js @@ -144,9 +144,12 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) { var selector = dojo.query('[name=selector]', row)[0]; var width = dojo.query('[name=width]', row)[0]; if(selector.checked && selector.getAttribute('ident') == cell.field+''+cell.name) { - if(width.checked) + if(width.checked) { cell.width = 'auto'; - else delete cell.width; + } else { + if(cell.width == 'auto') + cell.width; + } newCellList.push(cell); } } @@ -218,9 +221,12 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) { if(cell.selectableColumn) { if(this._arrayHas(setting.columns, cell.field)) { newCellList.push(cell); - if(this._arrayHas(setting.auto, cell.field)) + if(this._arrayHas(setting.auto, cell.field)) { cell.width = 'auto'; - else delete cell.width; + } else { + if(cell.width == 'auto') + delete cell.width; + } } } else { // if it's not selectable, always show it newCellList.push(cell); -- 2.11.0