From c02a9abd5df7a8d309527089ee8d22be297c8440 Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 2 Apr 2009 21:25:45 +0000 Subject: [PATCH] implemented select/deselect all. removed some debugging. disable sort when clicking on selector column header git-svn-id: svn://svn.open-ils.org/ILS/trunk@12768 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/dojo/openils/widget/AutoGrid.js | 37 +++++++++++++++++++------ 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js b/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js index 24c413b8a3..e2f1d63404 100644 --- a/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js +++ b/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js @@ -25,6 +25,8 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) { 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,8 +37,19 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) { 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() { @@ -63,10 +76,11 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) { field : '+selector', get : function(rowIdx, item) { return self._buildRowSelectInput(rowIdx, item); }, width : this.selectorWidth, - name : '✓' + name : '✓' }); } + if(!this.fieldOrder) { /* no order defined, start with any explicit grid fields */ for(var e in existing) { @@ -108,8 +122,19 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) { 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 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) { 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); -- 2.11.0