Import bib trash field Vandelay UI
authorBill Erickson <berick@esilibrary.com>
Fri, 1 Mar 2013 19:55:15 +0000 (14:55 -0500)
committerMike Rylander <mrylander@gmail.com>
Wed, 13 Mar 2013 20:36:10 +0000 (16:36 -0400)
During bib record import, if any optional MARC trash field groups exist
(in the org unit range), a new multi-select option is displayed allowing
the user to specify which trash field groups should be applied to the
current record import/merge/overlay.

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/src/templates/vandelay/inc/upload.tt2
Open-ILS/web/js/ui/default/vandelay/vandelay.js

index f33d682..0d8be97 100644 (file)
@@ -1,3 +1,6 @@
+<style type="text/css">
+    @import "[% ctx.media_prefix %]/js/dojo/dojox/form/resources/CheckedMultiSelect.css";
+</style>
 <div dojoType="dijit.layout.ContentPane" layoutAlign='client' style='margin-top:10px;'>
     <fieldset id='vl-queue-filter-fieldset'>
         <legend>[% l('Queue ') %]<span style='font-style:italic;' id='vl-queue-summary-name'></span></legend>
                         <div jsId='vlUploadFtMergeProfile2' dojoType='dijit.form.FilteringSelect' required='false' labelAttr='name' searchAttr='name'></div>
                     </td>
                 </tr>
+                <tr id='vl-trash-groups-row2'>
+                    <td>[% l('Remove MARC Field Groups') %]</td>
+                    <td colspan='4'>
+                        <select style='overflow-y:auto;' multiple='true' 
+                            jsId="vlUploadTrashGroups2" 
+                            dojoType="dojox.form.CheckedMultiSelect">
+                        </select>
+                    </td>
+                </tr>
+
                 <tr>
                     <td>
                         <button dojoType='dijit.form.Button' jsId='queueItemsImportCancelButton'>[% l('Cancel') %]</button>
index caae6dc..0203306 100644 (file)
                 <div jsId='vlUploadFtMergeProfile' dojoType='dijit.form.FilteringSelect' required='false' labelAttr='name' searchAttr='name'></div>
             </td>
         </tr>
+        <tr id='vl-trash-groups-row'>
+            <td>[% l('Remove MARC Field Groups') %]</td>
+            <td colspan='4'>
+                <select style='overflow-y:auto; height:6em; width:12em' multiple='true' 
+                    jsId="vlUploadTrashGroups" 
+                    dojoType="dojox.form.CheckedMultiSelect">
+                </select>
+            </td>
+        </tr>
 
         <tr><td colspan='2' style='border-bottom:2px solid #888;'></td></tr>
         <tr><td colspan='2' style='padding-bottom: 10px;'></td></tr>
index 26ca3cc..bc82bca 100644 (file)
@@ -44,6 +44,7 @@ dojo.require('openils.widget.OrgUnitFilteringSelect');
 dojo.require('openils.widget.AutoGrid');
 dojo.require('openils.widget.AutoFieldWidget');
 dojo.require('openils.widget.ProgressDialog');
+dojo.require('dojox.form.CheckedMultiSelect');
 
 
 var globalDivs = [
@@ -87,11 +88,12 @@ var cgi = new openils.CGI();
 var vlQueueGridColumePicker = {};
 var vlBibSources = [];
 var importItemDefs = [];
-var matchSets = {};
+var matchSets = {biblio : [], authority : []};
 var mergeProfiles = [];
 var copyStatusCache = {};
 var copyLocationCache = {};
 var localeStrings;
+var trashGroups = [];
 
 // org settings
 var orgSettings = {};
@@ -106,7 +108,7 @@ function vlInit() {
     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 initNeeded = 9; // 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(
@@ -210,7 +212,39 @@ function vlInit() {
         {   async: true,
             oncomplete: function(r) {
                 var stats = openils.Util.readResponse(r);
-                dojo.forEach(stats, function(stat){copyStatusCache[stat.id()] = stat});
+                dojo.forEach(stats, 
+                    function(stat){copyStatusCache[stat.id()] = stat});
+                checkInitDone();
+            }
+        }
+    );
+
+    new openils.PermaCrud().search('vibtg',
+        {   always_apply : 'f',
+            owner: owner.map(function(org) { return org.id(); })
+        }, 
+        {   order_by : {vibtg : ['label']},
+            async: true,
+            oncomplete: function(r) {
+                trashGroups = openils.Util.readResponse(r);
+
+                if (trashGroups.length == 0) {
+                    openils.Util.hide('vl-trash-groups-row');
+                    openils.Util.hide('vl-trash-groups-row2');
+                    checkInitDone();
+                    return;
+                }
+
+                dojo.forEach(trashGroups, function(grp) {
+                    var sn = fieldmapper.aou.findOrgUnit(grp.owner()).shortname();
+                    var opt = {
+                        label : grp.label() + '&nbsp;(' + sn + ')',
+                        value : grp.id()
+                    };
+                    vlUploadTrashGroups.addOption(opt);
+                    vlUploadTrashGroups2.addOption(opt);
+                });
+
                 checkInitDone();
             }
         }
@@ -1189,6 +1223,12 @@ function vlHandleQueueItemsAction(action) {
             vlUploadQueueAutoOverlayBestMatch.attr('value',  vlUploadQueueAutoOverlayBestMatch2.attr('value'));
             vlUploadQueueAutoOverlayBestMatchRatio.attr('value',  vlUploadQueueAutoOverlayBestMatchRatio2.attr('value'));
 
+            // attr('value') and various other incantations won't let me set 
+            // the value on the checkedmultiselect, so we temporarily swap 
+            // the dijits instead.
+            var tmpTrashGroup = vlUploadTrashGroups;
+            vlUploadTrashGroups = vlUploadTrashGroups2;
+
             if(action == 'import') {
                 vlImportSelectedRecords();
             } else if(action == 'import_all') {
@@ -1206,21 +1246,27 @@ function vlHandleQueueItemsAction(action) {
             vlUploadMergeProfile2.attr('value', '');
             vlUploadFtMergeProfile.attr('value', '');
             vlUploadFtMergeProfile2.attr('value', '');
+            vlUploadTrashGroups.attr('value', '');
+            vlUploadTrashGroups2.attr('value', '');
             vlUploadQueueAutoOverlayBestMatch.attr('value', false);
             vlUploadQueueAutoOverlayBestMatch2.attr('value', false);
             vlUploadQueueAutoOverlayBestMatchRatio.attr('value', '0.0');
             vlUploadQueueAutoOverlayBestMatchRatio2.attr('value', '0.0');
+
+            // and... swap them back
+            vlUploadTrashGroups2 = vlUploadTrashGroups;
+            vlUploadTrashGroups = tmpTrashGroup;
         }
     );
 
-    queueItemsImportDialog.show();
-}
-
-function vlHandleCreateBucket() {
+    if (currentType.match(/auth/) || trashGroups.length == 0) {
+        openils.Util.hide('vl-trash-groups-row2');
+    } else {
+        openils.Util.show('vl-trash-groups-row2', 'table-row');
+    }
 
-    create-bucket-dialog-name
+    queueItemsImportDialog.show();
 }
-    
 
 /* import user-selected records */
 function vlImportSelectedRecords() {
@@ -1296,6 +1342,10 @@ function vlImportRecordQueue(type, queueId, recList, onload) {
         options.fall_through_merge_profile = ftprofile;
     }
 
+    var strip_grps = vlUploadTrashGroups.attr('value');
+    if (strip_grps != null && strip_grps.length) {
+        options.strip_field_groups = strip_grps;
+    }
 
     /* determine which method we're calling */
 
@@ -1465,6 +1515,12 @@ function vlShowUploadForm() {
         new dojo.data.ItemFileReadStore({data:viiad.toStoreData(importItemDefs)});
     vlUpdateMatchSetSelector(vlUploadRecordType.getValue());
 
+    if (vlUploadRecordType.attr('value').match(/auth/) || trashGroups.length == 0) {
+        openils.Util.hide('vl-trash-groups-row');
+    } else {
+        openils.Util.show('vl-trash-groups-row', 'table-row');
+    }
+
     // use ratio from the merge profile if it's set
     dojo.connect(
         vlUploadMergeProfile, 
@@ -1486,6 +1542,25 @@ function vlShowUploadForm() {
                vlUploadQueueAutoOverlayBestMatchRatio2.attr('value', profile.lwm_ratio()+''); 
         }
     );
+}
+
+function vlDeleteSelectedQueues() {
+    var checkboxes = document.getElementById('vlQueueSelectList').getElementsByTagName('input');
+    var type = vlQueueSelectType.attr('value').replace(/-.*/, '');
+    for(var i = 0; i < checkboxes.length; i++) {
+        if(checkboxes[i].getAttribute('name') == 'delete' && checkboxes[i].checked) {
+            vlDeleteQueue(type, checkboxes[i].getAttribute('value'), function () {});
+        }
+    }
+    window.location.reload();
+}
+
+function vlShowQueueSelect() {
+    displayGlobalDiv('vl-queue-select-div');
+    var type = vlQueueSelectType.attr('value');
+    var data = vlGetQueueData(type, false);
+    type = type.replace(/-.*/, ''); // To remove any sub-typeish info.
+    var tbody = document.getElementById('vlQueueSelectList');
 
 }