Bug 6911: Remember search terms in the log viewer tool

The modules and actions selected by the user are now selected when a
log search is done.
Note that this patch also add the multiple attribute to the actions
select in order to add the ability to select several actions.
The code to do that already existed.

Test plan:
1/ Go on the log viewer tool (tools/viewlog.pl)
2/ Launch a search with modules and actions selected.
3/ Confirm that the values you have selected is still selected after the
search.

Patch works as expected.
Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This commit is contained in:
Jonathan Druart 2015-03-27 10:03:32 +01:00 committed by Tomas Cohen Arazi
parent ae1a75d369
commit b8db092a0a
2 changed files with 41 additions and 28 deletions

View File

@ -67,24 +67,41 @@
<label for="user">Librarian:</label>
<input type="text" name="user" id="user" value="[% user %]" />
</li>
<li>
<label for="modules">Module:</label>
<select name="modules" id="modules" multiple="multiple">
<option value="" selected="selected">All</option>
[% FOREACH modx IN [ 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'CIRCULATION' 'LETTER' 'FINES' 'SYSTEMPREFERENCE' ] %]
<option value="[% modx %]">[% PROCESS translate_log_module module=modx %]</option>
[% END %]
</select>
</li>
<li>
<label for="action">Action:</label>
<select name="action" id="action">
<option value ="">All</option>
[% FOREACH actx IN [ 'ADD' 'DELETE' 'MODIFY' 'ISSUE' 'RETURN' 'CREATE' ] %]
<option value="[% actx %]">[% PROCESS translate_log_action action=actx %]</option>
[% END %]
</select>
</li>
<li>
<label for="modules">Modules:</label>
<select name="modules" id="modules" multiple="multiple">
[% UNLESS modules %]
<option value="" selected="selected">All</option>
[% ELSE %]
<option value="">All</option>
[% END %]
[% FOREACH modx IN [ 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'CIRCULATION' 'LETTER' 'FINES' 'SYSTEMPREFERENCE' ] %]
[% IF modules.grep(modx).size %]
<option value="[% modx %]" selected="selected">[% PROCESS translate_log_module module=modx %]</option>
[% ELSE %]
<option value="[% modx %]">[% PROCESS translate_log_module module=modx %]</option>
[% END %]
[% END %]
</select>
</li>
<li>
<label for="actions">Actions:</label>
<select name="actions" id="actions" multiple="multiple">
[% UNLESS actions %]
<option value="" selected="selected">All</option>
[% ELSE %]
<option value="">All</option>
[% END %]
[% FOREACH actx IN [ 'ADD' 'DELETE' 'MODIFY' 'ISSUE' 'RETURN' 'CREATE' ] %]
[% IF actions.grep(actx).size %]
<option value="[% actx %]" selected="selected">[% PROCESS translate_log_action action=actx %]</option>
[% ELSE %]
<option value="[% actx %]">[% PROCESS translate_log_action action=actx %]</option>
[% END %]
[% END %]
</select>
</li>
<li>
<label for="object">Object: </label>
<input type="text" id="object" name="object" value="[% object %]" />

View File

@ -47,7 +47,7 @@ $debug or $debug = $cgi_debug;
my $do_it = $input->param('do_it');
my @modules = $input->param("modules");
my $user = $input->param("user");
my @action = $input->param("action");
my @actions = $input->param("actions");
my $object = $input->param("object");
my $info = $input->param("info");
my $datefrom = $input->param("from");
@ -126,10 +126,10 @@ $template->param(
if ($do_it) {
my @data;
my ( $results, $modules, $action );
if ( $action[0] ne '' ) { $action = \@action; } # match All means no limit
my ( $results, $modules, $actions );
if ( $actions[0] ne '' ) { $actions = \@actions; } # match All means no limit
if ( $modules[0] ne '' ) { $modules = \@modules; } # match All means no limit
$results = GetLogs( $datefrom, $dateto, $user, $modules, $action, $object, $info );
$results = GetLogs( $datefrom, $dateto, $user, $modules, $actions, $object, $info );
@data = @$results;
foreach my $result (@data) {
@ -188,16 +188,12 @@ if ($do_it) {
dateto => $dateto,
user => $user,
object => $object,
action => \@action,
info => $info,
src => $src,
modules => \@modules,
actions => \@actions,
);
# Used modules
foreach my $module (@modules) {
$template->param( $module => 1 );
}
output_html_with_http_headers $input, $cookie, $template->output;
}
else {