Vandelay; copy imported bib queue recs to bucket
authorBill Erickson <berick@esilibrary.com>
Mon, 31 Oct 2011 21:33:23 +0000 (17:33 -0400)
committerMike Rylander <mrylander@gmail.com>
Thu, 17 Nov 2011 19:40:32 +0000 (14:40 -0500)
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@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/templates/vandelay/inc/queue.tt2
Open-ILS/web/css/skin/default.css
Open-ILS/web/js/dojo/openils/vandelay/nls/vandelay.js [new file with mode: 0644]
Open-ILS/web/js/ui/default/vandelay/vandelay.js

index b645f33..850d342 100644 (file)
@@ -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>
 </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>
index a7ab2d6..4fa7215 100644 (file)
@@ -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 (file)
index 0000000..c7bfbe9
--- /dev/null
@@ -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.'
+}
+                 
index ff4eba7..2b39612 100644 (file)
@@ -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 */