added option to import holdings from main record import screen. Give the user the...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 17 Jul 2009 16:04:45 +0000 (16:04 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 17 Jul 2009 16:04:45 +0000 (16:04 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@13617 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm
Open-ILS/web/js/ui/default/vandelay/vandelay.js
Open-ILS/web/templates/default/vandelay/inc/export.tt2
Open-ILS/web/templates/default/vandelay/inc/upload.tt2

index 7dd9002..563851b 100644 (file)
@@ -848,16 +848,6 @@ __PACKAGE__->register_method(
     stream      => 1,
        record_type     => 'bib'
 );
-
-sub import_record_asset_list {
-    my($self, $conn, $auth, $rec_ids) = @_;
-    my $e = new_editor(authtoken => $auth);
-    return $e->event unless $e->checkauth;
-    my $err = import_record_asset_list_impl($conn, $rec_ids, $e->requestor);
-    return $err if $err;
-    return {complete => 1};
-}
-
 __PACKAGE__->register_method(  
        api_name        => "open-ils.vandelay.bib_record.queue.asset.import",
        method          => 'import_record_queue_assets',
@@ -868,21 +858,21 @@ __PACKAGE__->register_method(
 );
 
 sub import_record_list_assets {
-    my($self, $conn, $auth, $rec_ids) = @_;
+    my($self, $conn, $auth, $import_def, $rec_ids) = @_;
     my $e = new_editor(authtoken => $auth);
     return $e->event unless $e->checkauth;
-    my $err = import_record_asset_list_impl($conn, $rec_ids, $e->requestor);
+    my $err = import_record_asset_list_impl($conn, $import_def, $rec_ids, $e->requestor);
     return $err if $err;
     return {complete => 1};
 }
 
 sub import_record_queue_assets {
-    my($self, $conn, $auth, $q_id) = @_;
+    my($self, $conn, $auth, $import_def, $q_id) = @_;
     my $e = new_editor(authtoken => $auth);
     return $e->event unless $e->checkauth;
     my $rec_ids = $e->search_vandelay_queued_bib_record(
         {queue => $q_id, import_time => {'!=' => undef}}, {idlist => 1});
-    my $err = import_record_asset_list_impl($conn, $rec_ids, $e->requestor);
+    my $err = import_record_asset_list_impl($conn, $import_def, $rec_ids, $e->requestor);
     return $err if $err;
     return {complete => 1};
 }
@@ -891,7 +881,7 @@ sub import_record_queue_assets {
 # Given a list of queued record IDs, imports all items attached to those records
 # --------------------------------------------------------------------------------
 sub import_record_asset_list_impl {
-    my($conn, $rec_ids, $requestor) = @_;
+    my($conn, $import_def, $rec_ids, $requestor) = @_;
 
     my $total = @$rec_ids;
     my $try_count = 0;
@@ -901,7 +891,7 @@ sub import_record_asset_list_impl {
     for my $rec_id (@$rec_ids) {
         my $rec = $roe->retrieve_vandelay_queued_bib_record($rec_id);
         next unless $rec and $rec->import_time;
-        my $item_ids = $roe->search_vandelay_import_item({record => $rec->id}, {idlist=>1});
+        my $item_ids = $roe->search_vandelay_import_item({definition => $import_def, record => $rec->id}, {idlist=>1});
 
         for my $item_id (@$item_ids) {
             my $e = new_editor(requestor => $requestor, xact => 1);
index eaa3bdd..f8542b1 100644 (file)
@@ -32,12 +32,14 @@ dojo.require('dojo.date.locale');
 dojo.require('dojo.date.stamp');
 dojo.require("fieldmapper.Fieldmapper");
 dojo.require("fieldmapper.dojoData");
+dojo.require("fieldmapper.OrgUtils");
 dojo.require('openils.CGI');
 dojo.require('openils.User');
 dojo.require('openils.Event');
 dojo.require('openils.Util');
 dojo.require('openils.MarcXPathParser');
 dojo.require('openils.widget.GridColumnPicker');
+dojo.require('openils.PermaCrud');
 
 
 var globalDivs = [
@@ -77,13 +79,14 @@ var selectableGridRecords;
 var cgi = new openils.CGI();
 var vlQueueGridColumePicker = {};
 var vlBibSources = [];
+var importItemDefs = [];
 
 /**
   * Grab initial data
   */
 function vlInit() {
     authtoken = openils.User.authtoken;
-    var initNeeded = 5; // how many async responses do we need before we're init'd 
+    var initNeeded = 6; // 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(
@@ -133,6 +136,17 @@ function vlInit() {
         }
     );
 
+    var owner = fieldmapper.aou.orgNodeTrail(fieldmapper.aou.findOrgUnit(new openils.User().user.ws_ou()));
+    new openils.PermaCrud().search('viiad', 
+        {owner: owner.map(function(org) { return org.id(); })},
+        {   async: true,
+            oncomplete: function(r) {
+                importItemDefs = openils.Util.readResponse(r);
+                checkInitDone();
+            }
+        }
+    );
+
     vlAttrEditorInit();
 }
 
@@ -822,6 +836,21 @@ function vlImportRecordQueue(type, queueId, noMatchOnly, onload) {
 }
 
 
+function vlImportHoldings(queueId, importProfile, onload) {
+    displayGlobalDiv('vl-generic-progress-with-total');
+    fieldmapper.standardRequest(
+        ['open-ils.vandelay', 'open-ils.vandelay.bib_record.queue.asset.import'],
+        {   async: true,
+            params: [authtoken, importProfile, queueId],
+            onresponse: function(r) {
+                var resp = openils.Util.readResponse(r);
+                vlControlledProgressBar.update({maximum:resp.total, progress:resp.progress});
+            },
+            oncomplete: function() {onload();}
+        }
+    );
+}
+
 /**
   * Create queue, upload MARC, process spool, load the newly created queue 
   */
@@ -833,7 +862,17 @@ function batchUpload() {
         if(vlUploadQueueAutoImport.checked) {
             vlImportRecordQueue(currentType, currentQueueId, true,  
                 function() {
-                    retrieveQueuedRecords(currentType, currentQueueId, handleRetrieveRecords);
+                    if(vlUploadQueueHoldingsImport.checked) {
+                        vlImportHoldings(
+                            currentQueueId, 
+                            vlUploadQueueHoldingsImportProfile.attr('value'), 
+                            function() { 
+                                retrieveQueuedRecords(currentType, currentQueueId, handleRetrieveRecords);
+                            }
+                        );
+                    } else {
+                        retrieveQueuedRecords(currentType, currentQueueId, handleRetrieveRecords);
+                    }
                 }
             );
         } else {
@@ -875,6 +914,17 @@ function vlShowUploadForm() {
     vlUploadSourceSelector.store = 
         new dojo.data.ItemFileReadStore({data:cbs.toStoreData(vlBibSources, 'source')});
     vlUploadSourceSelector.setValue(vlBibSources[0].id());
+    vlUploadQueueHoldingsImportProfile.store = 
+        new dojo.data.ItemFileReadStore({data:viiad.toStoreData(importItemDefs)});
+    vlUploadQueueHoldingsImportProfile.attr('disabled', true);
+    dojo.connect(vlUploadQueueHoldingsImport, 'onChange',
+        function(val) {
+            if(val)
+                vlUploadQueueHoldingsImportProfile.attr('disabled', false);
+            else
+                vlUploadQueueHoldingsImportProfile.attr('disabled', true);
+        }
+    );
 }
 
 function vlShowQueueSelect() {
index 292f13b..1f7a9e3 100644 (file)
@@ -1,5 +1,5 @@
 <h1>&vandelay.export.records;</h1><br/>
-<form method="POST" enctype="multipart/form-data" action='/exporter'>
+<form method="POST" enctype="multipart/form-data" action='https://[% ctx.hostname %]/exporter'>
     <table class='form_table'>
         <tr class='export_tr_border'>
             <td>&vandelay.export.use_field_no;</td>
index 9c71353..f380229 100644 (file)
             </td>
         </tr>
         <tr>
+            <td>Import Attached Holdings</td>
+            <td colspan='4'>
+                <input jsId='vlUploadQueueHoldingsImport' dojoType='dijit.form.CheckBox'/>
+            </td>
+        </tr>
+        <tr>
+            <td>Holdings Import Profile</td>
+            <td>
+                <input jsId='vlUploadQueueHoldingsImportProfile'
+                    dojoType='dijit.form.FilteringSelect' labelAttr='name' searchAttr='name'/>
+            </td>
+        </tr>
+        <tr>
             <td>&vandelay.import.bib_sources;</td>
             <td>
-                <select name='bib_source' jsId='vlUploadSourceSelector' dojoType='dijit.form.FilteringSelect' labelAttr='source' searchAttr='source'>
-                </select>
+                <select name='bib_source' jsId='vlUploadSourceSelector' 
+                    dojoType='dijit.form.FilteringSelect' labelAttr='source' searchAttr='source'/>
             </td>
         </tr>
         <tr>