From a9eb28f73c106374781496d438287943fd788868 Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 18 Sep 2008 18:09:43 +0000 Subject: [PATCH] adding initial grid column picker logic and plugged into queued records grid. also moved some filter options on the queue grid around for ease of use git-svn-id: svn://svn.open-ils.org/ILS/trunk@10637 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/dojo/openils/GridColumnPicker.js | 125 +++++++++++++++++++++++ Open-ILS/web/vandelay/vandelay.html | 85 +++++++++++---- Open-ILS/web/vandelay/vandelay.js | 39 ++++--- 3 files changed, 213 insertions(+), 36 deletions(-) create mode 100644 Open-ILS/web/js/dojo/openils/GridColumnPicker.js diff --git a/Open-ILS/web/js/dojo/openils/GridColumnPicker.js b/Open-ILS/web/js/dojo/openils/GridColumnPicker.js new file mode 100644 index 0000000000..7ba129dd40 --- /dev/null +++ b/Open-ILS/web/js/dojo/openils/GridColumnPicker.js @@ -0,0 +1,125 @@ +/* --------------------------------------------------------------------------- + * Copyright (C) 2008 Georgia Public Library Service + * Bill Erickson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * --------------------------------------------------------------------------- + */ + +if(!dojo._hasResource["openils.GridColumnPicker"]) { + dojo._hasResource["openils.GridColumnPicker"] = true; + dojo.provide('openils.GridColumnPicker'); + dojo.declare('openils.GridColumnPicker', null, { + + constructor : function (dialog, grid) { + this.dialog = dialog; + this.grid = grid; + this.structure = grid.structure; + this.dialogTable = dialog.domNode.getElementsByTagName('tbody')[0]; + this.baseCellList = this.structure[0].cells[0].slice(); + this.build(); + this.grid.model.fields.get(0).sort = false; + }, + + // builds the column-picker dialog table + build : function() { + var cells = this._selectableCellList(); + var str = ''; + var rows = dojo.query('tr', this.dialogTable); + + for(var i = 0; i < rows.length; i++) { + if(rows[i].getAttribute('picker')) + this.dialogTable.removeChild(rows[i]); + } + + rows = dojo.query('tr', this.dialogTable); + var lastChild = null; + if(rows.length > 0) + lastChild = rows[rows.length-1]; + + for(var i = 0; i < cells.length; i++) { + // setting table.innerHTML breaks stuff, so do it the hard way + tr = document.createElement('tr'); + tr.setAttribute('picker', 'picker'); + td1 = document.createElement('td'); + td2 = document.createElement('td'); + td3 = document.createElement('td'); + + ipt = document.createElement('input'); + ipt.setAttribute('type', 'checkbox'); + ipt.setAttribute('checked', 'checked'); + ipt.setAttribute('ident', cells[i].field+''+cells[i].name); + ipt.setAttribute('name', 'selector'); + + ipt2 = document.createElement('input'); + ipt2.setAttribute('type', 'checkbox'); + ipt2.setAttribute('ident', cells[i].field+''+cells[i].name); + ipt2.setAttribute('name', 'width'); + + td1.appendChild(document.createTextNode(cells[i].name)); + td2.appendChild(ipt); + td3.appendChild(ipt2); + tr.appendChild(td1); + tr.appendChild(td2); + tr.appendChild(td3); + if(lastChild) + this.dialogTable.insertBefore(tr, lastChild); + else + this.dialogTable.appendChild(tr); + } + }, + + // update the grid based on the items selected in the picker dialog + update : function() { + var newCellList = []; + var rows = dojo.query('[picker=picker]', this.dialogTable); + + for(var j = 0; j < this.baseCellList.length; j++) { + var cell = this.baseCellList[j]; + if(cell.selectableColumn) { + for(var i = 0; i < rows.length; i++) { + var row = rows[i]; + 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) + cell.width = 'auto'; + else delete cell.width; + newCellList.push(cell); + } + } + } else { // if it's not selectable, always show it + newCellList.push(cell); + } + } + + this.structure[0].cells[0] = newCellList; + this.grid.setStructure(this.structure); + this.grid.update(); + }, + + _selectableCellList : function() { + var cellList = this.structure[0].cells[0]; + var cells = []; + for(var i = 0; i < cellList.length; i++) { + var cell = cellList[i]; + if(cell.selectableColumn) + cells.push({name:cell.name, field:cell.field}); + } + return cells; + }, + + // save me as a user setting + persist : function() { + } + }); +} + diff --git a/Open-ILS/web/vandelay/vandelay.html b/Open-ILS/web/vandelay/vandelay.html index a2c7dcd115..47b9f79772 100644 --- a/Open-ILS/web/vandelay/vandelay.html +++ b/Open-ILS/web/vandelay/vandelay.html @@ -19,7 +19,9 @@ @import "/js/dojo/dijit/themes/tundra/tundra.css"; @import "/js/dojo/dijit/tests/css/dijitTests.css"; @import "/js/dojo/dojox/grid/_grid/Grid.css"; - td { padding: 6px; } + .container:after {content: ""; display: block; height: 0; clear: both; } + .form_table td { padding: 6px; } + table { border-collapse: collapse; } .match_div { height: 95%; width: 95%; @@ -33,6 +35,7 @@ font-weight:bold; } .tall { height:100%; } + .wide { width:100%; } .hidden { display: none; } #toolbar { margin-top: 0px; } body { width:100%; height:100%; border:0; margin:0; padding:0; } @@ -47,7 +50,7 @@ border: 1px solid red; } - + @@ -78,7 +81,7 @@

- +
Record Type @@ -136,20 +139,64 @@ vlQueueGridLayout = [{ defaultCell: {styles: 'text-align: center;'}, cells : [[ - {name: 'Selected', get: vlQueueGridDrawSelectBox }, - {name: 'Import Time', field:'import_time', get:vlGetDateTimeField} + {name: '', + get: vlQueueGridDrawSelectBox }, + {name: 'Import Time', field:'import_time', get:vlGetDateTimeField, selectableColumn:true} ]] }]; }
- -
- - + +
+ + + + + + + + + +
ColumnDislapyAuto Width
+ +
+
+ + + + + - + + + Select Columns + + +
+ + + + + + + +
+ Only show records with possible matches + + + Results Per Page + + + Page + + +
+
« Previous Page - + Next Page » - Only show possible matches - - Page Size - Page - -
+ +
@@ -235,7 +282,7 @@