From 304247d326f6de073364098850dcd091985f8315 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 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 Signed-off-by: Jonathan Druart --- .../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 8b3c23aa76..e7f928afe4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -269,7 +269,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 %] @@ -1258,9 +1258,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 b724811440..e5ba19d242 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -402,7 +402,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.39.5