Bug 10588: improve selection of default branch for OPAC popular items pag

In OPAC most popular items page:
With user is logged-in his branch should be selected by default.
When a branch is manually selected and form is submitted, this branch
should be selected in results page.
When looking at HTML, you see that all options are selected in combobox.

This patch corrects by using the hidden input 'do_it' to distinguish
form display and no branch filter selected.

Test plan :
- Make sure there are issues on records created in the past 3 month
- Go to OPAC not logged-in
- Click on "Most popular"
=> You get to page with results, "All libraries" is selected
- Select a branch and submit
=> You get to page with results, the branch is selected [testing opac-topissues.inc from]
- Select a branch and perform a search that does not have results (for example an item type never issued)
=> You get to page without results, the branch is selected [testing opac-topissues.tt form]
- Log-in with a user
- Click on "Most popular"
=> You get to page with results, user's branch is selected
- Select "All libraries" and submit
=> You get to page with results, "All libraries" is selected [testing opac-topissues.inc from]
- Select "All libraries" and perform a search that does not have results (for example an item type never issued)
=> You get to page without results, "All libraries" is selected [testing opac-topissues.tt form]

Signed-off-by: Srdjan <srdjan@catalyst.net.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Works nicely and passes all tests.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 600e953dff)
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
(cherry picked from commit 4afc06d76a)
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
(cherry picked from commit 4afc06d76a)
This commit is contained in:
Fridolyn SOMERS 2013-07-15 12:14:53 +02:00 committed by Bernardo Gonzalez Kriegel
parent b3ba600934
commit 2fc0e258ea
2 changed files with 6 additions and 2 deletions

View File

@ -17,7 +17,7 @@
<select name="branch" id="branch" style="width: 10em;">
<option value="">All libraries</option>
[% FOREACH branchloo IN branchloop %]
[% IF ( branch == branchname ) %]<option value="[% branchloo.value %]" selected="selected">[% ELSE %]<option value="[% branchloo.value %]">[% END %]
[% IF ( branchloo.selected ) %]<option value="[% branchloo.value %]" selected="selected">[% ELSE %]<option value="[% branchloo.value %]">[% END %]
[% branchloo.branchname %]
</option>
[% END %]

View File

@ -59,10 +59,14 @@ my ($template, $borrowernumber, $cookie)
});
my $dbh = C4::Context->dbh;
# Displaying results
my $do_it = $input->param('do_it') || 0; # as form been posted
my $limit = $input->param('limit');
$limit = 10 unless ($limit && $limit =~ /^\d+$/); # control user input for SQL query
$limit = 100 if $limit > 100;
my $branch = $input->param('branch') || '';
if (!$do_it && C4::Context->userenv && C4::Context->userenv->{'branch'} ) {
$branch = C4::Context->userenv->{'branch'}; # select user branch by default
}
my $itemtype = $input->param('itemtype') || '';
my $timeLimit = $input->param('timeLimit') || 3;
my $advanced_search_types = C4::Context->preference('AdvancedSearchTypes');
@ -138,7 +142,7 @@ $template->param(do_it => 1,
results_loop => \@results,
);
$template->param( branchloop => GetBranchesLoop(C4::Context->userenv?C4::Context->userenv->{'branch'}:''));
$template->param( branchloop => GetBranchesLoop($branch));
# the index parameter is different for item-level itemtypes
my $itype_or_itemtype = (C4::Context->preference("item-level_itypes"))?'itype':'itemtype';