[open-ils-commits] r10526 - trunk/Open-ILS/web/vandelay
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Sep 3 17:10:03 EDT 2008
Author: erickson
Date: 2008-09-03 17:09:58 -0400 (Wed, 03 Sep 2008)
New Revision: 10526
Modified:
trunk/Open-ILS/web/vandelay/vandelay.html
trunk/Open-ILS/web/vandelay/vandelay.js
Log:
when we find matches, provide an option to view a list of matched records and see the MARC for those records
Modified: trunk/Open-ILS/web/vandelay/vandelay.html
===================================================================
--- trunk/Open-ILS/web/vandelay/vandelay.html 2008-09-03 21:08:35 UTC (rev 10525)
+++ trunk/Open-ILS/web/vandelay/vandelay.html 2008-09-03 21:09:58 UTC (rev 10526)
@@ -1,7 +1,6 @@
<!--
# Copyright (C) 2008 Georgia Public Library Service
# Bill Erickson <erickson at esilibrary.com>
-#
# 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
@@ -33,21 +32,23 @@
color: red;
font-weight:bold;
}
+ .tall { height:100%; }
+ .hidden { display: none; }
</style>
- <script type="text/javascript" djConfig="parseOnLoad: true,isDebug:true" src="/js/dojo/dojo/dojo.js"></script>
+ <script type="text/javascript" djConfig="parseOnLoad: true,isDebug:false" src="/js/dojo/dojo/dojo.js"></script>
<script type="text/javascript" src='vandelay.js'></script>
</head>
- <body class="tundra" style='height:100%;'>
+ <body class="tundra" class='tall'>
<div id="vl-generic-progress" style='width:100%;text-align:center'>
<div dojoType="dijit.ProgressBar" style="width:200px" indeterminate="true"></div>
</div>
- <div id="vl-generic-progress-with-total" style='width:100%;text-align:center;display:none;'>
+ <div id="vl-generic-progress-with-total" class='hidden' style='width:100%;text-align:center;'>
<div dojoType="dijit.ProgressBar" jsId='vlControlledProgressBar' style="width:200px"></div>
</div>
<!-- MARC upload form -->
- <div id='vl-marc-upload-div' style='display:none;'>
- <h1>Evergreen MARC File Upload</h1>
+ <div id='vl-marc-upload-div' class='hidden'>
+ <h1>Evergreen MARC File Upload</h1><br/>
<form id="vl-marc-upload-form" enctype="multipart/form-data">
<input type='hidden' name='ses' id='vl-ses-input'/>
<br>
@@ -78,7 +79,7 @@
<tr>
<td>
<span id="vl-file-label">File to Upload:</span><br>
- <span id="vl-file-uploading" style='display:none;'>Uploading...</span><br>
+ <span id="vl-file-uploading" class='hidden'>Uploading...</span><br>
</td>
<td id='vl-input-td'>
<input size='48' type="file" name="marc_upload">
@@ -86,7 +87,7 @@
</tr>
<tr>
<td colspan='2'>
- <span id="vl-upload-progress-span" style="display:none;">
+ <span id="vl-upload-progress-span" class='hidden'>
<div dojoType="dijit.ProgressBar" style="width:200px" indeterminate="true"></div>
</span>
</td>
@@ -99,7 +100,7 @@
</table>
</form>
</div>
- <div id='vl-queue-div' style='display:none;height:100%;'>
+ <div id='vl-queue-div' class='tall hidden'>
<h1>Record Queue</h1><br/>
<script>
var vlQueueGridLayout;
@@ -108,17 +109,63 @@
defaultCell: {styles: 'text-align: center;'},
cells : [[
{name: 'Selected', get: vlQueueGridDrawSelectBox },
- {name: 'Import Time', field:'import_time', get:getDateTimeField}
+ {name: 'Import Time', field:'import_time', get:vlGetDateTimeField}
]]
}];
}
</script>
- <button dojoType='dijit.form.Button' onclick='vlSelectAllGridRecords'>Select All</button>
- <button dojoType='dijit.form.Button' onclick='vlSelectNoGridRecords'>Select None</button>
- <button dojoType='dijit.form.Button' onclick='vlImportSelectedRecords'>Import Selected</button>
- <div style='height:100%;'>
+ <button dojoType='dijit.form.Button' onclick='vlSelectAllGridRecords();'>Select All</button>
+ <button dojoType='dijit.form.Button' onclick='vlSelectNoGridRecords();'>Select None</button>
+ <button dojoType='dijit.form.Button' onclick='vlImportSelectedRecords();'>Import Selected</button>
+ <div class='tall'>
<div dojoType='dojox.Grid' jsId='vlQueueGrid'> </div>
</div>
</div>
+
+ <!-- Grid of record matches -->
+ <div id='vl-match-div' class='tall hidden'>
+ <script>
+ var vlMatchGridLayout;
+ function resetVlMatchGridLayout() {
+ vlMatchGridLayout = [{
+ defaultCell: {styles: 'text-align: center;'},
+ cells : [[
+ {name: 'ID', field:'id'},
+ { name: 'View MARC',
+ get: vlGetViewMARC,
+ value:'<a href="javascript:void(0);" onclick="vlLoadMARCHtml(RECID);">View MARC</a>'
+ },
+ {name: 'Creator', get: vlGetCreator},
+ {name: 'Create Date', field:'create_date', get: vlGetDateTimeField},
+ {name: 'Last Edit Date', field:'edit_date', get: vlGetDateTimeField},
+ {name: 'Source', field:'source'},
+ {name: 'TCN Source', field:'tcn_source'},
+ {name: 'TCN Value', field:'tcn_value'}
+ ]]
+ }];
+ }
+ </script>
+ <h1>Import Matches</h1></br>
+ <div>
+ <button dojoType='dijit.form.Button' onclick='displayGlobalDiv("vl-queue-div");'>Back To Import Queue...</button>
+ </div>
+ <div class='tall'>
+ <div dojoType='dojox.Grid' jsId='vlMatchGrid'> </div>
+ </div>
+ </div>
+
+
+ <!-- MARC as HTML for matched records -->
+ <div id='vl-match-html-div' class='tall hidden'>
+ <h1>MARC Record</h1><br/>
+ <div>
+ <button dojoType='dijit.form.Button' onclick='displayGlobalDiv("vl-match-div");'>Back To Matches...</button>
+ </div>
+ <div>
+ <style>#vl-match-record-html td {padding:0px;}</style>
+ <div id='vl-match-record-html'/>
+ </div>
+ </div>
+
</body>
</html>
Modified: trunk/Open-ILS/web/vandelay/vandelay.js
===================================================================
--- trunk/Open-ILS/web/vandelay/vandelay.js 2008-09-03 21:08:35 UTC (rev 10525)
+++ trunk/Open-ILS/web/vandelay/vandelay.js 2008-09-03 21:09:58 UTC (rev 10526)
@@ -17,6 +17,8 @@
dojo.require("dijit.ProgressBar");
dojo.require("dijit.form.Button");
dojo.require("dijit.form.FilteringSelect");
+dojo.require("dijit.layout.ContentPane");
+dojo.require("dijit.layout.TabContainer");
dojo.require("dojo.cookie");
dojo.require("dojox.grid.Grid");
dojo.require("dojo.data.ItemFileReadStore");
@@ -32,7 +34,9 @@
'vl-generic-progress',
'vl-generic-progress-with-total',
'vl-marc-upload-div',
- 'vl-queue-div'
+ 'vl-queue-div',
+ 'vl-match-div',
+ 'vl-match-html-div'
];
var authtoken;
@@ -47,6 +51,7 @@
var currentType;
var cgi = new openils.CGI();
var currentQueueId = null;
+var userCache = {};
/**
* Grab initial data
@@ -220,55 +225,125 @@
}
function vlLoadMatchUI(recId, attrCode) {
- alert(recId + ' : ' + attrCode);
+ displayGlobalDiv('vl-generic-progress');
+ var matches = getRecMatchesFromAttrCode(queuedRecordsMap[recId], attrCode);
+ var records = [];
+ for(var i = 0; i < matches.length; i++)
+ records.push(matches[i].eg_record());
+ fieldmapper.standardRequest(
+ ['open-ils.search', 'open-ils.search.biblio.record_entry.slim.retrieve'],
+ { async: true,
+ params:[records],
+ oncomplete: function(r) {
+ var recs = r.recv().content();
+ if(e = openils.Event.parse(recs))
+ return alert(e);
+ displayGlobalDiv('vl-match-div');
+ resetVlMatchGridLayout();
+ vlMatchGrid.setStructure(vlMatchGridLayout);
+ var store = new dojo.data.ItemFileReadStore({data:bre.toStoreData(recs)});
+ var model = new dojox.grid.data.DojoData(
+ null, store, {rowsPerPage: 100, clientSort: true, query:{id:'*'}});
+ vlMatchGrid.setModel(model);
+ vlMatchGrid.update();
+ }
+ }
+ );
}
+function vlLoadMARCHtml(recId) {
+ displayGlobalDiv('vl-generic-progress');
+ fieldmapper.standardRequest(
+ ['open-ils.search', 'open-ils.search.biblio.record.html'],
+ { async: true,
+ params: [recId, 1],
+ oncomplete: function(r) {
+ displayGlobalDiv('vl-match-html-div');
+ var html = r.recv().content();
+ dojo.byId('vl-match-record-html').innerHTML = html;
+ }
+ }
+ );
+}
+
/**
* 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 '<div class="match_div">' +
+ '<a href="javascript:void(0);" onclick="vlLoadMatchUI('+
+ rec.id()+',\''+matches[0].field_type()+'\');">'+
+ attr.attr_value() + ' ('+matches.length+')</a></div>';
+ }
+
+ return attr.attr_value();
+}
+
+function getRecMatchesFromAttrCode(rec, attrCode) {
var matches = [];
for(var j = 0; j < rec.matches().length; j++) {
var match = rec.matches()[j];
if(match.field_type() == attrCode)
matches.push(match);
}
+ return matches;
+}
- if(matches.length > 0) { // found some matches
- return '<div class="match_div">' +
- '<a href="javascript:void(0);" onclick="vlLoadMatchUI('+
- rec.id()+',\''+match.field_type()+'\');">'+
- attr.attr_value() + ' ('+matches.length+')</a></div>';
+function getRecAttrFromCode(rec, attrCode) {
+ var defId = attrMap[attrCode];
+ var attrs = rec.attributes();
+ for(var i = 0; i < attrs.length; i++) {
+ var attr = attrs[i];
+ if(attr.field() == defId)
+ return attr;
}
-
- return attr.attr_value();
+ return null;
}
function getAttrValue(rowIdx) {
var data = this.grid.model.getRow(rowIdx);
if(!data) return '';
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 buildAttrColumnUI(rec, attrCode, attr);
- }
+ var attr = getRecAttrFromCode(rec, attrCode);
+ console.log('attr = ' + attr);
+ if(attr)
+ return buildAttrColumnUI(rec, attrCode, attr);
return '';
}
-function getDateTimeField(rowIdx) {
+function vlGetDateTimeField(rowIdx) {
data = this.grid.model.getRow(rowIdx);
if(!data) return '';
+ if(!data[this.field]) return '';
var date = dojo.date.stamp.fromISOString(data[this.field]);
- return dojo.date.locale.format(date, {formatLength:'medium'});
+ return dojo.date.locale.format(date, {selector:'date'});
}
+function vlGetCreator(rowIdx) {
+ data = this.grid.model.getRow(rowIdx);
+ if(!data) return '';
+ var id = data.creator;
+ if(userCache[id])
+ return userCache[id].usrname();
+ var user = fieldmapper.standardRequest(['open-ils.actor', 'open-ils.actor.user.retrieve'], [authtoken, id]);
+ if(e = openils.Event.parse(user))
+ return alert(e);
+ userCache[id] = user;
+ return user.usrname();
+}
+
+function vlGetViewMARC(rowIdx) {
+ data = this.grid.model.getRow(rowIdx);
+ if(data)
+ return this.value.replace('RECID', data.id);
+}
+
function buildRecordGrid(type) {
displayGlobalDiv('vl-queue-div');
More information about the open-ils-commits
mailing list