From 0d7fa6bc3d647d3e030c7e7368811dc6d3ca7703 Mon Sep 17 00:00:00 2001 From: miker Date: Sun, 3 May 2009 00:52:14 +0000 Subject: [PATCH] add configurable string joiner instead of hardcoding a space Open-ILS/web/js/dojo/openils/BibTemplate.js git-svn-id: svn://svn.open-ils.org/ILS/trunk@13038 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/examples/fm_IDL.xml | 11 +- .../src/perlmods/OpenILS/Application/SuperCat.pm | 117 +++++++++++++++++++-- Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm | 3 +- Open-ILS/web/js/dojo/openils/BibTemplate.js | 5 +- 4 files changed, 122 insertions(+), 14 deletions(-) diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 4a5d87876a..2a483e3443 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -1516,6 +1516,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + @@ -1524,6 +1526,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + @@ -1544,8 +1548,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + - + + + + diff --git a/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm b/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm index cf7c189d79..7ed9187ad9 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm @@ -267,7 +267,7 @@ sub cn_browse { my $orgs = $_storage->request( "open-ils.cstore.direct.actor.org_unit.search", $o_search, - { flesh => 3, + { flesh => 100, flesh_fields => { aou => [qw/children/] } } )->gather(1); @@ -362,7 +362,7 @@ sub new_books_by_item { my $orgs = $_storage->request( "open-ils.cstore.direct.actor.org_unit.search", { shortname => $ou }, - { flesh => 10, + { flesh => 100, flesh_fields => { aou => [qw/children/] } } )->gather(1); @@ -533,7 +533,7 @@ sub tag_sf_browse { my $orgs = $_storage->request( "open-ils.cstore.direct.actor.org_unit.search", { shortname => $ou }, - { flesh => 10, + { flesh => 100, flesh_fields => { aou => [qw/children/] } } )->gather(1); @@ -651,9 +651,53 @@ sub holding_data_formats { } __PACKAGE__->register_method( method => 'holding_data_formats', api_name => 'open-ils.supercat.acn.formats', api_level => 1 ); __PACKAGE__->register_method( method => 'holding_data_formats', api_name => 'open-ils.supercat.acp.formats', api_level => 1 ); +__PACKAGE__->register_method( method => 'holding_data_formats', api_name => 'open-ils.supercat.auri.formats', api_level => 1 ); __PACKAGE__->register_method( + method => 'retrieve_uri', + api_name => 'open-ils.supercat.auri.marcxml.retrieve', + api_level => 1, + argc => 1, + signature => + { desc => <<" DESC", +Returns a fleshed call number object + DESC + params => + [ + { name => 'uri_id', + desc => 'An OpenILS asset::uri id', + type => 'number' }, + ], + 'return' => + { desc => 'fleshed uri', + type => 'object' } + } +); +sub retrieve_uri { + my $self = shift; + my $client = shift; + my $cpid = shift; + my $args = shift; + + return OpenILS::Application::SuperCat::unAPI + ->new(OpenSRF::AppSession + ->create( 'open-ils.cstore' ) + ->request( + "open-ils.cstore.direct.asset.uri.retrieve", + $cpid, + { flesh => 10, + flesh_fields => { + auri => [qw/call_number_maps/], + acn => [qw/owning_lib record/], + auricnm => [qw/uri/], + } + }) + ->gather(1)) + ->as_xml($args); +} + +__PACKAGE__->register_method( method => 'retrieve_copy', api_name => 'open-ils.supercat.acp.marcxml.retrieve', api_level => 1, @@ -728,9 +772,10 @@ sub retrieve_callnumber { ->request( "open-ils.cstore.direct.asset.call_number.retrieve", $cnid, - { flesh => 2, + { flesh => 5, flesh_fields => { - acn => [qw/owning_lib record copies/], + acn => [qw/owning_lib record copies uri_maps/], + auricnm => [qw/uri/], acp => [qw/location status circ_lib stat_cat_entries notes/], } }) @@ -792,7 +837,7 @@ sub basic_record_holdings { my $orgs = $_storage->request( "open-ils.cstore.direct.actor.org_unit.search", $o_search, - { flesh => 3, + { flesh => 100, flesh_fields => { aou => [qw/children/] } } )->gather(1); @@ -871,7 +916,8 @@ sub new_record_holdings { { flesh => 5, flesh_fields => { bre => [qw/call_numbers/], - acn => [qw/copies owning_lib/], + acn => [qw/copies owning_lib uri_maps/], + auricnm => [qw/uri/], acp => [qw/location status circ_lib stat_cat_entries notes/], asce => [qw/stat_cat/], } @@ -886,7 +932,7 @@ sub new_record_holdings { my $orgs = $_storage->request( "open-ils.cstore.direct.actor.org_unit.search", $o_search, - { flesh => 3, + { flesh => 100, flesh_fields => { aou => [qw/children/] } } )->gather(1); @@ -911,6 +957,10 @@ sub new_record_holdings { $found = 1; last; } + + if (!$found && ref($cn->uri_maps) && @{$cn->uri_maps}) { + $found = 1 if (grep {$cn->owning_lib->id == $_} @ou_ids); + } next unless $found; $client->respond( @@ -1604,6 +1654,38 @@ sub obj { return $self->{obj}; } +package OpenILS::Application::SuperCat::unAPI::auri; +use base qw/OpenILS::Application::SuperCat::unAPI/; + +sub as_xml { + my $self = shift; + my $args = shift; + + my $xml = 'obj->id . '" '; + $xml .= 'use_restriction="' . $self->escape( $self->obj->use_restriction ) . '" '; + $xml .= 'label="' . $self->escape( $self->obj->label ) . '" '; + $xml .= 'href="' . $self->escape( $self->obj->href ) . '">'; + + if (!$args->{no_volumes} && ref($self->obj->call_number_maps) && @{ $self->obj->call_number_maps }) { + $xml .= '' . join( + '', + map { + OpenILS::Application::SuperCat::unAPI + ->new( $_->call_number ) + ->as_xml({ %$args, no_uris=>1, no_copies=>1 }) + } @{ $self->obj->call_number_maps } + ) . ''; + + } else { + $xml .= ''; + } + + $xml .= ''; + + return $xml; +} + package OpenILS::Application::SuperCat::unAPI::acn; use base qw/OpenILS::Application::SuperCat::unAPI/; @@ -1631,6 +1713,20 @@ sub as_xml { $xml .= ''; } + if (!$args->{no_uris} && ref($self->obj->uri_maps) && @{ $self->obj->uri_maps }) { + $xml .= '' . join( + '', + map { + OpenILS::Application::SuperCat::unAPI + ->new( $_->uri ) + ->as_xml({ %$args, no_volumes=>1 }) + } @{ $self->obj->uri_maps } + ) . ''; + + } else { + $xml .= ''; + } + $xml .= 'obj->owning_lib->id . '" '; @@ -1664,11 +1760,12 @@ sub as_xml { $xml .= '' . $self->escape( $self->obj->status->name ) . ''; $xml .= '' . $self->escape( $self->obj->location->name ) . ''; + $xml .= '' . $self->escape( $self->obj->circ_lib->name ) . ''; - $xml .= 'obj->circ_lib->id . '" '; $xml .= 'shortname="'.$self->escape( $self->obj->circ_lib->shortname ) .'" '; - $xml .= 'name="'.$self->escape( $self->obj->circ_lib->name ) .'">' . $self->escape( $self->obj->circ_lib->name ) . ''; + $xml .= 'name="'.$self->escape( $self->obj->circ_lib->name ) .'"/>'; $xml .= ""; if (ref($self->obj->notes) && $self->obj->notes) { diff --git a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm index 7d60d16994..097c71dab4 100644 --- a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm +++ b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm @@ -352,6 +352,7 @@ sub unapi { $type = 'call_number' if ($1 =~ /^call_number/o); $type = 'acp' if ($1 =~ /^asset-copy/o); $type = 'acn' if ($1 =~ /^asset-call_number/o); + $type = 'auri' if ($1 =~ /^asset-uri/o); $command = 'retrieve'; $command = 'browse' if ($type eq 'call_number'); } @@ -424,7 +425,7 @@ sub unapi { print "Location: $root/../../en-US/skin/default/xml/rdetail.xml?r=$id&l=$lib_id&d=$lib_depth\n\n" if ($type eq 'record'); return 302; - } elsif (OpenILS::WWW::SuperCat::Feed->exists($base_format) && ($type ne 'acn' && $type ne 'acp')) { + } elsif (OpenILS::WWW::SuperCat::Feed->exists($base_format) && ($type ne 'acn' && $type ne 'acp' && $type ne 'auri')) { my $feed = create_record_feed( $type, $format => [ $id ], diff --git a/Open-ILS/web/js/dojo/openils/BibTemplate.js b/Open-ILS/web/js/dojo/openils/BibTemplate.js index 54839868f9..3eb3e386c5 100644 --- a/Open-ILS/web/js/dojo/openils/BibTemplate.js +++ b/Open-ILS/web/js/dojo/openils/BibTemplate.js @@ -28,7 +28,6 @@ if(!dojo._hasResource["openils.BibTemplate"]) { render : function() { var all_slots = dojo.query('*[type^=opac/slot-data]', this.root); - var rec = location.href.split('?')[1]; var slots = {}; dojo.forEach(all_slots, function(s){ @@ -51,6 +50,8 @@ if(!dojo._hasResource["openils.BibTemplate"]) { load: function (bib) { dojo.forEach(slot_list, function (slot) { + var joiner = slot.getAttribute('join') || ' '; + var slot_handler = dojo.query( 'script[type=opac/slot-format]', slot @@ -65,7 +66,7 @@ if(!dojo._hasResource["openils.BibTemplate"]) { slot.innerHTML = dojo.query( slot.getAttribute('query'), bib - ).map(slot_handler).join(' '); + ).map(slot_handler).join(joiner); delete(slot_handler); -- 2.11.0