[open-ils-commits] [GIT] Evergreen ILS branch master updated. ad07dc3faddeca280969bf6825a6947e27419b96

Evergreen Git git at git.evergreen-ils.org
Thu Nov 17 14:32:34 EST 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  ad07dc3faddeca280969bf6825a6947e27419b96 (commit)
       via  aed4b69715f34188a9c906d72345632d41283415 (commit)
      from  472c7e7669e21cc8cc08b14b00e768e420d1151c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ad07dc3faddeca280969bf6825a6947e27419b96
Author: Bill Erickson <berick at esilibrary.com>
Date:   Mon Oct 31 17:33:23 2011 -0400

    Vandelay; copy imported bib queue recs to bucket
    
    Adds a "Copy to Bucket" option within the Vandelay queue interface.
    User is given the option to name the bucket.  If the bucket already
    exists, the records are added to the existing bucket.  Otherwise, a new
    bucket is created and the records are added.
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/templates/vandelay/inc/queue.tt2 b/Open-ILS/src/templates/vandelay/inc/queue.tt2
index b645f33..850d342 100644
--- a/Open-ILS/src/templates/vandelay/inc/queue.tt2
+++ b/Open-ILS/src/templates/vandelay/inc/queue.tt2
@@ -16,6 +16,7 @@
                                     if(confirm("[% l('Are you sure you want to delete this queue?') %]")) {
                                         vlDeleteQueue(currentType, currentQueueId, 
                                             function() { displayGlobalDiv("vl-marc-upload-div"); });}'>[% l('Delete Queue') %]</a></td></tr>
+                                <tr id='add-to-bucket-action'><td><a href='javascript:;' onclick='createBucketDialog.show()'>[% l('Copy To Bucket') %]</a></td></tr>
                             </tbody>
                         </table>
                     </td>
@@ -250,4 +251,14 @@
 </div>
 
 
-
+<div jsId='progressDialog' dojoType='openils.widget.ProgressDialog'></div>
+<div jsId='createBucketDialog' dojoType="dijit.Dialog" class='center' title="[% l('Copy Records to Bucket') %]">
+    <div dojoType="dijit.layout.ContentPane" class='pad-level-1'>
+        <div class='pad-level-1'>[% l('Please enter the name of the bucket to append/create.') %]</div>
+        <div class='pad-level-1'><input dojoType='dijit.form.TextBox' name='name' id='create-bucket-dialog-name'/></div>
+        <div>
+            <button class='pad-level-1' dojoType="dijit.form.Button" type="submit" onClick="handleCreateBucket()">[% l('Apply') %]</button>
+            <button class='pad-level-1' dojoType="dijit.form.Button" type="submit" onClick="createBucketDialog.hide()">[% l('Cancel') %]</button>
+        </div>
+    </div>
+</div>
diff --git a/Open-ILS/web/css/skin/default.css b/Open-ILS/web/css/skin/default.css
index a7ab2d6..4fa7215 100644
--- a/Open-ILS/web/css/skin/default.css
+++ b/Open-ILS/web/css/skin/default.css
@@ -115,3 +115,6 @@ table { border-collapse: collapse; }
 .openils-widget-editpane-ro-value-cell {
     text-decoration: underline;
 }
+
+.pad-level-1 { padding: 5px; }
+.center { text-align: center; }
diff --git a/Open-ILS/web/js/dojo/openils/vandelay/nls/vandelay.js b/Open-ILS/web/js/dojo/openils/vandelay/nls/vandelay.js
new file mode 100644
index 0000000..c7bfbe9
--- /dev/null
+++ b/Open-ILS/web/js/dojo/openils/vandelay/nls/vandelay.js
@@ -0,0 +1,5 @@
+{
+    NO_BUCKET_ITEMS : 'No bucket was created because the selected queue has no imported records',
+    BUCKET_CREATE_SUCCESS : 'Successfully added ${0} record(s) to bucket "${1}".\n\nThe bucket now has ${2} total records.'
+}
+                 
diff --git a/Open-ILS/web/js/ui/default/vandelay/vandelay.js b/Open-ILS/web/js/ui/default/vandelay/vandelay.js
index ff4eba7..2b39612 100644
--- a/Open-ILS/web/js/ui/default/vandelay/vandelay.js
+++ b/Open-ILS/web/js/ui/default/vandelay/vandelay.js
@@ -43,6 +43,7 @@ dojo.require('openils.PermaCrud');
 dojo.require('openils.widget.OrgUnitFilteringSelect');
 dojo.require('openils.widget.AutoGrid');
 dojo.require('openils.widget.AutoFieldWidget');
+dojo.require('openils.widget.ProgressDialog');
 
 
 var globalDivs = [
@@ -90,11 +91,16 @@ var matchSets = {};
 var mergeProfiles = [];
 var copyStatusCache = {};
 var copyLocationCache = {};
+var localeStrings;
 
 /**
   * Grab initial data
   */
 function vlInit() {
+
+    dojo.requireLocalization("openils.vandelay", "vandelay");
+    localeStrings = dojo.i18n.getLocalization("openils.vandelay", "vandelay");
+
     authtoken = openils.User.authtoken;
     var initNeeded = 8; // how many async responses do we need before we're init'd 
     var initCount = 0; // how many async reponses we've received
@@ -954,10 +960,12 @@ function buildRecordGrid(type) {
         openils.Util.show('vl-bib-queue-grid-wrapper');
         openils.Util.hide('vl-auth-queue-grid-wrapper');
         vlQueueGrid = vlBibQueueGrid;
+        openils.Util.show('add-to-bucket-action', 'table-row');
     } else {
         openils.Util.show('vl-auth-queue-grid-wrapper');
         openils.Util.hide('vl-bib-queue-grid-wrapper');
         vlQueueGrid = vlAuthQueueGrid;
+        openils.Util.hide('add-to-bucket-action');
     }
 
 
@@ -1070,6 +1078,10 @@ var handleRetrieveRecords = function() {
             dojo.byId('vl-queue-summary-import-item-imported-count').innerHTML = summary.total_items_imported + '';
             dojo.byId('vl-queue-summary-rec-error-count').innerHTML = summary.rec_import_errors + '';
             dojo.byId('vl-queue-summary-item-error-count').innerHTML = summary.item_import_errors + '';
+           
+            if (dojo.byId('create-bucket-dialog-name')) {
+                dojo.byId('create-bucket-dialog-name').value = summary.queue.name();
+            }
         }
     );
 }
@@ -1089,6 +1101,36 @@ function vlFetchQueueSummary(qId, type, onload) {
     );
 }
 
+function handleCreateBucket(args) {
+    var bname = dojo.byId('create-bucket-dialog-name').value;
+    if (!bname) return;
+
+    progressDialog.show(true);
+    fieldmapper.standardRequest(
+        ['open-ils.vandelay', 'open-ils.vandelay.bib_queue.to_bucket'],
+        {   async : true,
+            params : [authtoken, currentQueueId, bname],
+            oncomplete : function(r) {
+                progressDialog.hide();
+                setTimeout(function() { 
+                    var resp = openils.Util.readResponse(r);
+                    if (resp.add_count == 0) {
+                        alert(localeStrings.NO_BUCKET_ITEMS);
+                    } else {
+                        alert(
+                            dojo.string.substitute(
+                                localeStrings.BUCKET_CREATE_SUCCESS,
+                                [resp.add_count, bname, resp.item_count]
+                            )
+                        );
+                    }
+                }, 200); // give the dialog a chance to hide
+            }
+        }
+    );
+}
+    
+
 var _importCancelHandler;
 var _importGoHandler;
 function vlHandleQueueItemsAction(action) {
@@ -1147,6 +1189,11 @@ function vlHandleQueueItemsAction(action) {
 
     queueItemsImportDialog.show();
 }
+
+function vlHandleCreateBucket() {
+
+    create-bucket-dialog-name
+}
     
 
 /* import user-selected records */

commit aed4b69715f34188a9c906d72345632d41283415
Author: Bill Erickson <berick at esilibrary.com>
Date:   Mon Oct 31 14:56:48 2011 -0400

    Vandelay; API for creating buckets from queues
    
    * Adds a new biblio record entry bucket type of "vandelay_queue"
    * Adds a new API call that allows callers to create new buckets (or add
    to existing buckets), copying imported records from a vandelay queue
    into the bucket.
    
    open-ils.vandelay.bib_queue.to_bucket
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm
index 62dca2e..b30d652 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm
@@ -12,7 +12,6 @@ use OpenILS::Utils::CStoreEditor qw/:funcs/;
 use MARC::Batch;
 use MARC::Record;
 use MARC::File::XML ( BinaryEncoding => 'UTF-8' );
-use OpenILS::Utils::Fieldmapper;
 use Time::HiRes qw(time);
 use OpenSRF::Utils::Logger qw/$logger/;
 use MIME::Base64;
@@ -1770,4 +1769,101 @@ sub match_set_update_tree {
     $e->commit or return $e->die_event;
 }
 
+__PACKAGE__->register_method(  
+    api_name    => 'open-ils.vandelay.bib_queue.to_bucket',
+    method      => 'bib_queue_to_bucket',
+    api_level   => 1,
+    argc        => 2,
+    signature   => {
+        desc    => q/Add to or create a new bib container (bucket) with the successfully 
+                    imported contents of a vandelay queue.  Any user that has Vandelay 
+                    queue create permissions can append or create buckets from his-her own queues./,
+        params  => [
+            {desc => 'Authtoken', type => 'string'},
+            {desc => 'Queue ID', type => 'number'},
+            {desc => 'Bucket Name', type => 'string'}
+        ],
+        return  => {desc => q/
+            {bucket => $bucket, addcount => number-of-items-added-to-bucket, item_count => total-bucket-item-count} on success,
+            {add_count => 0} if there is nothing to do, and Event on error/}
+    }
+);
+
+sub bib_queue_to_bucket {
+    my ($self, $conn, $auth, $q_id, $bucket_name) = @_;
+
+    my $e = new_editor(xact => 1, authtoken => $auth);
+    return $e->die_event unless $e->checkauth;
+    
+    my $queue = $e->retrieve_vandelay_bib_queue($q_id)
+        or return $e->die_event;
+
+    return OpenILS::Event->new('BAD_PARAMS', 
+        note => q/Bucket creator must be queue owner/)
+        unless $queue->owner == $e->requestor->id;
+
+    # find the bib IDs that will go into the bucket
+    my $bib_ids = $e->json_query({
+        select => {vqbr => ['imported_as']},
+        from => 'vqbr',
+        where => {queue => $q_id, imported_as => {'!=' => undef}}
+    });
+
+    if (!@$bib_ids) { # no records to add
+        $e->rollback;
+        return {add_count => 0};
+    }
+
+    # allow user to add to an existing bucket by name
+    my $bucket = $e->search_container_biblio_record_entry_bucket({
+        owner => $e->requestor->id, 
+        name => $bucket_name,
+        btype => 'vandelay_queue'
+    })->[0];
+
+    # if the bucket does not exist, create a new one
+    if (!$bucket) { 
+        $bucket = Fieldmapper::container::biblio_record_entry_bucket->new;
+        $bucket->name($bucket_name);
+        $bucket->owner($e->requestor->id);
+        $bucket->btype('vandelay_queue');
+
+        $e->create_container_biblio_record_entry_bucket($bucket)
+            or return $e->die_event;
+    }
+
+    # create the new bucket items
+    for my $bib_id ( map {$_->{imported_as}} @$bib_ids ) {
+        my $item = Fieldmapper::container::biblio_record_entry_bucket_item->new;
+        $item->target_biblio_record_entry($bib_id);
+        $item->bucket($bucket->id);
+        $e->create_container_biblio_record_entry_bucket_item($item)
+            or return $e->die_event;
+    }
+
+    # re-fetch the bucket to pick up the correct create_time
+    $bucket = $e->retrieve_container_biblio_record_entry_bucket($bucket->id)
+        or return $e->die_event;
+
+    # get the total count of items in this bucket
+    my $count = $e->json_query({
+        select => {cbrebi => [{
+            aggregate =>  1,
+            transform => 'count',
+            alias => 'count',
+            column => 'id'
+        }]},
+        from => 'cbrebi',
+        where => {bucket => $bucket->id}
+    })->[0];
+
+    $e->commit;
+
+    return {
+        bucket => $bucket, 
+        add_count => scalar(@$bib_ids), # items added to the bucket
+        item_count => $count->{count} # total items in buckets
+    };
+}
+
 1;
diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
index e317202..2422cfe 100644
--- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql
+++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
@@ -10396,3 +10396,10 @@ INSERT INTO action_trigger.validator ( module, description ) VALUES (
     'ReservationIsAvailable',
     'Checked that a reserved resource is available for checkout'
 );
+
+INSERT INTO container.biblio_record_entry_bucket_type (code, label) VALUES (
+    'vandelay_queue',
+    oils_i18n_gettext('vandelay_queue', 'Vandelay Queue', 'cbrebt', 'label')
+);
+
+
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.vandelay-queue-bib-bucket-type.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.vandelay-queue-bib-bucket-type.sql
new file mode 100644
index 0000000..ef2ffd8
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.vandelay-queue-bib-bucket-type.sql
@@ -0,0 +1,13 @@
+-- Evergreen DB patch XXXX.data.vandelay-queue-bib-bucket-type.sql
+--
+BEGIN;
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+INSERT INTO container.biblio_record_entry_bucket_type (code, label) VALUES (
+    'vandelay_queue',
+    oils_i18n_gettext('vandelay_queue', 'Vandelay Queue', 'cbrebt', 'label')
+);
+
+COMMIT;

-----------------------------------------------------------------------

Summary of changes:
 .../perlmods/lib/OpenILS/Application/Vandelay.pm   |   98 +++++++++++++++++++-
 Open-ILS/src/sql/Pg/950.data.seed-values.sql       |    7 ++
 .../XXXX.data.vandelay-queue-bib-bucket-type.sql   |   13 +++
 Open-ILS/src/templates/vandelay/inc/queue.tt2      |   13 +++-
 Open-ILS/web/css/skin/default.css                  |    3 +
 .../web/js/dojo/openils/vandelay/nls/vandelay.js   |    5 +
 Open-ILS/web/js/ui/default/vandelay/vandelay.js    |   47 ++++++++++
 7 files changed, 184 insertions(+), 2 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.data.vandelay-queue-bib-bucket-type.sql
 create mode 100644 Open-ILS/web/js/dojo/openils/vandelay/nls/vandelay.js


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list