Bug 28175: (follow-up) Preselect correct category after search

This patch modifies the script and template so that if the user submits
a search by category, that category will be preselected on the search
results page.

Also added is an empty "Choose" option so that a search category isn't
selected by default.

To test, apply the patch and view the uploads page.

 - In the category search form, a "Choose" option should be selected.
   Submitting the form without selecting a category should not work.
 - Search using one of your existing categories. On the search results
   page the category you selected should remain selected.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Owen Leonard 2021-06-22 19:09:23 +00:00 committed by Jonathan Druart
parent e078875cbc
commit 2f6877d616
2 changed files with 13 additions and 7 deletions

View File

@ -120,10 +120,15 @@
<ol>
<li>
<label for="browsecategory">Category: </label>
<select id="browsecategory" name="browsecategory">
[% FOREACH cat IN uploadcategories %]
<option value="[% cat.code | html %]">[% cat.name | html %]</option>
[% END %]
<select id="browsecategory" name="browsecategory" required="required">
<option value="">Choose</option>
[% FOREACH cat IN uploadcategories %]
[% IF cat.code == browsecategory %]
<option value="[% cat.code | html %]" selected="selected">[% cat.name | html %]</option>
[% ELSE -%]
<option value="[% cat.code | html %]">[% cat.name | html %]</option>
[% END %]
[% END %]
</select>
</li>
</ol>

View File

@ -69,9 +69,10 @@ if ( $op eq 'new' ) {
}
$template->param(
mode => 'report',
msg => $msg,
uploads => $uploads,
mode => 'report',
msg => $msg,
uploads => $uploads,
browsecategory => $browsecategory,
);
output_html_with_http_headers $input, $cookie, $template->output;