[open-ils-commits] r12768 - trunk/Open-ILS/web/js/dojo/openils/widget (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Apr 2 17:25:50 EDT 2009


Author: erickson
Date: 2009-04-02 17:25:45 -0400 (Thu, 02 Apr 2009)
New Revision: 12768

Modified:
   trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
Log:
implemented select/deselect all.  removed some debugging.  disable sort when clicking on selector column header

Modified: trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js	2009-04-02 20:16:39 UTC (rev 12767)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js	2009-04-02 21:25:45 UTC (rev 12768)
@@ -25,6 +25,8 @@
 
             startup : function() {
                 this.selectionMode = 'single';
+                this.sequence = openils.widget.AutoGrid.sequence++;
+                openils.widget.AutoGrid.gridCache[this.sequence] = this;
                 this.inherited(arguments);
                 this.initAutoEnv();
                 this.setStructure(this._compileStructure());
@@ -35,10 +37,21 @@
                     this._applyEditOnEnter();
                 else if(this.singleEditStyle) 
                     this._applySingleEditStyle();
-                this.sequence = openils.widget.AutoGrid.sequence++;
-                openils.widget.AutoGrid.gridCache[this.sequence] = this;
+
+                if(!this.hideSelector) {
+                    var header = this.layout.cells[0].view.getHeaderCellNode(0);
+                    var self = this;
+                    header.onclick = function() { self.toggleSelectAll(); }
+                }
             },
 
+            /* Don't allow sorting on the selector column */
+            canSort : function(rowIdx) {
+                if(rowIdx == 1 && !this.hideSelector)
+                    return false;
+                return true;
+            },
+
             _compileStructure : function() {
                 var existing = (this.structure && this.structure[0].cells[0]) ? 
                     this.structure[0].cells[0] : [];
@@ -63,10 +76,11 @@
                         field : '+selector',
                         get : function(rowIdx, item) { return self._buildRowSelectInput(rowIdx, item); },
                         width : this.selectorWidth,
-                        name : '✓'
+                        name : '&#x2713'
                     });
                 }
 
+
                 if(!this.fieldOrder) {
                     /* no order defined, start with any explicit grid fields */
                     for(var e in existing) {
@@ -108,8 +122,19 @@
                 return [{cells: [fields]}];
             },
 
+            toggleSelectAll : function() {
+                var selected = this.getSelectedRows();
+                for(var i = 0; i < this.rowCount; i++) {
+                    if(selected[0])
+                        this.deSelectRow(i);
+                    else
+                        this.selectRow(i);
+                }
+            },
+
             getSelectedRows : function() {
-                var rows = []; dojo.forEach(
+                var rows = []; 
+                dojo.forEach(
                     dojo.query('[name=autogrid.selector]', this.domNode),
                     function(input) {
                         if(input.checked)
@@ -193,10 +218,6 @@
 
                 dojo.connect(this, 'onKeyDown',
                     function(e) {
-                        if(dojo.keys.UP_ARROW) {
-                            console.log("up arrow");
-                            console.log(this.getSelectedRows() + ' : ' + this.focus.rowIndex);
-                        }
                         if(e.keyCode == dojo.keys.ENTER) {
                             this.selection.deselectAll();
                             this.selection.select(this.focus.rowIndex);



More information about the open-ils-commits mailing list