From 6dd221223f1a1bd4c8b15e0342b66f75ddc32b9d Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 11 Jun 2013 11:31:49 +0200 Subject: [PATCH] Bug 10857: add ability to remove active facets when refining search results When searching (at the OPAC or pro), facets can be enabled but never disabled. So a user is obliged to relaunch the search. This patch adds a new link "[x]" at the right of each selected facet. This link relaunch the search without this facet. Test plan: - Launch a search (OPAC and pro) - Enable some facets - Disable some facets Signed-off-by: sonia bouis Signed-off-by: Katrin Fischer Patches pass all tests and QA script. Nice feature! Tested in Boostrap and Prog, adding end removing multiple facets in different sequences, adding and removing the availability limit. Signed-off-by: Galen Charlton --- catalogue/search.pl | 12 ++++++ .../intranet-tmpl/prog/en/includes/facets.inc | 33 ++++++++++++----- .../prog/en/includes/opac-facets.inc | 37 +++++++++++++------ opac/opac-search.pl | 13 +++++++ 4 files changed, 74 insertions(+), 21 deletions(-) diff --git a/catalogue/search.pl b/catalogue/search.pl index cda5dad7ac..5ad44d5c8a 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -414,6 +414,9 @@ my @operands = map uri_unescape($_), $cgi->param('q'); # limits are use to limit to results to a pre-defined category such as branch or language my @limits = map uri_unescape($_), $cgi->param('limit'); +my @nolimits = map uri_unescape($_), $cgi->param('nolimit'); +my %is_nolimit = map { $_ => 1 } @nolimits; +@limits = grep { not $is_nolimit{$_} } @limits; if($params->{'multibranchlimit'}) { my $multibranch = '('.join( " or ", map { "branch: $_ " } @{ GetBranchesInCategory( $params->{'multibranchlimit'} ) } ).')'; @@ -716,6 +719,15 @@ my $gotopage = $cgi->param('gotoPage'); $template->{'VARS'}->{'gotoPage'} = $gotopage if $gotopage =~ m/^(ISBD|labeledMARC|MARC|more)?detail.pl$/; +my @input_values = map { $_->{input_value} } @limit_inputs; +for my $facet ( @$facets ) { + for my $entry ( @{ $facet->{facets} } ) { + my $index = $entry->{type_link_value}; + my $value = $entry->{facet_link_value}; + $entry->{active} = grep { $_ eq qq{$index:$value} } @input_values; + } +} + $template->param( #classlist => $classlist, total => $total, diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc index 1dfe57a196..e105e32680 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc @@ -21,17 +21,30 @@ [% 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 ) %] -
  • Show more
  • + [% FOREACH facet IN facets_loo.facets %] +
  • + [% SET query_cgi_f = query_cgi | html %] + [% SET limit_cgi_f = limit_cgi | html %] + [% SET url = "/cgi-bin/koha/catalogue/search.pl?" _ query_cgi_f _ limit_cgi_f %] + [% IF ( sort_by ) %] + [% SET url = url _ "&sort_by=" _ sort_by %] + [% END %] + [% IF facet.active %] + [% SET url = url _ "&nolimit=" _ facet.type_link_value _ ":" _ facet.facet_link_value %] + [% facet.facet_label_value %] + [x] + [% ELSE %] + [% SET url = url _ "&limit=" _ facet.type_link_value _ ":" _ facet.facet_link_value %] + [% facet.facet_label_value %] + [% IF ( displayFacetCount ) %] + ([% facet.facet_count %]) [% END %] + [% END %] +
  • + [% END %] + [% IF ( facets_loo.expandable ) %] +
  • Show more
  • + [% END %]
[% END %] [% 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 96446ee4ff..1457e14ccc 100644 --- a/koha-tmpl/opac-tmpl/prog/en/includes/opac-facets.inc +++ b/koha-tmpl/opac-tmpl/prog/en/includes/opac-facets.inc @@ -22,18 +22,33 @@ [% 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 %] -
  • + [% FOREACH facet IN facets_loo.facets %] +
  • + [% SET query_cgi_f = query_cgi | html %] + [% SET limit_cgi_f = limit_cgi | html %] + [% SET url = "/cgi-bin/koha/opac-search.pl?" _ query_cgi_f _ limit_cgi_f %] + [% IF ( sort_by ) %] + [% SET url = url _ "&sort_by=" _ sort_by |html %] + [% END %] + [% IF facet.active %] + [% SET url = url _ "&nolimit=" _ facet.type_link_value _ ":" _ facet.facet_link_value %] + [% facet.facet_label_value %] + [x] + [% ELSE %] + [% SET url = url _ "&limit=" _ facet.type_link_value _ ":" _ facet.facet_link_value %] + [% facet.facet_label_value %] + [% IF ( displayFacetCount ) %] + ([% facet.facet_count %]) [% END %] - [% IF ( facets_loo.expandable ) %] -
  • Show more
  • -[% END %] -
+ [% END %] + + [% END %] + [% IF ( facets_loo.expandable ) %] +
  • Show more +
  • + [% END %] + + [% END %] [% END %] diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 8e46005ead..2fe5303b84 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -403,6 +403,9 @@ if ($operands[0] && !$operands[1]) { # limits are use to limit to results to a pre-defined category such as branch or language my @limits = $cgi->param('limit'); +my @nolimits = $cgi->param('nolimit'); +my %is_nolimit = map { $_ => 1 } @nolimits; +@limits = grep { not $is_nolimit{$_} } @limits; @limits = map { uri_unescape($_) } @limits; if($params->{'multibranchlimit'}) { @@ -842,6 +845,16 @@ for (my $i=0;$i<@servers;$i++) { } #/end of the for loop #$template->param(FEDERATED_RESULTS => \@results_array); +my @input_values = map { $_->{input_value} } @limit_inputs; +for my $facet ( @$facets ) { + for my $entry ( @{ $facet->{facets} } ) { + my $index = $entry->{type_link_value}; + my $value = $entry->{facet_link_value}; + $entry->{active} = grep { $_ eq qq{$index:$value} } @input_values; + } +} + + $template->param( #classlist => $classlist, total => $total, -- 2.39.5