From: Dan Scott Date: Sun, 11 Mar 2012 03:05:36 +0000 (-0500) Subject: TPAC: Teach record details how to sort by preferred library X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=827f109b6f22147cc1fddb8c7dac8bacca54f16a;p=working%2FEvergreen.git TPAC: Teach record details how to sort by preferred library Using the same _get_pref_lib() function to grab our preferred library, replace the order_by clause in mk_copy_query() with the evergreen.rank_ou() routine. Copies in record details display now sort in the same library order as in search results. Signed-off-by: Dan Scott --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm index 2daaf2ffe0..476d539ff1 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm @@ -15,6 +15,7 @@ sub load_record { $ctx->{page} = 'record'; my $org = $self->_get_search_lib(); + my $pref_ou = $self->_get_pref_lib(); my $depth = $self->cgi->param('depth'); $depth = $ctx->{get_aou}->($org)->ou_type->depth unless defined $depth; # can be 0 @@ -41,7 +42,7 @@ sub load_record { my $cstore = OpenSRF::AppSession->create('open-ils.cstore'); my $copy_rec = $cstore->request( 'open-ils.cstore.json_query.atomic', - $self->mk_copy_query($rec_id, $org, $copy_depth, $copy_limit, $copy_offset) + $self->mk_copy_query($rec_id, $org, $copy_depth, $copy_limit, $copy_offset, $pref_ou) ); my (undef, @rec_data) = $self->get_records_and_facets([$rec_id], undef, {flesh => '{holdings_xml,bmp,mra,acp,acnp,acns}'}); @@ -143,6 +144,7 @@ sub mk_copy_query { my $depth = shift; my $copy_limit = shift; my $copy_offset = shift; + my $pref_ou = shift; my $query = { select => { @@ -203,6 +205,9 @@ sub mk_copy_query { }, order_by => [ + { class => "aou", field => 'id', + transform => 'evergreen.rank_ou', params => [$pref_ou, $org] + }, {class => 'aou', field => 'name'}, {class => 'acn', field => 'label'} ], @@ -211,16 +216,6 @@ sub mk_copy_query { offset => $copy_offset }; - # XXX In the future, $sort_org should be understood to be an abstration - # that refers to something configurable, not necessariyl physical_loc. - - if (my $sort_org = $self->ctx->{physical_loc}) { - unshift @{$query->{order_by}}, { - class => 'acp', field => 'circ_lib', transform => 'numeric_eq', - params => [$sort_org], direction => 'desc' - }; - } - if($org != $self->ctx->{aou_tree}->()->id) { # no need to add the org join filter if we're not actually filtering $query->{from}->{acp}->{aou} = {