From 0fc56f78927ddae5203f35bd1f6cae1d8a45d24d Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 25 Sep 2008 13:25:11 +0000 Subject: [PATCH] instead of displaying a link on match cells, have a dedicated match column, which links to a page with all matches. git-svn-id: svn://svn.open-ils.org/ILS/trunk@10699 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/vandelay/vandelay.html | 21 ++++++--- Open-ILS/web/vandelay/vandelay.js | 73 +++++++++++++++++++---------- 2 files changed, 62 insertions(+), 32 deletions(-) diff --git a/Open-ILS/web/vandelay/vandelay.html b/Open-ILS/web/vandelay/vandelay.html index 0fe4855ffb..ba3184a672 100644 --- a/Open-ILS/web/vandelay/vandelay.html +++ b/Open-ILS/web/vandelay/vandelay.html @@ -142,7 +142,12 @@ get: vlQueueGridDrawSelectBox }, { name: 'View MARC', get: vlGetViewMARC, - value:'View MARC' + value:'View MARC' + }, + { name: 'Matches', + get: vlGetViewMatches, + value:'Matches' }, {name: 'Import Time', field:'import_time', get:vlGetDateTimeField, selectableColumn:true} ]] @@ -245,13 +250,16 @@ { name: 'Overlay Target', get: vlGetOverlayTargetSelector, - value: '' + value: '' }, - {name:'Match Point', field:'field_type'}, + {name:'Source Match Point', field:'src_matchpoint'}, + {name:'Destination Match Point', field:'dest_matchpoint'}, {name: 'ID', field:'id'}, { name: 'View MARC', get: vlGetViewMARC, - value:'View MARC' + value:'View MARC' }, {name: 'Creator', get: vlGetCreator}, {name: 'Create Date', field:'create_date', get: vlGetDateTimeField}, @@ -316,10 +324,11 @@ + diff --git a/Open-ILS/web/vandelay/vandelay.js b/Open-ILS/web/vandelay/vandelay.js index c88c087876..be885d3297 100644 --- a/Open-ILS/web/vandelay/vandelay.js +++ b/Open-ILS/web/vandelay/vandelay.js @@ -292,9 +292,11 @@ function retrieveQueuedRecords(type, queueId, onload) { ); } -function vlLoadMatchUI(recId, attrCode) { +//function vlLoadMatchUI(recId, attrCode) { +function vlLoadMatchUI(recId) { displayGlobalDiv('vl-generic-progress'); - var matches = getRecMatchesFromAttrCode(queuedRecordsMap[recId], attrCode); + //var matches = getRecMatchesFromAttrCode(queuedRecordsMap[recId], attrCode); + var matches = queuedRecordsMap[recId].matches(); var records = []; currentImportRecId = recId; for(var i = 0; i < matches.length; i++) @@ -322,16 +324,26 @@ function vlLoadMatchUI(recId, attrCode) { currentMatchedRecords = recs; vlMatchGrid.setStructure(vlMatchGridLayout); - // build the data store or records with match information - var dataStore = bre.toStoreData(recs, null, {virtualFields:['field_type']}); + // build the data store of records with match information + var dataStore = bre.toStoreData(recs, null, + {virtualFields:['dest_matchpoint', 'src_matchpoint', '_id']}); + dataStore.identifier = '_id'; + + for(var i = 0; i < dataStore.items.length; i++) { var item = dataStore.items[i]; + item._id = i; // just need something unique for(var j = 0; j < matches.length; j++) { var match = matches[j]; - if(match.eg_record() == item.id) - item.field_type = match.field_type(); + if(match.eg_record() == item.id) { + item.dest_matchpoint = match.field_type(); + var attr = getRecAttrFromMatch(queuedRecordsMap[recId], match); + //item.src_matchpoint = getRecAttrDefFromAttr(attr, currentType).description(); + item.src_matchpoint = getRecAttrDefFromAttr(attr, currentType).code(); + } } } + // now populate the grid vlPopulateGrid(vlMatchGrid, dataStore); } @@ -377,23 +389,7 @@ function vlLoadMARCHtml(recId, inCat, oncomplete) { } -/** - * 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 = getRecMatchesFromAttrCode(rec, attrCode); - if(matches.length > 0) { // found some matches - return '
' + - ''+ - attr.attr_value() + ' ('+matches.length+')
'; - } - - return attr.attr_value(); -} - +/* function getRecMatchesFromAttrCode(rec, attrCode) { var matches = []; var attr = getRecAttrFromCode(rec, attrCode); @@ -404,6 +400,24 @@ function getRecMatchesFromAttrCode(rec, attrCode) { } return matches; } +*/ + +function getRecAttrFromMatch(rec, match) { + for(var i = 0; i < rec.attributes().length; i++) { + var attr = rec.attributes()[i]; + if(attr.id() == match.matched_attr()) + return attr; + } +} + +function getRecAttrDefFromAttr(attr, type) { + var defs = (type == 'bib') ? bibAttrDefs : authAttrDefs; + for(var i = 0; i < defs.length; i++) { + var def = defs[i]; + if(def.id() == attr.field()) + return def; + } +} function getRecAttrFromCode(rec, attrCode) { var defId = attrDefMap[attrCode]; @@ -416,15 +430,22 @@ function getRecAttrFromCode(rec, attrCode) { return null; } +function vlGetViewMatches(rowIdx) { + var data = this.grid.model.getRow(rowIdx); + if(!data) return ''; + var rec = queuedRecordsMap[data.id]; + if(rec.matches().length > 0) + return this.value.replace('RECID', data.id); + return ''; +} + function getAttrValue(rowIdx) { var data = this.grid.model.getRow(rowIdx); if(!data) return ''; var attrCode = this.field.split('.')[1]; var rec = queuedRecordsMap[data.id]; var attr = getRecAttrFromCode(rec, attrCode); - if(attr) - return buildAttrColumnUI(rec, attrCode, attr); - return ''; + return (attr) ? attr.attr_value() : ''; } function vlGetDateTimeField(rowIdx) { -- 2.43.2