gave autogrid the ability to turn on the column picker
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 26 May 2009 17:46:50 +0000 (17:46 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 26 May 2009 17:46:50 +0000 (17:46 +0000)
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
Open-ILS/web/js/dojo/openils/widget/GridColumnPicker.js

index f984216..9908e4e 100644 (file)
@@ -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 : '&#x2713'
+                        name : '&#x2713',
+                        nonSelectable : true
                     });
                 }
 
index ae1924d..394a495 100644 (file)
@@ -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);