be885d329769a3f6a30681c8480c9a2c26f2993e
[Evergreen.git] / Open-ILS / web / vandelay / vandelay.js
1 /* ---------------------------------------------------------------------------
2 # Copyright (C) 2008  Georgia Public Library Service
3 # Bill Erickson <erickson@esilibrary.com>
4
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 # --------------------------------------------------------------------------- */
15 dojo.require("dojo.parser");
16 dojo.require("dojo.io.iframe"); 
17 dojo.require("dijit.ProgressBar"); 
18 dojo.require("dijit.form.Button"); 
19 dojo.require("dijit.form.FilteringSelect"); 
20 dojo.require("dijit.layout.LayoutContainer");
21 dojo.require("dijit.layout.ContentPane");
22 dojo.require("dijit.layout.TabContainer");
23 dojo.require("dijit.Dialog");
24 dojo.require("dojo.cookie");
25 dojo.require("dojox.grid.Grid");
26 dojo.require("dojo.data.ItemFileReadStore");
27 dojo.require('dojo.date.locale');
28 dojo.require('dojo.date.stamp');
29 dojo.require("fieldmapper.Fieldmapper");
30 dojo.require("fieldmapper.dojoData");
31 dojo.require('openils.CGI');
32 dojo.require('openils.User');
33 dojo.require('openils.Event');
34 dojo.require('openils.MarcXPathParser');
35 dojo.require('openils.GridColumnPicker');
36
37 var globalDivs = [
38     'vl-generic-progress',
39     'vl-generic-progress-with-total',
40     'vl-marc-upload-div',
41     'vl-queue-div',
42     'vl-match-div',
43     'vl-marc-html-div',
44     'vl-queue-select-div',
45     'vl-marc-upload-status-div'
46 ];
47
48 var authtoken;
49 var VANDELAY_URL = '/vandelay-upload';
50 var bibAttrDefs = [];
51 var authAttrDefs = [];
52 var queuedRecords = [];
53 var queuedRecordsMap = {};
54 var bibAttrsFetched = false;
55 var authAttrsFetched = false;
56 var attrDefMap = {}; // maps attr def code names to attr def ids
57 var currentType;
58 var currentQueueId = null;
59 var userCache = {};
60 var currentMatchedRecords; // set of loaded matched bib records
61 var currentOverlayRecordsMap; // map of import record to overlay record
62 var currentImportRecId; // when analyzing matches, this is the current import record
63 var userBibQueues = []; // only non-complete queues
64 var userAuthQueues = []; // only non-complete queues
65 var allUserBibQueues;
66 var allUserAuthQueues;
67 var selectableGridRecords;
68 var cgi = new openils.CGI();
69 var vlQueueGridColumePicker;
70
71 /**
72   * Grab initial data
73   */
74 function vlInit() {
75     authtoken = dojo.cookie('ses') || cgi.param('ses');
76     var initNeeded = 4; // how many async responses do we need before we're init'd 
77     var initCount = 0; // how many async reponses we've received
78
79     function checkInitDone() {
80         initCount++;
81         if(initCount == initNeeded)
82             runStartupCommands();
83     }
84
85     // Fetch the bib and authority attribute definitions
86     fieldmapper.standardRequest(
87         ['open-ils.permacrud', 'open-ils.permacrud.search.vqbrad'],
88         {   async: true,
89             params: [authtoken, {id:{'!=':null}}],
90             onresponse: function(r) {
91                 var def = r.recv().content(); 
92                 if(e = openils.Event.parse(def[0])) 
93                     return alert(e);
94                 bibAttrDefs.push(def);
95             },
96             oncomplete: function() {
97                 bibAttrDefs = bibAttrDefs.sort(
98                     function(a, b) {
99                         if(a.id() > b.id()) return 1;
100                         if(a.id() < b.id()) return -1;
101                         return 0;
102                     }
103                 );
104                 checkInitDone();
105             }
106         }
107     );
108
109     fieldmapper.standardRequest(
110         ['open-ils.permacrud', 'open-ils.permacrud.search.vqarad'],
111         {   async: true,
112             params: [authtoken, {id:{'!=':null}}],
113             onresponse: function(r) {
114                 var def = r.recv().content(); 
115                 if(e = openils.Event.parse(def[0])) 
116                     return alert(e);
117                 authAttrDefs.push(def);
118             },
119             oncomplete: function() {
120                 authAttrDefs = authAttrDefs.sort(
121                     function(a, b) {
122                         if(a.id() > b.id()) return 1;
123                         if(a.id() < b.id()) return -1;
124                         return 0;
125                     }
126                 );
127                 checkInitDone();
128             }
129         }
130     );
131
132     vlRetrieveQueueList('bib', null, 
133         function(list) {
134             allUserBibQueues = list;
135             for(var i = 0; i < allUserBibQueues.length; i++) {
136                 if(allUserBibQueues[i].complete() == 'f')
137                     userBibQueues.push(allUserBibQueues[i]);
138             }
139             checkInitDone();
140         }
141     );
142
143     vlRetrieveQueueList('auth', null, 
144         function(list) {
145             allUserAuthQueues = list;
146             for(var i = 0; i < allUserAuthQueues.length; i++) {
147                 if(allUserAuthQueues[i].complete() == 'f')
148                     userAuthQueues.push(allUserAuthQueues[i]);
149             }
150             checkInitDone();
151         }
152     );
153 }
154
155 function vlRetrieveQueueList(type, filter, onload) {
156     type = (type == 'bib') ? type : 'authority';
157     fieldmapper.standardRequest(
158         ['open-ils.vandelay', 'open-ils.vandelay.'+type+'_queue.owner.retrieve.atomic'],
159         {   async: true,
160             params: [authtoken, null, filter],
161             oncomplete: function(r) {
162                 var list = r.recv().content();
163                 if(e = openils.Event.parse(list[0]))
164                     return alert(e);
165                 onload(list);
166             }
167         }
168     );
169 }
170
171 function displayGlobalDiv(id) {
172     for(var i = 0; i < globalDivs.length; i++) {
173         try {
174             dojo.style(dojo.byId(globalDivs[i]), 'display', 'none');
175         } catch(e) {
176             alert('please define div ' + globalDivs[i]);
177         }
178     }
179     dojo.style(dojo.byId(id),'display','block');
180 }
181
182 function runStartupCommands() {
183     currentQueueId = cgi.param('qid');
184     currentType = cgi.param('qtype');
185     if(currentQueueId)
186         return retrieveQueuedRecords(currentType, currentQueueId, handleRetrieveRecords);
187     vlShowUploadForm();
188 }
189
190 /**
191   * asynchronously upload a file of MARC records
192   */
193 function uploadMARC(onload){
194     dojo.byId('vl-upload-status-count').innerHTML = '0';
195     dojo.byId('vl-ses-input').value = authtoken;
196     displayGlobalDiv('vl-marc-upload-status-div');
197     dojo.io.iframe.send({
198         url: VANDELAY_URL,
199         method: "post",
200         handleAs: "html",
201         form: dojo.byId('vl-marc-upload-form'),
202         handle: function(data,ioArgs){
203             var content = data.documentElement.textContent;
204             onload(content);
205         }
206     });
207 }       
208
209 /**
210   * Creates a new vandelay queue
211   */
212 function createQueue(queueName, type, onload) {
213     fieldmapper.standardRequest(
214         ['open-ils.vandelay', 'open-ils.vandelay.'+type+'_queue.create'],
215         {   async: true,
216             params: [authtoken, queueName, null, type],
217             oncomplete : function(r) {
218                 var queue = r.recv().content();
219                 if(e = openils.Event.parse(queue)) 
220                     return alert(e);
221                 onload(queue);
222             }
223         }
224     );
225 }
226
227 /**
228   * Tells vendelay to pull a batch of records from the cache and explode them
229   * out into the vandelay tables
230   */
231 function processSpool(key, queueId, type, onload) {
232     fieldmapper.standardRequest(
233         ['open-ils.vandelay', 'open-ils.vandelay.'+type+'.process_spool'],
234         {   async: true,
235             params: [authtoken, key, queueId],
236             onresponse : function(r) {
237                 var resp = r.recv().content();
238                 if(e = openils.Event.parse(resp)) 
239                     return alert(e);
240                 dojo.byId('vl-upload-status-count').innerHTML = resp;
241             },
242             oncomplete : function(r) {onload();}
243         }
244     );
245 }
246
247 function retrieveQueuedRecords(type, queueId, onload) {
248     displayGlobalDiv('vl-generic-progress');
249     queuedRecords = [];
250     queuedRecordsMap = {};
251     currentOverlayRecordsMap = {};
252     selectableGridRecords = {};
253     resetVlQueueGridLayout();
254
255     var method = 'open-ils.vandelay.'+type+'_queue.records.retrieve.atomic';
256     if(vlQueueGridShowMatches.checked)
257         method = method.replace('records', 'records.matches');
258
259     var limit = parseInt(vlQueueDisplayLimit.getValue());
260     var offset = limit * parseInt(vlQueueDisplayPage.getValue()-1);
261
262     fieldmapper.standardRequest(
263         ['open-ils.vandelay', method],
264         {   async: true,
265             params: [authtoken, queueId, 
266                 {   clear_marc: 1, 
267                     offset: offset,
268                     limit: limit
269                 }
270             ],
271             /* intermittent bug in streaming, multipart requests prevents use of onreponse for now...
272             onresponse: function(r) {
273                 var rec = r.recv().content();
274                 if(e = openils.Event.parse(rec))
275                     return alert(e);
276                 queuedRecords.push(rec);
277                 queuedRecordsMap[rec.id()] = rec;
278             },
279             */
280             oncomplete: function(r){
281                 var recs = r.recv().content();
282                 if(e = openils.Event.parse(recs[0]))
283                     return alert(e);
284                 for(var i = 0; i < recs.length; i++) {
285                     var rec = recs[i];
286                     queuedRecords.push(rec);
287                     queuedRecordsMap[rec.id()] = rec;
288                 }
289                 onload();
290             }
291         }
292     );
293 }
294
295 //function vlLoadMatchUI(recId, attrCode) {
296 function vlLoadMatchUI(recId) {
297     displayGlobalDiv('vl-generic-progress');
298     //var matches = getRecMatchesFromAttrCode(queuedRecordsMap[recId], attrCode);
299     var matches = queuedRecordsMap[recId].matches();
300     var records = [];
301     currentImportRecId = recId;
302     for(var i = 0; i < matches.length; i++)
303         records.push(matches[i].eg_record());
304
305     var retrieve = ['open-ils.search', 'open-ils.search.biblio.record_entry.slim.retrieve'];
306     var params = [records];
307     if(currentType == 'auth') {
308         retrieve = ['open-ils.cat', 'open-ils.cat.authority.record.retrieve'];
309         parmas = [authtoken, records, {clear_marc:1}];
310     }
311
312     fieldmapper.standardRequest(
313         retrieve,
314         {   async: true,
315             params:params,
316             oncomplete: function(r) {
317                 var recs = r.recv().content();
318                 if(e = openils.Event.parse(recs))
319                     return alert(e);
320
321                 /* ui mangling */
322                 displayGlobalDiv('vl-match-div');
323                 resetVlMatchGridLayout();
324                 currentMatchedRecords = recs;
325                 vlMatchGrid.setStructure(vlMatchGridLayout);
326
327                 // build the data store of records with match information
328                 var dataStore = bre.toStoreData(recs, null, 
329                     {virtualFields:['dest_matchpoint', 'src_matchpoint', '_id']});
330                 dataStore.identifier = '_id';
331
332
333                 for(var i = 0; i < dataStore.items.length; i++) {
334                     var item = dataStore.items[i];
335                     item._id = i; // just need something unique
336                     for(var j = 0; j < matches.length; j++) {
337                         var match = matches[j];
338                         if(match.eg_record() == item.id) {
339                             item.dest_matchpoint = match.field_type();
340                             var attr = getRecAttrFromMatch(queuedRecordsMap[recId], match);
341                             //item.src_matchpoint = getRecAttrDefFromAttr(attr, currentType).description();
342                             item.src_matchpoint = getRecAttrDefFromAttr(attr, currentType).code();
343                         }
344                     }
345                 }
346
347                 // now populate the grid
348                 vlPopulateGrid(vlMatchGrid, dataStore);
349             }
350         }
351     );
352 }
353
354 function vlPopulateGrid(grid, data) {
355     var store = new dojo.data.ItemFileReadStore({data:data});
356     var model = new dojox.grid.data.DojoData(
357         null, store, {rowsPerPage: 100, clientSort: true, query:{id:'*'}});
358     grid.setModel(model);
359     grid.update();
360 }
361
362
363 function vlLoadMARCHtml(recId, inCat, oncomplete) {
364     dijit.byId('vl-marc-html-done-button').onClick = oncomplete;
365     displayGlobalDiv('vl-generic-progress');
366     var api;
367     var params = [recId, 1];
368     if(inCat) {
369         api = ['open-ils.search', 'open-ils.search.biblio.record.html'];
370         if(currentType == 'auth')
371             api = ['open-ils.search', 'open-ils.search.authority.to_html'];
372     } else {
373         params = [authtoken, recId];
374         api = ['open-ils.vandelay', 'open-ils.vandelay.queued_bib_record.html'];
375         if(currentType == 'auth')
376             api = ['open-ils.vandelay', 'open-ils.vandelay.queued_authority_record.html'];
377     }
378     fieldmapper.standardRequest(
379         api, 
380         {   async: true,
381             params: params,
382             oncomplete: function(r) {
383             displayGlobalDiv('vl-marc-html-div');
384                 var html = r.recv().content();
385                 dojo.byId('vl-marc-record-html').innerHTML = html;
386             }
387         }
388     );
389 }
390
391
392 /*
393 function getRecMatchesFromAttrCode(rec, attrCode) {
394     var matches = [];
395     var attr = getRecAttrFromCode(rec, attrCode);
396     for(var j = 0; j < rec.matches().length; j++) {
397         var match = rec.matches()[j];
398         if(match.matched_attr() == attr.id()) 
399             matches.push(match);
400     }
401     return matches;
402 }
403 */
404
405 function getRecAttrFromMatch(rec, match) {
406     for(var i = 0; i < rec.attributes().length; i++) {
407         var attr = rec.attributes()[i];
408         if(attr.id() == match.matched_attr())
409             return attr;
410     }
411 }
412
413 function getRecAttrDefFromAttr(attr, type) {
414     var defs = (type == 'bib') ? bibAttrDefs : authAttrDefs;
415     for(var i = 0; i < defs.length; i++) {
416         var def = defs[i];
417         if(def.id() == attr.field())
418             return def;
419     }
420 }
421
422 function getRecAttrFromCode(rec, attrCode) {
423     var defId = attrDefMap[attrCode];
424     var attrs = rec.attributes();
425     for(var i = 0; i < attrs.length; i++) {
426         var attr = attrs[i];
427         if(attr.field() == defId) 
428             return attr;
429     }
430     return null;
431 }
432
433 function vlGetViewMatches(rowIdx) {
434     var data = this.grid.model.getRow(rowIdx);
435     if(!data) return '';
436     var rec = queuedRecordsMap[data.id];
437     if(rec.matches().length > 0)
438         return this.value.replace('RECID', data.id);
439     return '';
440 }
441
442 function getAttrValue(rowIdx) {
443     var data = this.grid.model.getRow(rowIdx);
444     if(!data) return '';
445     var attrCode = this.field.split('.')[1];
446     var rec = queuedRecordsMap[data.id];
447     var attr = getRecAttrFromCode(rec, attrCode);
448     return (attr) ? attr.attr_value() : '';
449 }
450
451 function vlGetDateTimeField(rowIdx) {
452     data = this.grid.model.getRow(rowIdx);
453     if(!data) return '';
454     if(!data[this.field]) return '';
455     var date = dojo.date.stamp.fromISOString(data[this.field]);
456     return dojo.date.locale.format(date, {selector:'date'});
457 }
458
459 function vlGetCreator(rowIdx) {
460     data = this.grid.model.getRow(rowIdx);
461     if(!data) return '';
462     var id = data.creator;
463     if(userCache[id])
464         return userCache[id].usrname();
465     var user = fieldmapper.standardRequest(
466         ['open-ils.actor', 'open-ils.actor.user.retrieve'], [authtoken, id]);
467     if(e = openils.Event.parse(user))
468         return alert(e);
469     userCache[id] = user;
470     return user.usrname();
471 }
472
473 function vlGetViewMARC(rowIdx) {
474     data = this.grid.model.getRow(rowIdx);
475     if(data) 
476         return this.value.replace('RECID', data.id);
477 }
478
479 function vlGetOverlayTargetSelector(rowIdx) {
480     data = this.grid.model.getRow(rowIdx);
481     if(data) {
482         var value = this.value.replace('ID', data.id);
483         var overlay = currentOverlayRecordsMap[currentImportRecId];
484         if(overlay && overlay == data.id) 
485             value = value.replace('/>', 'checked="checked"/>');
486         return value;
487     }
488 }
489
490 /**
491   * see if the user has enabled overlays for the current match set and, 
492   * if so, map the current import record to the overlay target.
493   */
494 function vlHandleOverlayTargetSelected() {
495     if(vlOverlayTargetEnable.checked) {
496         for(var i = 0; i < currentMatchedRecords.length; i++) {
497             var matchRecId = currentMatchedRecords[i].id();
498             if(dojo.byId('vl-overlay-target-'+matchRecId).checked) {
499                 console.log("found overlay target " + matchRecId);
500                 currentOverlayRecordsMap[currentImportRecId] = matchRecId;
501                 dojo.byId('vl-record-list-selected-' + currentImportRecId).checked = true;
502                 dojo.byId('vl-record-list-selected-' + currentImportRecId).parentNode.className = 'overlay_selected';
503                 return;
504             }
505         }
506     } else {
507         delete currentOverlayRecordsMap[currentImportRecId];
508         dojo.byId('vl-record-list-selected-' + currentImportRecId).checked = false;
509     }
510 }
511
512 var vlQueueGridBuilt = false;
513 function buildRecordGrid(type) {
514     displayGlobalDiv('vl-queue-div');
515
516     currentOverlayRecordsMap = {};
517
518     if(!vlQueueGridBuilt) {
519         var defs = (type == 'bib') ? bibAttrDefs : authAttrDefs;
520         for(var i = 0; i < defs.length; i++) {
521             var def = defs[i]
522             attrDefMap[def.code()] = def.id();
523             var col = {
524                 name:def.description(), 
525                 field:'attr.' + def.code(),
526                 get: getAttrValue,
527                 selectableColumn:true
528             };
529             vlQueueGridLayout[0].cells[0].push(col);
530         }
531         vlQueueGridBuilt = true;
532     }
533
534     var storeData;
535     if(type == 'bib')
536         storeData = vqbr.toStoreData(queuedRecords);
537     else
538         storeData = vqar.toStoreData(queuedRecords);
539
540     var store = new dojo.data.ItemFileReadStore({data:storeData});
541     var model = new dojox.grid.data.DojoData(
542         null, store, {rowsPerPage: 100, clientSort: true, query:{id:'*'}});
543
544     vlQueueGrid.setModel(model);
545     if(vlQueueGridColumePicker) 
546         vlQueueGrid.setStructure(vlQueueGridColumePicker.structure);
547     else
548         vlQueueGrid.setStructure(vlQueueGridLayout);
549     vlQueueGrid.update();
550
551     if(!vlQueueGridColumePicker) {
552         vlQueueGridColumePicker = 
553             new openils.GridColumnPicker(vlQueueGridColumePickerDialog, vlQueueGrid);
554     }
555 }
556
557 function vlDeleteQueue(type, queueId, onload) {
558     fieldmapper.standardRequest(
559         ['open-ils.vandelay', 'open-ils.vandelay.'+type+'_queue.delete'],
560         {   async: true,
561             params: [authtoken, queueId],
562             oncomplete: function(r) {
563                 var resp = r.recv().content();
564                 if(e = openils.Event.parse(resp))
565                     return alert(e);
566                 onload();
567             }
568         }
569     );
570 }
571
572
573 function vlQueueGridDrawSelectBox(rowIdx) {
574     var data = this.grid.model.getRow(rowIdx);
575     if(!data) return '';
576     var domId = 'vl-record-list-selected-' +data.id;
577     selectableGridRecords[domId] = data.id;
578     return "<div><input type='checkbox' id='"+domId+"'/></div>";
579 }
580
581 function vlSelectAllQueueGridRecords() {
582     for(var id in selectableGridRecords) 
583         dojo.byId(id).checked = true;
584 }
585 function vlSelectNoQueueGridRecords() {
586     for(var id in selectableGridRecords) 
587         dojo.byId(id).checked = false;
588 }
589 function vlToggleQueueGridSelect() {
590     if(dojo.byId('vl-queue-grid-row-selector').checked)
591         vlSelectAllQueueGridRecords();
592     else
593         vlSelectNoQueueGridRecords();
594 }
595
596 var handleRetrieveRecords = function() {
597     buildRecordGrid(currentType);
598 }
599
600 function vlImportSelectedRecords() {
601     displayGlobalDiv('vl-generic-progress-with-total');
602     var records = [];
603
604     for(var id in selectableGridRecords) {
605         if(dojo.byId(id).checked) {
606             var recId = selectableGridRecords[id];
607             var rec = queuedRecordsMap[recId];
608             if(!rec.import_time()) 
609                 records.push(recId);
610         }
611     }
612
613     fieldmapper.standardRequest(
614         ['open-ils.vandelay', 'open-ils.vandelay.'+currentType+'_record.list.import'],
615         {   async: true,
616             params: [authtoken, records, {overlay_map:currentOverlayRecordsMap}],
617             onresponse: function(r) {
618                 var resp = r.recv().content();
619                 if(e = openils.Event.parse(resp))
620                     return alert(e);
621                 vlControlledProgressBar.update({maximum:resp.total, progress:resp.progress});
622             },
623             oncomplete: function() {
624                 return retrieveQueuedRecords(currentType, currentQueueId, handleRetrieveRecords);
625             }
626         }
627     );
628 }
629
630 function vlImportRecordQueue(type, queueId, noMatchOnly, onload) {
631     displayGlobalDiv('vl-generic-progress-with-total');
632     var method = 'open-ils.vandelay.bib_queue.import';
633     if(noMatchOnly)
634         method = method.replace('import', 'nomatch.import');
635     if(type == 'auth')
636         method = method.replace('bib', 'auth');
637
638     fieldmapper.standardRequest(
639         ['open-ils.vandelay', method],
640         {   async: true,
641             params: [authtoken, queueId],
642             onresponse: function(r) {
643                 var resp = r.recv().content();
644                 if(e = openils.Event.parse(resp))
645                     return alert(e);
646                 vlControlledProgressBar.update({maximum:resp.total, progress:resp.progress});
647             },
648             oncomplete: function() {onload();}
649         }
650     );
651 }
652
653
654 /**
655   * Create queue, upload MARC, process spool, load the newly created queue 
656   */
657 function batchUpload() {
658     var queueName = dijit.byId('vl-queue-name').getValue();
659     currentType = dijit.byId('vl-record-type').getValue();
660
661     var handleProcessSpool = function() {
662         console.log('records uploaded and spooled');
663         if(vlUploadQueueAutoImport.checked) {
664             vlImportRecordQueue(currentType, currentQueueId, true,  
665                 function() {
666                     retrieveQueuedRecords(currentType, currentQueueId, handleRetrieveRecords);
667                 }
668             );
669         } else {
670             retrieveQueuedRecords(currentType, currentQueueId, handleRetrieveRecords);
671         }
672     }
673
674     var handleUploadMARC = function(key) {
675         console.log('marc uploaded');
676         dojo.style(dojo.byId('vl-upload-status-processing'), 'display', 'block');
677         processSpool(key, currentQueueId, currentType, handleProcessSpool);
678     };
679
680     var handleCreateQueue = function(queue) {
681         console.log('queue created ' + queue.name());
682         currentQueueId = queue.id();
683         uploadMARC(handleUploadMARC);
684     };
685     
686     if(vlUploadQueueSelector.getValue() && !queueName) {
687         currentQueueId = vlUploadQueueSelector.getValue();
688         console.log('adding records to existing queue ' + currentQueueId);
689         uploadMARC(handleUploadMARC);
690     } else {
691         createQueue(queueName, currentType, handleCreateQueue);
692     }
693 }
694
695
696 function vlFleshQueueSelect(selector, type) {
697     var data = (type == 'bib') ? vbq.toStoreData(allUserBibQueues) : vaq.toStoreData(allUserAuthQueues);
698     selector.store = new dojo.data.ItemFileReadStore({data:data});
699     selector.setValue(null);
700     selector.setDisplayedValue('');
701     if(data[0])
702         selector.setValue(data[0].id());
703 }
704
705 function vlShowUploadForm() {
706     displayGlobalDiv('vl-marc-upload-div');
707     vlFleshQueueSelect(vlUploadQueueSelector, vlUploadRecordType.getValue());
708 }
709
710 function vlShowQueueSelect() {
711     displayGlobalDiv('vl-queue-select-div');
712     vlFleshQueueSelect(vlQueueSelectQueueList, vlQueueSelectType.getValue());
713 }
714
715 function vlFetchQueueFromForm() {
716     currentType = vlQueueSelectType.getValue();
717     currentQueueId = vlQueueSelectQueueList.getValue();
718     retrieveQueuedRecords(currentType, currentQueueId, handleRetrieveRecords);
719 }
720
721 dojo.addOnLoad(vlInit);