From 2f036053ce8f67771349952e30d1254b4565914c Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 12 Oct 2021 10:31:47 +0100 Subject: [PATCH] Bug 11175: (QA follow-up) Display components tab if no holdings Content-Type: text/plain; charset=utf-8 This patch updates the default details tab selection to components for the case when there are no holdings attached to the record and there is no HTML5 content to display in preference. Bug 11175: (QA follow-up) OPAC - Display components tab if no holdings As for the staff client, this selects the default tab to be 'Components' for the case where no holdings are found. Signed-off-by: Marcel de Rooy --- .../prog/en/modules/catalogue/detail.tt | 13 +++++++++---- .../opac-tmpl/bootstrap/en/modules/opac-detail.tt | 10 +++++++++- opac/opac-detail.pl | 4 +++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 6cd934f77a..896cd88e85 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -274,7 +274,7 @@ [% END %] [% IF ( MARCNOTES || notes ) %]
  • Descriptions ([% ( MARCNOTES.size || 1 ) | html %])
  • [% END %] -[% IF ( ComponentParts ) %]
  • Components ([% ( ComponentParts.size || 1 ) %])
  • [% END %] +[% IF ( ComponentParts ) %]
  • Components ([% ( ComponentParts.size ) %])
  • [% END %] [% IF ( subscriptionsnumber ) %]
  • Subscriptions
  • [% END %] [% IF Koha.Preference('AcquisitionDetails') %]
  • Acquisition details
  • [% END %] [% IF suggestions.count %]
  • Suggestion details
  • [% END %] @@ -1265,9 +1265,14 @@ Note that permanent location is a code, and location may be an authval. $(document).ready(function() { $('#bibliodetails').tabs(); - [% IF count == 0 and ( Koha.Preference('HTML5MediaEnabled') == 'staff' or Koha.Preference('HTML5MediaEnabled') == 'both' ) %] - $('#bibliodetails').tabs("option", "active", $('#media_tab').index() ); - [% END %] + // Pick details tab to display by default + [% IF count == 0 %] + [% IF ( Koha.Preference('HTML5MediaEnabled') == 'staff' or Koha.Preference('HTML5MediaEnabled') == 'both' ) && HTML5MediaSets.size %] + $('#bibliodetails').tabs("option", "active", $('#media_tab').index() ); + [% ELSIF ComponentParts %] + $('#bibliodetails').tabs("option", "active", $('#components_tab').index() ); + [% END %] + [% END %] $('#search-form').focus(); $('.thumbnails > li > .remove').click(function() { var result = confirm(_("Are you sure you want to delete this cover image?")); diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index 9630e21f4a..39a9889033 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -378,7 +378,15 @@ [% IF SYNDETICS_SUMMARY %][% SET title_notes_count = title_notes_count + 1 %][% END %]
  • Title notes ( [% title_notes_count | html %] )
  • [% END %] - [% IF ( ComponentParts ) %]
  • Components ([% ( ComponentParts.size || 1 ) %])
  • [% END %] + [% IF ( ComponentParts ) %] + [% IF defaulttab == 'components' %] +
  • + [% ELSE %] +
  • + [% END %] + Components ([% ( ComponentParts.size || 1 ) %]) +
  • + [% END %] [% IF ( SYNDETICS_TOC ) %]
  • TOC
  • [% END %] diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 43d675222d..c8903411cf 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -659,9 +659,9 @@ my $max_items_to_display = C4::Context->preference('OpacMaxItemsToDisplay') // 5 # Get component parts details my $showcomp = C4::Context->preference('ShowComponentRecords'); +my $parts; if ( $showcomp eq 'both' || $showcomp eq 'opac' ) { if ( my $components = $biblio->get_marc_components(300) ) { - my $parts; for my $part ( @{$components} ) { $part = C4::Search::new_record_from_zebra( 'biblioserver', $part ); @@ -1207,6 +1207,8 @@ my $defaulttab = ? 'serialcollection' : $opac_serial_default eq 'holdings' && scalar (@itemloop) > 0 ? 'holdings' : + ( $showcomp eq 'both' || $showcomp eq 'opac' ) && scalar (@itemloop) == 0 && $parts + ? 'components' : scalar (@itemloop) == 0 ? 'media' : $subscriptionsnumber -- 2.20.1