From e6ffb90380096a5946d28111c5ac6f4dcc824660 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 3 Sep 2008 15:14:07 +0000 Subject: [PATCH 1/1] added logic to find matches. centering cell data git-svn-id: svn://svn.open-ils.org/ILS/trunk@10520 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/vandelay/vandelay.html | 1 + Open-ILS/web/vandelay/vandelay.js | 41 +++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/Open-ILS/web/vandelay/vandelay.html b/Open-ILS/web/vandelay/vandelay.html index 6b1001f751..421149ba30 100644 --- a/Open-ILS/web/vandelay/vandelay.html +++ b/Open-ILS/web/vandelay/vandelay.html @@ -93,6 +93,7 @@ var vlQueueGridLayout; function resetVlQueueGridLayout() { vlQueueGridLayout = [{ + defaultCell: {styles: 'text-align: center;'}, cells : [[ {name: 'Selected', get: vlQueueGridDrawSelectBox }, {name: 'Import Time', field:'import_time', get:getDateTimeField} diff --git a/Open-ILS/web/vandelay/vandelay.js b/Open-ILS/web/vandelay/vandelay.js index 6e7c99843b..e57beff35f 100644 --- a/Open-ILS/web/vandelay/vandelay.js +++ b/Open-ILS/web/vandelay/vandelay.js @@ -219,17 +219,44 @@ function retrieveQueuedRecords(type, queueId, onload) { ); } + +/** + * Given a record, an attribute definition code, and a matching record attribute, + * this will determine if there are any import matches and build the UI to + * represent those matches. If no matches exist, simply returns the attribute value + */ +function buildAttrColumnUI(rec, attrCode, attr) { + var matches = []; + for(var j = 0; j < rec.matches().length; j++) { + var match = rec.matches()[j]; + if(match.field_type() == attrCode) + matches.push(match); + } + + if(matches.length > 0) { // found some matches + var str = '
'; + for(var k = 0; k < matches.length; k++) { + var match = matches[k]; + str += '
' + match.eg_record()+'
'; + } + str += '
'; + return str; + } + + return attr.attr_value(); +} + function getAttrValue(rowIdx) { var data = this.grid.model.getRow(rowIdx); if(!data) return ''; - var attrName = this.field.split('.')[1]; - var defId = attrMap[attrName]; + var attrCode = this.field.split('.')[1]; + var defId = attrMap[attrCode]; var rec = queuedRecordsMap[data.id]; var attrs = rec.attributes(); for(var i = 0; i < attrs.length; i++) { var attr = attrs[i]; if(attr.field() == defId) - return attr.attr_value(); + return buildAttrColumnUI(rec, attrCode, attr); } return ''; } @@ -299,8 +326,12 @@ function vlImportSelectedRecords() { displayGlobalDiv('vl-generic-progress-with-total'); var records = []; for(var id in selectableGridRecords) { - if(dojo.byId(id).checked) - records.push(selectableGridRecords[id]); + if(dojo.byId(id).checked) { + var recId = selectableGridRecords[id]; + var rec = queuedRecordsMap[recId]; + if(!rec.import_time()) + records.push(recId); + } } fieldmapper.standardRequest( ['open-ils.vandelay', 'open-ils.vandelay.'+currentType+'_record.list.import'], -- 2.43.2