From 8d25af615527e730bb75942a3bbcb822793d6aee Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Wed, 7 Mar 2012 11:54:55 -0500 Subject: [PATCH] pretty good working copy summary for serial units still need: twisties, testing nested paging better Signed-off-by: Lebbeous Fogle-Weekley --- .../perlmods/lib/OpenILS/Application/AppUtils.pm | 15 +- .../src/perlmods/lib/OpenILS/Application/Serial.pm | 15 +- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm | 5 +- .../src/templates/opac/parts/record/copy_table.tt2 | 62 +++++-- .../src/templates/opac/parts/record/issues-db.tt2 | 143 ++++++++++++++++ .../templates/opac/parts/record/issues-mfhd.tt2 | 40 +++++ .../src/templates/opac/parts/record/issues.tt2 | 181 +-------------------- .../src/templates/opac/parts/record/summary.tt2 | 2 +- Open-ILS/web/css/skin/default/opac/style.css | 2 + 9 files changed, 266 insertions(+), 199 deletions(-) create mode 100644 Open-ILS/src/templates/opac/parts/record/issues-db.tt2 create mode 100644 Open-ILS/src/templates/opac/parts/record/issues-mfhd.tt2 diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm index c47d51ce2b..2c0a1103a1 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm @@ -1959,8 +1959,11 @@ sub bib_container_items_via_search { # filters. sub basic_opac_copy_query { - # Pass a defined value for $rec_id OR $iss_id, not both. - my ($self, $rec_id, $iss_id, $copy_limit, $copy_offset, $staff) = @_; + ###################################################################### + # Pass a defined value for either $rec_id OR ($iss_id AND $dist_id), # + # not both. # + ###################################################################### + my ($self,$rec_id,$iss_id,$dist_id,$copy_limit,$copy_offset,$staff) = @_; return { select => { @@ -1999,7 +2002,10 @@ sub basic_opac_copy_query { sitem => { fkey => 'id', field => 'unit', - filter => {issuance => $iss_id} + filter => {issuance => $iss_id}, + join => { + sstr => { } + } } ) : ()), acn => { @@ -2036,7 +2042,8 @@ sub basic_opac_copy_query { '+acp' => { deleted => 'f', ($staff ? () : (opac_visible => 't')) - } + }, + ($dist_id ? ( '+sstr' => { distribution => $dist_id } ) : ()) }, order_by => [ diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Serial.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Serial.pm index 6ccf7d1cf3..ee088bc336 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Serial.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Serial.pm @@ -916,11 +916,13 @@ sub _get_deepest_holding_level { # This is a helper for grouped_holdings_for_summary() later. sub _opac_visible_unit_data { - my ($issuance_id_list, $staff, $e) = @_; + my ($issuance_id_list, $dist_id, $staff, $e) = @_; + + return {} unless @$issuance_id_list; my $rows = $e->json_query( $U->basic_opac_copy_query( - undef, $issuance_id_list, + undef, $issuance_id_list, $dist_id, 1000, 0, # XXX no mechanism for users to page at this level yet $staff ) @@ -1080,6 +1082,7 @@ sub grouped_holdings_for_summary { # Now get the top level of holdings. my $top = $e->json_query({ select => { + sstr => ["distribution"], "smhc_$subfield" => ["value"], ( $subfield eq $deepest_level ? (siss => [qw/id label date_published/]) : () @@ -1127,6 +1130,10 @@ sub grouped_holdings_for_summary { pop @$top; } + # Distribution is the same for all rows anyway, but we may need it for a + # copy query later. + my $dist_id = @$top ? $top->[0]->{distribution} : undef; + # This will help us avoid certain repetitive calculations. Examine # _label_holding_level() to see what I mean. my $mfhd_cache = {}; @@ -1136,7 +1143,7 @@ sub grouped_holdings_for_summary { if ($with_units and $subfield eq $deepest_level) { $unit_data = _opac_visible_unit_data( - [map { $_->{id} } @$top], $with_units > 1, $e + [map { $_->{id} } @$top], $dist_id, $with_units > 1, $e ); return $unit_data if defined $U->event_code($unit_data); } @@ -1231,7 +1238,7 @@ sub grouped_holdings_for_summary { # Prepare related unit data if appropriate. if ($with_units and $subfield eq $deepest_level) { $unit_data = _opac_visible_unit_data( - [map { $_->{id} } @$level], $with_units > 1, $e + [map { $_->{id} } @$level], $dist_id, $with_units > 1, $e ); return $unit_data if defined $U->event_code($unit_data); } 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 68739d6d62..d2f1eb276e 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm @@ -132,7 +132,7 @@ sub mk_copy_query { my $copy_offset = shift; my $query = $U->basic_opac_copy_query( - $rec_id, undef, $copy_limit, $copy_offset, $self->ctx->{is_staff} + $rec_id, undef, undef, $copy_limit, $copy_offset, $self->ctx->{is_staff} ); # XXX In the future, $sort_org should be understood to be an abstration @@ -218,7 +218,8 @@ sub load_serial_holding_summaries { "open-ils.serial.holdings.grouped_by_summary", $summary_type, $summary_id, $expand_path, $expand_limit, $expand_offsets, - $auto_expand_first + $auto_expand_first, + 1 + ($self->ctx->{is_staff} ? 1 : 0) )->gather(1); if ($holdings and ref $holdings eq "ARRAY") { diff --git a/Open-ILS/src/templates/opac/parts/record/copy_table.tt2 b/Open-ILS/src/templates/opac/parts/record/copy_table.tt2 index 8148dd934a..ef48ee5141 100644 --- a/Open-ILS/src/templates/opac/parts/record/copy_table.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/copy_table.tt2 @@ -1,5 +1,19 @@ [%- -FOREACH copy_info IN ctx.copies; + +# If being used in serial mode, flatten list of units so that they can be +# used like one long list of copies without changing so much code below. +IF serial_holdings; + copies = []; + FOREACH h IN serial_holdings; + units = h.units.slice(0); # copy + FOREACH unit IN units; + unit.holding_label = h.label; + END; + copies = copies.merge(units); + END; +END; + +FOREACH copy_info IN copies; IF copy_info.call_number_label != '##URI##'; has_copies = 'true'; END; @@ -10,12 +24,16 @@ FOREACH copy_info IN ctx.copies; LAST; END; END; -%] +-%] [%- IF has_copies; %] + [% IF serial_holdings -%] + + [%- ELSE -%] + [%- END %] [%- IF has_parts == 'true' %] @@ -25,6 +43,8 @@ END; [%- IF ctx.is_staff %] + [%- END %] + [%- IF ctx.is_staff OR serial_holdings %] [%- END %] @@ -33,7 +53,7 @@ END; [%- last_cn = 0; - FOR copy_info IN ctx.copies; + FOR copy_info IN copies; callnum = copy_info.call_number_label; NEXT IF callnum == '##URI##'; @@ -48,12 +68,15 @@ END; END; -%] - + [%- ELSE %] + [% END %] [%- IF has_parts == 'true' %] @@ -73,13 +96,18 @@ END; ctx.parse_datetime(copy_info.create_date), DATE_FORMAT ) %] + [% END # is_staff %] + [% IF ctx.is_staff OR serial_holdings %] @@ -105,7 +145,7 @@ END; [%- END %] - [%- IF ctx.copy_offset > 0; + [%- IF ctx.copy_offset > 0 AND NOT serial_holdings; new_offset = ctx.copy_offset - ctx.copy_limit; IF new_offset < 0; new_offset = 0; END %] [%- END %] - [%- IF ctx.copies.size >= ctx.copy_limit %] + [%- IF copies.size >= ctx.copy_limit AND NOT serial_holdings %] [%- END %] + [% IF NOT serial_holdings -%] + [%- END %]
[% l("Holding Label") %][% l("Location") %][% l("Call Number") %][% l("Part") %][% l("Age Hold Protection") %] [% l("Create Date") %][% l("Holdable?") %][% l("Status") %]
+ [%- IF serial_holdings %] + [%- copy_info.holding_label | html; -%] + [%- org_name = ctx.get_aou(copy_info.circ_lib).name; org_name | html -%] - [% callnum | html %] [% IF ctx.get_org_setting(CGI.param('loc') OR ctx.aou_tree.id, 'sms.enable') == 1 %](Text)[% END %][% copy_info.part_label | html %][% # Show copy/volume hold links to staff (without # checking whether they have permissions to do those). - overall_holdable = (copy_info.holdable == 't' AND + overall_holdable = ( + copy_info.holdable == 't' AND copy_info.location_holdable == 't' AND copy_info.status_holdable == 't'); IF overall_holdable; - l("Place on"); %] + l("Place on"); + IF ctx.is_staff; + %] [% l("copy") %] [%- IF copy_info.call_number != last_cn; @@ -88,6 +116,18 @@ END; [% l("volume") %] [%- END; + IF serial_holdings; + l(" / "); + END; + END; + IF serial_holdings; + %] + [% l("holding") %][%- + END; ELSE; l("No"); END %]
@@ -113,17 +153,18 @@ END; l('Previous [_1]', ctx.copy_offset - new_offset) %] [% l('Next [_1]', ctx.copy_limit) %] »
[%- more_copies_limit = 50 %] [%# TODO: config %] - [%- IF ctx.copy_limit != more_copies_limit AND ctx.copies.size >= ctx.copy_limit %] + [%- IF ctx.copy_limit != more_copies_limit AND copies.size >= ctx.copy_limit %]
[% l('Show more copies') %] @@ -136,6 +177,7 @@ END; [%- END %]
[% END; %] diff --git a/Open-ILS/src/templates/opac/parts/record/issues-db.tt2 b/Open-ILS/src/templates/opac/parts/record/issues-db.tt2 new file mode 100644 index 0000000000..5bee35acd0 --- /dev/null +++ b/Open-ILS/src/templates/opac/parts/record/issues-db.tt2 @@ -0,0 +1,143 @@ +[%- +expand_path = CGI.param('sepath') || []; +seoffset_list = CGI.param('seoffset') || []; +IF expand_path.size == 0 AND seoffset_list.size == 0; + seoffset_list = [0,0]; # compensate for $auto_expand_first; see ML +END; + +selimit = CGI.param('selimit') || 10; +ght_sepath = []; +ght_depth = 0; + +VIEW grouped_holding_tree; + BLOCK list; + '
'; + prev_seoffset_list = seoffset_list.slice(0, ght_depth + 1); + next_seoffset_list = seoffset_list.slice(0, ght_depth + 1); + + prev_seoffset_list.$ght_depth = prev_seoffset_list.$ght_depth - selimit; + IF prev_seoffset_list.$ght_depth < 0; + prev_seoffset_list.$ght_depth = 0; + END; + + next_seoffset_list.$ght_depth = next_seoffset_list.$ght_depth + selimit; + IF item.0.units.size; + INCLUDE "opac/parts/record/copy_table.tt2" serial_holdings=item; + "
"; + "
"; + ELSE; + FOREACH node IN item; + IF NOT node.label; + has_more = 1; + LAST; + END; + + IF node.value; + ght_sepath.push(node.value); + all_balls = []; + FOREACH i IN [-1 .. ght_depth]; # aka [0 .. ght_depth+1] + all_balls.push(0); + END; + + expand_link = mkurl( + '', {'sepath' => ght_sepath, 'seoffset' => all_balls}, + 0, 'issues' + ); + + collapse_sepath = ght_sepath.slice(0, -2); + IF collapse_sepath.size == 0; + collapse_clear_params = ['sepath']; + ELSE; + collapse_clear_params = 0; + END; + + collapse_link = mkurl( + '', { + 'sepath' => collapse_sepath, + 'seoffset' => all_balls.slice(0, -2) + }, collapse_clear_params, 'issues' + ); + + ""; + + IF node.children.size; + ght_depth = ght_depth + 1; + view.print(node.children); + ght_depth = ght_depth - 1; + END; + + waste = ght_sepath.pop; + ELSE; + "
"; node.label; "
"; + # XXX Hold placement link here? Maybe not if no units. + END; + END; + IF seoffset_list.$ght_depth > 0; + ''; l('Previous'); ''; + END; + IF has_more; + ''; l('Next'); ''; + END; + ''; + END; + END; +END; + +VIEW holding_summary_tree; + BLOCK hash; + '
'; + ctx.get_aou(item.org_unit).name; "
"; + FOREACH summary IN item.holding_summaries; + IF summary.holdings; + link = mkurl( + '', {}, + ['sid','stype','selimit','sepath','seoffset'], 'issues' + ); + link_title = l('Collapse'); + ELSE; + link = mkurl( + '', {sid => summary.id, stype => summary.summary_type}, + ['selimit','sepath','seoffset'], 'issues' + ); + link_title = l('Expand'); + END; + ''; + summary.generated_coverage.join(", "); + '
'; + IF summary.holdings; + grouped_holding_tree.print(summary.holdings); + END; + END; + FOREACH child IN item.children; + view.print(child); + END; + '
'; + END; +END %] +
+ [% holding_summary_tree.print(ctx.holding_summary_tree) %] +
+
+ [% slimit = CGI.param('slimit') || 10; + soffset = CGI.param('soffset') || 0; + soffset_prev = soffset - slimit; + IF soffset_prev < 0; soffset_prev = 0; END; + soffset_next = soffset + slimit; + %] + [% IF soffset > 0 %] + soffset_next}, ['sid','stype','sepath','selimit','seoffset'], 'issues') %]">[% l('Next') %] + [% END %] +
diff --git a/Open-ILS/src/templates/opac/parts/record/issues-mfhd.tt2 b/Open-ILS/src/templates/opac/parts/record/issues-mfhd.tt2 new file mode 100644 index 0000000000..15b9ab9d3c --- /dev/null +++ b/Open-ILS/src/templates/opac/parts/record/issues-mfhd.tt2 @@ -0,0 +1,40 @@ +[% IF ctx.mfhd_summaries.size; %] +
+ +[% + mfhd = { + basic_holdings = l('Volumes'), + basic_holdings_add = l('Additional Volume Information'), + supplement_holdings = l('Supplements'), + supplement_holdings_add = l('Additional Supplement Information'), + index_holdings = l('Indexes'), + index_holdings_add = l('Additional Index Information'), + online = l('Online'), + missing = l('Missing'), + incomplete = l('Incomplete'), + }; + + FOREACH serial IN ctx.mfhd_summaries; +%] + + + +[% + FOREACH type IN mfhd.keys; + NEXT UNLESS serial.$type.size; +%] + + + + + [% END %] + + + + [% END %] +
[% l('Holdings summary ([_1])', serial.location) %]
[% mfhd.$type %][% + FOR thing IN serial.$type; + thing.join(", "); + END %]
+
+[% END %] diff --git a/Open-ILS/src/templates/opac/parts/record/issues.tt2 b/Open-ILS/src/templates/opac/parts/record/issues.tt2 index 491c9c0211..6c2241e988 100644 --- a/Open-ILS/src/templates/opac/parts/record/issues.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/issues.tt2 @@ -1,179 +1,4 @@ -
[% -expand_path = CGI.param('sepath') || []; -seoffset_list = CGI.param('seoffset') || []; -IF expand_path.size == 0 AND seoffset_list.size == 0; - seoffset_list = [0,0]; # compensate for $auto_expand_first; see ML -END; - -selimit = CGI.param('selimit') || 10; -ght_sepath = []; -ght_depth = 0; - -VIEW grouped_holding_tree; - BLOCK list; - '
    '; - prev_seoffset_list = seoffset_list.slice(0, ght_depth + 1); - next_seoffset_list = seoffset_list.slice(0, ght_depth + 1); - - prev_seoffset_list.$ght_depth = prev_seoffset_list.$ght_depth - selimit; - IF prev_seoffset_list.$ght_depth < 0; - prev_seoffset_list.$ght_depth = 0; - END; - - next_seoffset_list.$ght_depth = next_seoffset_list.$ght_depth + selimit; - FOREACH node IN item; - IF NOT node.label; - has_more = 1; - LAST; - END; - - IF node.value; - ght_sepath.push(node.value); - all_balls = []; - FOREACH i IN [-1 .. ght_depth]; # aka [0 .. ght_depth+1] - all_balls.push(0); - END; - - expand_link = mkurl( - '', {'sepath' => ght_sepath, 'seoffset' => all_balls}, - 0, 'issues' - ); - - collapse_sepath = ght_sepath.slice(0, -2); - IF collapse_sepath.size == 0; - collapse_clear_params = ['sepath']; - ELSE; - collapse_clear_params = 0; - END; - - collapse_link = mkurl( - '', { - 'sepath' => collapse_sepath, - 'seoffset' => all_balls.slice(0, -2) - }, collapse_clear_params, 'issues' - ); - - "
  • "; node.label; "
  • "; - - IF node.children.size; - ght_depth = ght_depth + 1; - view.print(node.children); - ght_depth = ght_depth - 1; - END; - - waste = ght_sepath.pop; - ELSE; - "
  • "; node.label; "
  • "; # XXX hold placement link here - END; - END; - IF seoffset_list.$ght_depth > 0; - ''; l('Previous'); ''; - END; - IF has_more; - ''; l('Next'); ''; - END; - '
'; - END; -END; - -VIEW holding_summary_tree; - BLOCK hash; - '
    '; - ''; - ctx.get_aou(item.org_unit).name; - ''; - FOREACH summary IN item.holding_summaries; - IF summary.holdings; - link = mkurl( - '', {}, - ['sid','stype','selimit','sepath','seoffset'], 'issues' - ); - link_title = l('Collapse'); - ELSE; - link = mkurl( - '', {sid => summary.id, stype => summary.summary_type}, - ['selimit','sepath','seoffset'], 'issues' - ); - link_title = l('Expand'); - END; - '
  • '; - summary.generated_coverage.join(", "); - '
  • '; - IF summary.holdings; - grouped_holding_tree.print(summary.holdings); - END; - END; - FOREACH child IN item.children; - view.print(child); - END; - '
'; - END; -END %] -
-[% holding_summary_tree.print(ctx.holding_summary_tree) %] -
-
- [% slimit = CGI.param('slimit') || 10; - soffset = CGI.param('soffset') || 0; - soffset_prev = soffset - slimit; - IF soffset_prev < 0; soffset_prev = 0; END; - soffset_next = soffset + slimit; - %] - [% IF soffset > 0 %] - soffset_next}, ['sid','stype','sepath','selimit','seoffset'], 'issues') %]">[% l('Next') %] - [% END %] -
-[% IF ctx.mfhd_summaries.size; %] -
- -[% - mfhd = { - basic_holdings = l('Volumes'), - basic_holdings_add = l('Additional Volume Information'), - supplement_holdings = l('Supplements'), - supplement_holdings_add = l('Additional Supplement Information'), - index_holdings = l('Indexes'), - index_holdings_add = l('Additional Index Information'), - online = l('Online'), - missing = l('Missing'), - incomplete = l('Incomplete'), - }; - - FOREACH serial IN ctx.mfhd_summaries; -%] - - - -[% - FOREACH type IN mfhd.keys; - NEXT UNLESS serial.$type.size; -%] - - - - - [% END %] - - - - [% END %] -
[% l('Holdings summary ([_1])', serial.location) %]
[% mfhd.$type %][% - FOR thing IN serial.$type; - thing.join(", "); - END %]
-
-[% END %] +
+ [% INCLUDE 'opac/parts/record/issues-db.tt2' %] + [% INCLUDE 'opac/parts/record/issues-mfhd.tt2' %]
diff --git a/Open-ILS/src/templates/opac/parts/record/summary.tt2 b/Open-ILS/src/templates/opac/parts/record/summary.tt2 index f62c5312e7..29f79e83e1 100644 --- a/Open-ILS/src/templates/opac/parts/record/summary.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/summary.tt2 @@ -101,7 +101,7 @@ IF num_uris > 0; ctx.record_hold_count, ctx.copy_summary.0.count) %]

-[%- INCLUDE "opac/parts/record/copy_table.tt2" %] +[%- INCLUDE "opac/parts/record/copy_table.tt2" copies=ctx.copies %]
[%- END %] diff --git a/Open-ILS/web/css/skin/default/opac/style.css b/Open-ILS/web/css/skin/default/opac/style.css index 10dacd9a89..4223e3cc46 100644 --- a/Open-ILS/web/css/skin/default/opac/style.css +++ b/Open-ILS/web/css/skin/default/opac/style.css @@ -1406,3 +1406,5 @@ table.result_holdings_table thead tr { table.result_holdings_table thead tr th { font-weight: bold; } +.rdetail-holding-group { margin-left: 1.5em; } +.rdetail-holding-group span { margin-left: 1.5em; } -- 2.11.0