[open-ils-commits] r10494 - trunk/Open-ILS/web/vandelay
svn at svn.open-ils.org
svn at svn.open-ils.org
Sat Aug 30 16:30:10 EDT 2008
Author: erickson
Date: 2008-08-30 16:30:06 -0400 (Sat, 30 Aug 2008)
New Revision: 10494
Modified:
trunk/Open-ILS/web/vandelay/vandelay.html
trunk/Open-ILS/web/vandelay/vandelay.js
Log:
displaying bib attrs in grid. added option to pass in queue id to bypass upload form
Modified: trunk/Open-ILS/web/vandelay/vandelay.html
===================================================================
--- trunk/Open-ILS/web/vandelay/vandelay.html 2008-08-30 19:08:02 UTC (rev 10493)
+++ trunk/Open-ILS/web/vandelay/vandelay.html 2008-08-30 20:30:06 UTC (rev 10494)
@@ -22,12 +22,16 @@
@import "/js/dojo/dojox/grid/_grid/Grid.css";
td { padding: 6px; }
</style>
- <script type="text/javascript" djConfig="parseOnLoad: 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" onload='vlInit();'>
+ <div id="vl-generic-progress" style='width:100%;text-align:center'>
+ <div dojoType="dijit.ProgressBar" style="width:200px" indeterminate="true"></div>
+ </div>
+
<!-- MARC upload form -->
- <div id='vl-marc-upload-div'>
+ <div id='vl-marc-upload-div' style='display:none;'>
<h1>Evergreen MARC File Upload</h1>
<form id="vl-marc-upload-form" enctype="multipart/form-data">
<input type='hidden' name='ses' id='vl-ses-input'/>
@@ -81,7 +85,7 @@
</form>
</div>
<div id='vl-queue-div' style='display:none;height:100%;'>
- <h1>Record Queue</h1>
+ <h1>Record Queue</h1><br/>
<div style='height:100%;'>
<div dojoType='dojox.Grid' jsId='vlQueueGrid'> </div>
</div>
Modified: trunk/Open-ILS/web/vandelay/vandelay.js
===================================================================
--- trunk/Open-ILS/web/vandelay/vandelay.js 2008-08-30 19:08:02 UTC (rev 10493)
+++ trunk/Open-ILS/web/vandelay/vandelay.js 2008-08-30 20:30:06 UTC (rev 10494)
@@ -26,16 +26,25 @@
dojo.require('openils.User');
dojo.require('openils.Event');
-var authtoken = dojo.cookie('ses') || new openils.CGI().param('ses');
+var authtoken;
var VANDELAY_URL = '/vandelay';
var bibAttrDefs = [];
var authAttrDefs = [];
var queuedRecords = [];
+var queuedRecordsMap = {};
+var bibAttrsFetched = false;
+var authAttrsFetched = false;
+var attrMap = {};
+var currentType;
+var cgi = new openils.CGI();
/**
* Grab initial data
*/
function vlInit() {
+ authtoken = dojo.cookie('ses') || cgi.param('ses');
+ bibAttrsFetched = false;
+ authAttrsFetched = false;
// Fetch the bib and authority attribute definitions
fieldmapper.standardRequest(
@@ -48,6 +57,11 @@
return alert(def);
bibAttrDefs.push(def);
},
+ oncomplete: function() {
+ bibAttrsFetched = true;
+ if(authAttrsFetched)
+ runStartupCommands();
+ }
}
);
@@ -60,11 +74,31 @@
if(openils.Event.parse(def))
return alert(def);
authAttrDefs.push(def);
+ },
+ oncomplete: function() {
+ authAttrsFetched = true;
+ if(bibAttrsFetched)
+ runStartupCommands();
}
}
);
}
+function displayGlobalDiv(id) {
+ dojo.style(dojo.byId('vl-generic-progress'),"display","none");
+ dojo.style(dojo.byId('vl-marc-upload-div'),"display","none");
+ dojo.style(dojo.byId('vl-queue-div'),"display","none");
+ dojo.style(dojo.byId(id),"display","block");
+}
+
+function runStartupCommands() {
+ var queueParam = cgi.param('qid');
+ currentType = cgi.param('qtype');
+ if(queueParam)
+ return retrieveQueuedRecords(currentType, queueParam, handleRetrieveRecords);
+ displayGlobalDiv('vl-marc-upload-div');
+}
+
/**
* asynchronously upload a file of MARC records
*/
@@ -140,26 +174,50 @@
if(e = openils.Event.parse(rec))
return alert(e);
queuedRecords.push(rec);
+ queuedRecordsMap[rec.id()] = rec;
},
oncomplete: function(){onload();}
}
);
}
+function getAttrValue(rowIdx) {
+ var data = this.grid.model.getRow(rowIdx);
+ if(!data) return '';
+ var attrName = this.field.split('.')[1];
+ var defId = attrMap[attrName];
+ 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 '';
+}
+
function buildRecordGrid(type) {
- dojo.style(dojo.byId('vl-marc-upload-div'),"display","none");
- dojo.style(dojo.byId('vl-queue-div'),"display","block");
+ displayGlobalDiv('vl-queue-div');
/* test structure... */
var structure = [{
+ noscroll : true,
cells : [[
{name: 'ID', field: 'id'},
- {name: 'Create Time', field: 'create_time'},
- {name: 'Import Time', field: 'import_time'},
- {name: 'Purpose', field: 'purpose'},
]]
}];
+ var defs = (type == 'bib') ? bibAttrDefs : authAttrDefs;
+ for(var i = 0; i < defs.length; i++) {
+ var attr = defs[i]
+ attrMap[attr.code()] = attr.id();
+ structure[0].cells[0].push({
+ name:attr.description(),
+ field:'attr.' + attr.code(),
+ get: getAttrValue
+ });
+ }
+
vlQueueGrid.setStructure(structure);
var storeData;
@@ -170,40 +228,38 @@
var store = new dojo.data.ItemFileReadStore({data:storeData});
var model = new dojox.grid.data.DojoData(
- null, store, {rowsPerPage: 20, clientSort: true, query:{id:'*'}});
+ null, store, {rowsPerPage: 100, clientSort: true, query:{id:'*'}});
vlQueueGrid.setModel(model);
vlQueueGrid.update();
}
+var handleRetrieveRecords = function() {
+ buildRecordGrid(currentType);
+}
+
/**
* Create queue, upload MARC, process spool, load the newly created queue
*/
function batchUpload() {
var queueName = dijit.byId('vl-queue-name').getValue();
- var recordType = dijit.byId('vl-record-type').getValue();
-
+ currentType = dijit.byId('vl-record-type').getValue();
var currentQueue = null;
- var handleRetrieveRecords = function() {
- alert("building record grid");
- buildRecordGrid(recordType);
- }
-
var handleProcessSpool = function() {
- alert('records uploaded and spooled');
- retrieveQueuedRecords(recordType, currentQueue.id(), handleRetrieveRecords);
+ console.log('records uploaded and spooled');
+ retrieveQueuedRecords(currentType, currentQueue.id(), handleRetrieveRecords);
}
var handleUploadMARC = function(key) {
- alert('marc uploaded');
- processSpool(key, currentQueue, recordType, handleProcessSpool);
+ console.log('marc uploaded');
+ processSpool(key, currentQueue, currentType, handleProcessSpool);
};
var handleCreateQueue = function(queue) {
- alert('queue created ' + queue.name());
+ console.log('queue created ' + queue.name());
currentQueue = queue;
uploadMARC(handleUploadMARC);
};
- createQueue(queueName, recordType, handleCreateQueue);
+ createQueue(queueName, currentType, handleCreateQueue);
}
More information about the open-ils-commits
mailing list