From 47d87d29447f49f492134e05a5024f395e41a631 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 3 Dec 2013 14:13:24 -0500 Subject: [PATCH] [PASSED QA] Bug 11334 - Add facet for home library The current "Library" facet is somewhat ambiguous for Koha installations with multiple libraries. It refers to the holdingbranch, but does not explicitly state this. It would be beneficial to allow the administrator to choose to show facets for the holding library, home library, or both. In addition, the facets should be more explicitly labeled. Test plan: 1) Apply this patch 2) Check that the facets label "Libraries" now reads "Holding libraries" 3) Update the system preference DisplayLibraryFacets to "home library" 4) Check that the facet now reads "Home libraries" 5) Update the preference again to "both home and holding library" 6) Check that both the facets for home and holding library are now displayed. Signed-off-by: Jen DeMuth Signed-off-by: Katrin Fischer Passes all tests and QA script. Changes apply to both prog and bootstrap OPAC and staff client. --- C4/Koha.pm | 74 +++++++++++++++++----- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 18 ++++++ .../intranet-tmpl/prog/en/includes/facets.inc | 3 +- .../en/modules/admin/preferences/searching.pref | 8 +++ .../bootstrap/en/includes/opac-facets.inc | 3 +- .../opac-tmpl/prog/en/includes/opac-facets.inc | 3 +- 7 files changed, 91 insertions(+), 19 deletions(-) diff --git a/C4/Koha.pm b/C4/Koha.pm index 4202957..b21325e 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -716,15 +716,36 @@ sub getFacets { } ]; - my $library_facet; - unless ( C4::Context->preference("singleBranchMode") || GetBranchesCount() == 1 ) { - $library_facet = { - idx => 'branch', - label => 'Libraries', - tags => [ qw/ 995b / ], - }; + unless ( C4::Context->preference("singleBranchMode") + || GetBranchesCount() == 1 ) + { + my $DisplayLibraryFacets = C4::Context->preference('DisplayLibraryFacets'); + if ( $DisplayLibraryFacets eq 'both' + || $DisplayLibraryFacets eq 'holding' ) + { + push( + @$facets, + { + idx => 'holdingbranch', + label => 'HoldingLibrary', + tags => [qw / 995b /], + } + ); + } + + if ( $DisplayLibraryFacets eq 'both' + || $DisplayLibraryFacets eq 'home' ) + { + push( + @$facets, + { + idx => 'homebranch', + label => 'HomeLibrary', + tags => [qw / 995a /], + } + ); + } } - push( @$facets, $library_facet ); } else { $facets = [ @@ -777,15 +798,36 @@ sub getFacets { }, ]; - my $library_facet; - unless ( C4::Context->preference("singleBranchMode") || GetBranchesCount() == 1 ) { - $library_facet = { - idx => 'branch', - label => 'Libraries', - tags => [ qw / 952b / ], - }; + unless ( C4::Context->preference("singleBranchMode") + || GetBranchesCount() == 1 ) + { + my $DisplayLibraryFacets = C4::Context->preference('DisplayLibraryFacets'); + if ( $DisplayLibraryFacets eq 'both' + || $DisplayLibraryFacets eq 'holding' ) + { + push( + @$facets, + { + idx => 'holdingbranch', + label => 'HoldingLibrary', + tags => [qw / 952b /], + } + ); + } + + if ( $DisplayLibraryFacets eq 'both' + || $DisplayLibraryFacets eq 'home' ) + { + push( + @$facets, + { + idx => 'homebranch', + label => 'HomeLibrary', + tags => [qw / 952a /], + } + ); + } } - push( @$facets, $library_facet ); } return $facets; } diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 0de3ac7..49a1467 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -97,6 +97,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('DisplayClearScreenButton','0','','If set to ON, a clear screen button will appear on the circulation page.','YesNo'), ('displayFacetCount','0',NULL,NULL,'YesNo'), ('DisplayIconsXSLT','1','','If ON, displays the format, audience, and material type icons in XSLT MARC21 results and detail pages.','YesNo'), +('DisplayLibraryFacets', 'holdingbranch', 'home|holding|both', 'Defines which library facets to display.', 'Choice'), ('DisplayMultiPlaceHold','1','','Display the ability to place multiple holds or not','YesNo'), ('DisplayOPACiconsXSLT','1','','If ON, displays the format, audience, and material type icons in XSLT MARC21 results and detail pages in the OPAC.','YesNo'), ('dontmerge','1',NULL,'If ON, modifying an authority record will not update all associated bibliographic records immediately, ask your system administrator to enable the merge_authorities.pl cron job','YesNo'), diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 80ab210..e099314 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7912,6 +7912,24 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = '3.15.00.XXX'; +if ( CheckVersion($DBversion) ) { + $dbh->do(q{ + INSERT INTO systempreferences ( + variable, + value, + options, + explanation, + type + ) + VALUES ( + 'DisplayLibraryFacets', 'holdingbranch', 'home|holding|both', 'Defines which library facets to display.', 'Choice' + ); + }); + print "Upgrade to $DBversion done (Bug 11334 - Add facet for home library)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc index 765bf01..2b19dd6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc @@ -17,7 +17,8 @@ [% IF ( facets_loo.type_label_Places ) %]Places[% END %] [% IF ( facets_loo.type_label_Series ) %]Series[% END %] [% IF ( facets_loo.type_label_ItemTypes ) %]Item types[% END %] -[% IF ( facets_loo.type_label_Libraries ) %]Libraries[% END %] +[% IF ( facets_loo.type_label_HomeLibrary ) %]Home libraries[% END %] +[% IF ( facets_loo.type_label_HoldingLibrary ) %]Holding libraries[% END %] [% IF ( facets_loo.type_label_Location ) %]Locations[% END %]
    [% FOREACH facet IN facets_loo.facets %]
  • [% facet.facet_label_value %] [% IF ( displayFacetCount ) %]([% facet.facet_count %])[% END %]
  • [% END %][% IF ( facets_loo.expandable ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref index 29da64e..d373171 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref @@ -172,6 +172,14 @@ Searching: class: integer - results per page in the OPAC. - + - "Show facets for" + - pref: DisplayLibraryFacets + type: choice + choices: + home: "home library" + holding: "holding library" + both: "both home and holding library" + - - pref: OPACItemsResultsDisplay type: boolean choices: diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc index 5669ce1..0448a9a 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc @@ -25,7 +25,8 @@ [% IF ( facets_loo.type_label_Series ) %]Series[% END %] [% IF ( facets_loo.type_label_ItemTypes ) %]Item types[% END %] [% UNLESS ( singleBranchMode ) %] - [% IF ( facets_loo.type_label_Libraries ) %]Libraries[% END %] + [% IF ( facets_loo.type_label_HomeLibrary ) %]Home libraries[% END %] + [% IF ( facets_loo.type_label_HoldingLibrary ) %]Holding libraries[% END %] [% END %] [% IF ( facets_loo.type_label_Location ) %]Locations[% END %]
      diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/opac-facets.inc b/koha-tmpl/opac-tmpl/prog/en/includes/opac-facets.inc index aae5d71..cc650d0 100644 --- a/koha-tmpl/opac-tmpl/prog/en/includes/opac-facets.inc +++ b/koha-tmpl/opac-tmpl/prog/en/includes/opac-facets.inc @@ -17,7 +17,8 @@ [% IF ( facets_loo.type_label_Series ) %]Series[% END %] [% IF ( facets_loo.type_label_ItemTypes ) %]Item types[% END %] [% UNLESS ( singleBranchMode ) %] -[% IF ( facets_loo.type_label_Libraries ) %]Libraries[% END %] + [% IF ( facets_loo.type_label_HomeLibrary ) %]Home libraries[% END %] + [% IF ( facets_loo.type_label_HoldingLibrary ) %]Holding libraries[% END %] [% END %] [% IF ( facets_loo.type_label_Location ) %]Locations[% END %]
        -- 1.8.3.2