From: erickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4> Date: Tue, 5 May 2009 20:47:21 +0000 (+0000) Subject: ported the attr def grid to the newer dojox.grid.DataGrid, plus some other dojo api... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=92881dcba625a77de4664438e0c902d113ff3436;p=evergreen%2Fmasslnc.git ported the attr def grid to the newer dojox.grid.DataGrid, plus some other dojo api fixes. 2 grids to go git-svn-id: svn://svn.open-ils.org/ILS/trunk@13083 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/vandelay/inc/attrs.xml b/Open-ILS/web/vandelay/inc/attrs.xml index c65744b563..03a49f93f3 100644 --- a/Open-ILS/web/vandelay/inc/attrs.xml +++ b/Open-ILS/web/vandelay/inc/attrs.xml @@ -81,22 +81,21 @@ </table> </div> </div> -<script> - var vlAttrGridLayout = [{ - cells : [[ - {name: '&vandelay.id;', field: 'id'}, - {name: '&vandelay.code;', field:'code', width:'auto'}, - {name: '&vandelay.descrip;', field: "description", width:'auto'}, - {name: '&vandelay.tag;', get:attrGridGetTag}, - {name: '&vandelay.subfield;', get: attrGridGetSubfield}, - {name: '&vandelay.identifier;', field:'ident'}, - {name: '&vandelay.xpath;', field:'xpath', width:'auto'}, - {name: '&vandelay.remove;', field:'remove', width:'auto'} - ]] - }]; -</script> -<div class='tall'> - <div dojoType='dojox.Grid' jsId='attrEditorGrid'> </div> +<div style='height:600px;'> + <table dojoType='dojox.grid.DataGrid' jsId='attrEditorGrid' query="{id: '*'}"> + <thead> + <tr> + <th field='id'>&vandelay.id;</th> + <th field='code' width='auto'>&vandelay.code;</th> + <th field='description' width='auto'>&vandelay.descrip;</th> + <th field='tag' get='attrGridGetTag'>&vandelay.tag;</th> + <th field='subfield' get='attrGridGetSubfield'>&vandelay.subfield;</th> + <th field='ident'>&vandelay.identifier;</th> + <th field='xpath' width='auto'>&vandelay.xpath;</th> + <th field='remove' width='auto'>&vandelay.remove;</th> + </tr> + </thead> + </table> </div> diff --git a/Open-ILS/web/vandelay/vandelay.css b/Open-ILS/web/vandelay/vandelay.css index b619aad69e..8296037a70 100644 --- a/Open-ILS/web/vandelay/vandelay.css +++ b/Open-ILS/web/vandelay/vandelay.css @@ -1,6 +1,8 @@ @import "/js/dojo/dojo/resources/dojo.css"; @import "/js/dojo/dijit/themes/tundra/tundra.css"; @import "/js/dojo/dojox/grid/_grid/Grid.css"; +@import "/js/dojo/dojox/grid/resources/tundraGrid.css"; + .container:after {content: ""; display: block; height: 0; clear: both; } html,body { width:100%; height:100%; border:0; margin:0; padding:0; background-color:white; } table { border-collapse: collapse; } diff --git a/Open-ILS/web/vandelay/vandelay.js b/Open-ILS/web/vandelay/vandelay.js index af96999859..44864098d0 100644 --- a/Open-ILS/web/vandelay/vandelay.js +++ b/Open-ILS/web/vandelay/vandelay.js @@ -27,6 +27,7 @@ dojo.require('dijit.Menu'); dojo.require("dijit.Dialog"); dojo.require("dojo.cookie"); dojo.require("dojox.grid.Grid"); +dojo.require('dojox.grid.DataGrid'); dojo.require("dojo.data.ItemFileReadStore"); dojo.require('dojo.date.locale'); dojo.require('dojo.date.stamp'); @@ -974,42 +975,37 @@ function onAttrEditorClose() { function loadAttrEditorGrid() { var _data = (ATTR_EDIT_GROUP == 'auth') ? vqarad.toStoreData(authAttrDefs) : vqbrad.toStoreData(bibAttrDefs) ; - + var store = new dojo.data.ItemFileReadStore({data:_data}); - var model = new dojox.grid.data.DojoData( - null, store, {rowsPerPage: 100, clientSort: true, query:{id:'*'}}); - attrEditorGrid.setModel(model); - attrEditorGrid.setStructure(vlAttrGridLayout); - attrEditorGrid.onRowClick = onAttrEditorClick; + attrEditorGrid.setStore(store); + dojo.connect(attrEditorGrid, 'onRowClick', onAttrEditorClick); attrEditorGrid.update(); } -function attrGridGetTag(n) { +function attrGridGetTag(n, item) { // grid helper: return the tags from the row's xpath column. - var xp = this.grid.model.getRow(n); - return xp && xpathParser.parse(xp.xpath).tags; + return item && xpathParser.parse(this.grid.store.getValue(item, 'xpath')).tags; } -function attrGridGetSubfield(n) { +function attrGridGetSubfield(n, item) { // grid helper: return the subfields from the row's xpath column. - var xp = this.grid.model.getRow(n); - return xp && xpathParser.parse(xp.xpath).subfields; + return item && xpathParser.parse(this.grid.store.getValue(item, 'xpath')).subfields; } -function onAttrEditorClick(evt) { - var row = attrEditorGrid.model.getRow(evt.rowIndex); - ATTR_EDIT_ID = row.id; +function onAttrEditorClick() { + var row = this.getItem(this.focus.rowIndex); + ATTR_EDIT_ID = this.store.getValue(row, 'id'); ATTR_EDITOR_IN_UPDATE_MODE = true; // populate the popup editor. - dojo.byId('attr-editor-code').value = row.code; - dojo.byId('attr-editor-description').value = row.description; - var parsed_xpath = xpathParser.parse(row.xpath); - dojo.byId('attr-editor-tags').value = parsed_xpath.tags; - dojo.byId('attr-editor-subfields').value = parsed_xpath.subfields; - dojo.byId('attr-editor-identifier').value = (row.ident ? 'True':'False'); - dojo.byId('attr-editor-xpath').value = row.xpath; - dojo.byId('attr-editor-remove').value = row.remove; + dijit.byId('attr-editor-code').attr('value', this.store.getValue(row, 'code')); + dijit.byId('attr-editor-description').attr('value', this.store.getValue(row, 'description')); + var parsed_xpath = xpathParser.parse(this.store.getValue(row, 'xpath')); + dijit.byId('attr-editor-tags').attr('value', parsed_xpath.tags); + dijit.byId('attr-editor-subfields').attr('value', parsed_xpath.subfields); + dijit.byId('attr-editor-identifier').attr('value', this.store.getValue(row, 'ident')); + dijit.byId('attr-editor-xpath').attr('value', this.store.getValue(row, 'xpath')); + dijit.byId('attr-editor-remove').attr('value', this.store.getValue(row, 'remove')); // set up UI for editing dojo.byId('vl-create-attr-editor-button').click(); diff --git a/Open-ILS/web/vandelay/vandelay.xml b/Open-ILS/web/vandelay/vandelay.xml index 10aac24576..15307491ab 100644 --- a/Open-ILS/web/vandelay/vandelay.xml +++ b/Open-ILS/web/vandelay/vandelay.xml @@ -22,7 +22,7 @@ <head> <title>&vandelay.vandelay;</title> <link type='text/css' rel='stylesheet' href="/vandelay/vandelay.css"/> - <script type="text/javascript" djConfig="parseOnLoad: true,isDebug:false" src="/js/dojo/dojo/dojo.js"></script> + <script type="text/javascript" djConfig="parseOnLoad: true,isDebug:true" src="/js/dojo/dojo/dojo.js"></script> <script type="text/javascript" src='/js/dojo/openils/MarcXPathParser.js'></script> <script type="text/javascript" src='/vandelay/vandelay.js'></script> </head>