From 254a9fffe1b50ff8ba8fcf5ba1a39a1a560b295d Mon Sep 17 00:00:00 2001 From: miker Date: Fri, 18 Mar 2011 15:53:04 +0000 Subject: [PATCH] Intelligent Metarecord Format Selection for Holds Previous to this commit, Evergreen would show all possible record formats when promoting a T-type hold to an M-type. This change causes the middle layer method to respect the Hard Boundary of the pickup library when considering what constituent records within a metarecord will contribute formats. Signed-off-by: Mike Rylander git-svn-id: svn://svn.open-ils.org/ILS/trunk@19805 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../lib/OpenILS/Application/Search/Biblio.pm | 32 ++++++++++++++++++++++ Open-ILS/web/opac/skin/default/js/holds.js | 17 ++++++++---- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm index c2b17ebb2f..946677f768 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm @@ -2364,6 +2364,9 @@ sub rec_to_mr_rec_descriptors { my $item_forms = $$args{item_forms}; my $item_types = $$args{item_types}; my $item_lang = $$args{item_lang}; + my $pickup_lib = $$args{pickup_lib}; + + my $hard_boundary = $U->ou_ancestor_setting_value($pickup_lib, OILS_SETTING_HOLD_HARD_BOUNDARY) if (defined $pickup_lib); my $e = new_editor(); my $recs; @@ -2385,6 +2388,35 @@ sub rec_to_mr_rec_descriptors { my $desc = $e->search_metabib_record_descriptor($search); + if ($hard_boundary) { # 0 (or "top") is the same as no setting + my $orgs = $e->json_query( + { from => [ 'actor.org_unit_descendants' => $pickup_lib, $hard_boundary ] } + ); + + my $good_records = $e->json_query( + { distinct => 1, + select => { 'bre' => ['id'] }, + from => { 'bre' => { 'acn' => { 'join' => { 'acp' } } } }, + where => { + '+bre' => { id => \@recs }, + '+acp' => { + circ_lib => [ map { $_->{id} } @$orgs ], + deleted => 'f' + } + } + } + ); + + my @keep; + for my $d (@$desc) { + if ( grep { $d->record == $_->{id} } @$good_records ) { + push @keep, $d; + } + } + + $desc = \@keep; + } + return { metarecord => $mrec, descriptors => $desc }; } diff --git a/Open-ILS/web/opac/skin/default/js/holds.js b/Open-ILS/web/opac/skin/default/js/holds.js index 7ed0eda9cb..748f98c27e 100644 --- a/Open-ILS/web/opac/skin/default/js/holds.js +++ b/Open-ILS/web/opac/skin/default/js/holds.js @@ -300,26 +300,32 @@ function _h_set_rec(args, doneCallback) { function _h_set_rec_descriptors(args, doneCallback) { + if( ! args.pickup_lib ) + args.pickup_lib = getSelectorVal($('holds_org_selector')); + + if(args.pickup_lib === null) + args.pickup_lib = holdArgs.recipient.home_ou(); + // grab the list of record desciptors attached to this records metarecord if( ! args.recordDescriptors ) { - var params = {}; + var params = { pickup_lib: args.pickup_lib }; if (args.type == 'M') { if( !args.metarecord && args.record) { params.metarecord = args.metarecord = args.record; delete(args.record); } else { - params = { metarecord : args.metarecordObject.doc_id() }; + params.metarecord = args.metarecordObject.doc_id(); } } else { - params = { record: args.record }; + params.record = args.record; } if( ! args.record ) { if( args.metarecord ) - params = { metarecord : args.metarecord }; + params.metarecord = args.metarecord; else - params = { metarecord : args.metarecordObject.doc_id() }; + params.metarecord = args.metarecordObject.doc_id(); } var req = new Request(FETCH_MR_DESCRIPTORS, params ); @@ -350,6 +356,7 @@ function holdsDrawWindow() { $('holds_cancel').onclick = function(){ runEvt('common', 'holdUpdateCanceled'), showCanvas() }; $('holds_submit').onclick = function(){holdsPlaceHold(holdsBuildHoldFromWindow())}; $('holds_update').onclick = function(){holdsPlaceHold(holdsBuildHoldFromWindow())}; + $('holds_org_selector').onchange = function(){holdsDrawWindow()}; holdFetchObjects(null, function(){ __holdsDrawWindow(); -- 2.11.0