match set selection support in vl uploage UI, part 1
authorberick <berick@esilibrary.com>
Tue, 3 May 2011 19:18:55 +0000 (15:18 -0400)
committerBill Erickson <berick@esilibrary.com>
Wed, 6 Jul 2011 18:50:51 +0000 (14:50 -0400)
Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm
Open-ILS/web/js/ui/default/vandelay/vandelay.js
Open-ILS/web/templates/default/vandelay/inc/upload.tt2

index 0820cb0..510d6bf 100644 (file)
@@ -60,6 +60,7 @@ sub create_bib_queue {
     my $name = shift;
     my $owner = shift;
     my $type = shift;
+    my $match_set = shift;
     my $import_def = shift;
 
     my $e = new_editor(authtoken => $auth, xact => 1);
@@ -78,6 +79,7 @@ sub create_bib_queue {
     $queue->owner( $owner );
     $queue->queue_type( $type ) if ($type);
     $queue->item_attr_def( $import_def ) if ($import_def);
+    $queue->match_set($match_set) if $match_set;
 
     my $new_q = $e->create_vandelay_bib_queue( $queue );
     return $e->die_event unless ($new_q);
@@ -100,6 +102,7 @@ sub create_auth_queue {
     my $name = shift;
     my $owner = shift;
     my $type = shift;
+    my $match_set = shift;
 
     my $e = new_editor(authtoken => $auth, xact => 1);
 
index 6ce390f..ad93a3c 100644 (file)
@@ -86,13 +86,14 @@ var cgi = new openils.CGI();
 var vlQueueGridColumePicker = {};
 var vlBibSources = [];
 var importItemDefs = [];
+var matchSets = {};
 
 /**
   * Grab initial data
   */
 function vlInit() {
     authtoken = openils.User.authtoken;
-    var initNeeded = 6; // how many async responses do we need before we're init'd 
+    var initNeeded = 7; // how many async responses do we need before we're init'd 
     var initCount = 0; // how many async reponses we've received
 
     openils.Util.registerEnterHandler(
@@ -165,6 +166,23 @@ function vlInit() {
         }
     );
 
+    new openils.PermaCrud().search('vms',
+        {owner: owner.map(function(org) { return org.id(); })},
+        {   async: true,
+            oncomplete: function(r) {
+                var sets = openils.Util.readResponse(r);
+                dojo.forEach(sets, 
+                    function(set) {
+                        if(!matchSets[set.mtype()])
+                            matchSets[set.mtype()] = [];
+                        matchSets[set.mtype()].push(set);
+                    }
+                );
+                checkInitDone();
+            }
+        }
+    );
+
     vlAttrEditorInit();
 }
 
@@ -319,13 +337,13 @@ function uploadMARC(onload){
 /**
   * Creates a new vandelay queue
   */
-function createQueue(queueName, type, onload, importDefId) {
+function createQueue(queueName, type, onload, importDefId, matchSet) {
     var name = (type=='bib') ? 'bib' : 'authority';
     var method = 'open-ils.vandelay.'+ name +'_queue.create'
     fieldmapper.standardRequest(
         ['open-ils.vandelay', method],
         {   async: true,
-            params: [authtoken, queueName, null, name, importDefId],
+            params: [authtoken, queueName, null, name, matchSet, importDefId],
             oncomplete : function(r) {
                 var queue = r.recv().content();
                 if(e = openils.Event.parse(queue)) 
@@ -1111,7 +1129,10 @@ function batchUpload() {
         currentQueueId = vlUploadQueueSelector.getValue();
         uploadMARC(handleUploadMARC);
     } else {
-        createQueue(queueName, currentType, handleCreateQueue, vlUploadQueueHoldingsImportProfile.attr('value'));
+        createQueue(queueName, currentType, handleCreateQueue, 
+            vlUploadQueueHoldingsImportProfile.attr('value'),
+            vlUploadQueueMatchSet.attr('value')
+        );
     }
 }
 
@@ -1134,9 +1155,13 @@ function vlFleshQueueSelect(selector, type) {
         if(val) {
             vlUploadQueueHoldingsImportProfile.attr('value', queue.item_attr_def() || '');
             vlUploadQueueHoldingsImportProfile.attr('disabled', true);
+            vlUploadQueueMatchSet.attr('value', queue.match_set() || '');
+            vlUploadQueueMatchSet.attr('disabled', true);
         } else {
             vlUploadQueueHoldingsImportProfile.attr('value', '');
             vlUploadQueueHoldingsImportProfile.attr('disabled', false);
+            vlUploadQueueMatchSet.attr('value', '');
+            vlUploadQueueMatchSet.attr('disabled', false);
         }
         dojo.disconnect(qInput._onchange);
         qInput.attr('value', '');
@@ -1148,6 +1173,8 @@ function vlFleshQueueSelect(selector, type) {
         // user entered a new queue name. clear the selector 
         vlUploadQueueHoldingsImportProfile.attr('value', '');
         vlUploadQueueHoldingsImportProfile.attr('disabled', false);
+        vlUploadQueueMatchSet.attr('value', '');
+        vlUploadQueueMatchSet.attr('disabled', false);
         dojo.disconnect(selector._onchange);
         selector.attr('value', '');
         selector._onchange = dojo.connect(selector, 'onChange', selChange);
@@ -1157,6 +1184,12 @@ function vlFleshQueueSelect(selector, type) {
     qInput._onchange = dojo.connect(qInput, 'onChange', inputChange);
 }
 
+function vlUpdateMatchSetSelector(type) {
+    type = (type.match(/bib/)) ? 'biblio' : 'authority';
+    vlUploadQueueMatchSet.store = 
+        new dojo.data.ItemFileReadStore({data:vms.toStoreData(matchSets[type])});
+}
+
 function vlShowUploadForm() {
     displayGlobalDiv('vl-marc-upload-div');
     vlFleshQueueSelect(vlUploadQueueSelector, vlUploadRecordType.getValue());
@@ -1165,6 +1198,7 @@ function vlShowUploadForm() {
     vlUploadSourceSelector.setValue(vlBibSources[0].id());
     vlUploadQueueHoldingsImportProfile.store = 
         new dojo.data.ItemFileReadStore({data:viiad.toStoreData(importItemDefs)});
+    vlUpdateMatchSetSelector(vlUploadRecordType.getValue());
 }
 
 function vlShowQueueSelect() {
index 8356075..909670e 100644 (file)
             </td>
         </tr>
         <tr>
+            <td>Record Match Set</td>
+            <td>
+                <input jsId='vlUploadQueueMatchSet'
+                    dojoType='dijit.form.FilteringSelect' labelAttr='name' searchAttr='name'/>
+            </td>
+        </tr>
+        <tr>
             <td>Holdings Import Profile</td>
             <td>
                 <input jsId='vlUploadQueueHoldingsImportProfile'