From d53538e7a19e4c3ae9265ac6a9ee32a1f8d89ec7 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 1 Mar 2013 14:55:15 -0500 Subject: [PATCH] Import bib trash field Vandelay UI 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 Signed-off-by: Mike Rylander --- Open-ILS/src/templates/vandelay/inc/queue.tt2 | 13 ++++ Open-ILS/src/templates/vandelay/inc/upload.tt2 | 9 +++ Open-ILS/web/js/ui/default/vandelay/vandelay.js | 93 ++++++++++++++++++++++--- 3 files changed, 106 insertions(+), 9 deletions(-) diff --git a/Open-ILS/src/templates/vandelay/inc/queue.tt2 b/Open-ILS/src/templates/vandelay/inc/queue.tt2 index f33d68279a..0d8be970eb 100644 --- a/Open-ILS/src/templates/vandelay/inc/queue.tt2 +++ b/Open-ILS/src/templates/vandelay/inc/queue.tt2 @@ -1,3 +1,6 @@ +
[% l('Queue ') %] @@ -237,6 +240,16 @@
+ + [% l('Remove MARC Field Groups') %] + + + + + diff --git a/Open-ILS/src/templates/vandelay/inc/upload.tt2 b/Open-ILS/src/templates/vandelay/inc/upload.tt2 index caae6dccab..020330622d 100644 --- a/Open-ILS/src/templates/vandelay/inc/upload.tt2 +++ b/Open-ILS/src/templates/vandelay/inc/upload.tt2 @@ -89,6 +89,15 @@
+ + [% l('Remove MARC Field Groups') %] + + + + diff --git a/Open-ILS/web/js/ui/default/vandelay/vandelay.js b/Open-ILS/web/js/ui/default/vandelay/vandelay.js index 26ca3cc73f..bc82bca951 100644 --- a/Open-ILS/web/js/ui/default/vandelay/vandelay.js +++ b/Open-ILS/web/js/ui/default/vandelay/vandelay.js @@ -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() + ' (' + 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'); } -- 2.11.0