From 33bba375dba70560053392efdee32beee9e9b777 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi <tomascohen@gmail.com> Date: Sun, 24 Aug 2014 02:11:50 -0300 Subject: [PATCH] [SIGNED-OFF] Bug 11672: Untranslatable dropdown on Guided Reports and dictionary Content-Type: text/plain; charset="utf-8" This patch removes hardcoded descriptions and sets them in the templates using the variable content as id. To test, create a new guided report and verify the 'module to report on' dropdown shows as usual [1]. Functionality shouldn't get changed. The patch also changes the dictionary pages where 'area' should be displayed/selectable with the same strings as the guided reports. Try all the possible disctionary pages. The last page when creating a dictionary now shows the 'area description' instead of the code. The same happens to the dictionary list once you have dictionaries saved. [1] The following texts get changed: Catalogue -> Catalog Acquisition -> Acquisitions Signed-off-by: Owen Leonard <oleonard@myacpl.org> --- C4/Reports/Guided.pm | 6 +- .../prog/en/modules/reports/dictionary.tt | 129 +++++++++++--------- .../en/modules/reports/guided_reports_start.tt | 25 +++- reports/dictionary.pl | 17 +-- reports/guided_reports.pl | 7 +- 5 files changed, 109 insertions(+), 75 deletions(-) diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm index a4c7c01..a8eb1d0 100644 --- a/C4/Reports/Guided.pm +++ b/C4/Reports/Guided.pm @@ -83,8 +83,12 @@ my $AREA_NAME_SQL_SNIPPET = "CASE report_area " . join (" ", map "WHEN '$_->[0]' THEN '$_->[1]'", @REPORT_AREA) . " END AS areaname"; + sub get_report_areas { - return \@REPORT_AREA + + my $report_areas = [ 'CIRC', 'CAT', 'PAT', 'ACQ', 'ACC' ]; + + return $report_areas; } my %table_areas = ( diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/dictionary.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/dictionary.tt index ee40dcf..7ca9c82 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/dictionary.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/dictionary.tt @@ -8,6 +8,16 @@ [% INCLUDE 'header.inc' %] [% INCLUDE 'circ-search.inc' %] +[%- BLOCK area_name -%] + [%- SWITCH area -%] + [%- CASE 'CIRC' -%]Circulation + [%- CASE 'CAT' -%]Catalog + [%- CASE 'PAT' -%]Patrons + [%- CASE 'ACQ' -%]Acquisitions + [%- CASE 'ACC' -%]Accounts + [%- END -%] +[%- END -%] + <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a> › <a href="/cgi-bin/koha/reports/guided_reports.pl">Guided reports wizard</a> [% IF ( new_dictionary ) %] › <a href="/cgi-bin/koha/reports/dictionary.pl">Dictionary</a> › <strong>Name the new definition</strong> [% ELSIF ( step_2 ) %] › <a href="/cgi-bin/koha/reports/dictionary.pl">Dictionary</a> › <strong>Step 2: Choose the area </strong> @@ -36,21 +46,22 @@ <h2>Current terms</h2> <form action="/cgi-bin/koha/reports/dictionary.pl" method="post"> <input type="hidden" name="phase" value="View Dictionary" /> - [% IF ( areas ) %] - Filter by area <select name="area"> - <option value="">All</option> - [% FOREACH area IN areas %] - [% IF ( area.selected ) %] - <option value="[% area.id %]" selected="selected" >[% area.name %]</option> - [% ELSE %] - <option value="[% area.id %]">[% area.name %]</option> - [% END %] - [% END %] - </select> - <input name="submit" value="Go" type="submit" /> - </form> - <br /> - [% END %] + [% IF ( areas ) %] + Filter by area + <select name="area"> + <option value="">All</option> + [% FOREACH area IN areas %] + [%- IF ( area.selected ) -%] + <option value="[% area.id %]" selected="selected">[%- PROCESS area_name area=area.id -%]</option> + [%- ELSE -%] + <option value="[% area.id %]">[%- PROCESS area_name area=area.id -%]</option> + [%- END -%] + [% END %] + </select> + <input name="submit" value="Go" type="submit" /> + [% END %] + </form> + <br /> <table border="1" cellspacing="0" cellpadding="5"> <tr> <th>Name</th> @@ -99,24 +110,27 @@ </form> [% END %] -[% IF ( step_2 ) %] +[%- IF ( step_2 ) -%] <h3>Add new definition</h3> <form action="/cgi-bin/koha/reports/dictionary.pl" method="post"> -<fieldset class="rows"> -<legend>Step 2 of 5: Choose the area</legend> -<ol><li><input type="hidden" name="phase" value="New Term step 3" /> -<input type="hidden" name="definition_name" value="[% definition_name %]" /> -<input type="hidden" name="definition_description" value="[% definition_description %]" /> -<label for="area">Select table </label><select name="area" id="area"> -[% FOREACH area IN areas %] -<option value="[% area.id %]">[% area.name %]</option> -[% END %] -</select></li> -</ol> -</fieldset> -<fieldset class="action"><input name="submit" value="Next" type="submit" /></fieldset> + <fieldset class="rows"> + <legend>Step 2 of 5: Choose the area</legend> + <ol> + <li> + <input type="hidden" name="phase" value="New Term step 3" /> + <input type="hidden" name="definition_name" value="[% definition_name %]" /> + <input type="hidden" name="definition_description" value="[% definition_description %]" /> + <label for="area">Select table </label><select name="area" id="area"> + [%- FOREACH area IN areas -%] + <option value="[%- area.id -%]">[%- PROCESS area_name area=area.id -%]</option> + [%- END -%] + </select> + </li> + </ol> + </fieldset> + <fieldset class="action"><input name="submit" value="Next" type="submit" /></fieldset> </form> -[% END %] +[%- END -%] [% IF ( step_3 ) %] <h3>Add new definition</h3> @@ -227,33 +241,34 @@ <h3>Add new definition</h3> <fieldset class="rows"> -<legend>Step 5 of 5: Confirm details</legend> -<ol><li> -<span class="label">Name:</span> -[% definition_name %] -</li> -<li> -<span class="label">Description:</span> -[% definition_description %] -</li> -<li> -<span class="label">Area:</span> -[% areaname %] -</li> -<li> -<span class="label">Data:</span> -<table> -<tr> -<th>Columns</th> -<th>Values</th> -</tr> -[% FOREACH criteria_loo IN criteria_loop %] -<tr> -<td>[% criteria_loo.name %]</td> -<td>[% criteria_loo.value %]</td> -</tr> -[% END %] -</table></li></ol> </fieldset> + <legend>Step 5 of 5: Confirm details</legend> + <ol> + <li> + <span class="label">Name:</span>[%- definition_name -%] + </li> + <li> + <span class="label">Description:</span>[%- definition_description -%] + </li> + <li> + <span class="label">Area:</span>[%- PROCESS area_name area=area -%] + </li> + <li> + <span class="label">Data:</span> + <table> + <tr> + <th>Columns</th> + <th>Values</th> + </tr> + [%- FOREACH criteria_loo IN criteria_loop -%] + <tr> + <td>[%- criteria_loo.name -%]</td> + <td>[%- criteria_loo.value -%]</td> + </tr> + [%- END -%] + </table> + </li> + </ol> +</fieldset> <fieldset class="action"><input type="hidden" name="sql" value="[% query %]" /> <input type="hidden" name="phase" value="New Term step 6" /> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt index eebf086..948783e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt @@ -1,4 +1,15 @@ [% USE KohaDates %] + +[%- BLOCK area_name -%] + [%- SWITCH area -%] + [%- CASE 'CIRC' -%]Circulation + [%- CASE 'CAT' -%]Catalog + [%- CASE 'PAT' -%]Patrons + [%- CASE 'ACQ' -%]Acquisitions + [%- CASE 'ACC' -%]Accounts + [%- END -%] +[%- END -%] + [% INCLUDE 'doc-head-open.inc' %] <title>Koha › Reports › Guided reports wizard [% IF ( saved1 ) %]› Saved reports @@ -401,11 +412,15 @@ canned reports and writing custom SQL reports.</p> <form action="/cgi-bin/koha/reports/guided_reports.pl"> <fieldset class="rows"> <legend>Step 1 of 6: Choose a module to report on,[% IF (usecache) %] Set cache expiry, [% END %] and Choose report visibility </legend> -<ol><li><label for="area">Choose: </label><select name="area" id="area"> -[% FOREACH area IN areas %] -<option value="[% area.id %]">[% area.name %]</option> -[% END %] -</select></li> +<ol> + <li> + <label for="area">Choose: </label> + <select name="area" id="area"> + [%- FOREACH area IN areas -%] + <option value="[% area %]">[%- PROCESS area_name area=area -%]</option> + [%- END -%] + </select> + </li> [% IF (public) %] <li><label for="public">Report is public:</label><select id="public" name="public"> <option value="0">No (default)</option> <option value="1" selected="selected">Yes</option> </select></li> [% ELSE %] diff --git a/reports/dictionary.pl b/reports/dictionary.pl index 0ab6f24..f3e08d0 100755 --- a/reports/dictionary.pl +++ b/reports/dictionary.pl @@ -55,7 +55,7 @@ if ($phase eq 'View Dictionary'){ # view the dictionary we use to set up abstract variables such as all borrowers over fifty who live in a certain town my $definitions = get_from_dictionary($area); $template->param( - 'areas'=> areas(), + 'areas' => areas( $area ), 'start_dictionary' => 1, 'definitions' => $definitions, ); @@ -70,7 +70,7 @@ elsif ( $phase eq 'New Term step 2' ) { # Choosing the area $template->param( 'step_2' => 1, - 'areas' => areas(), + 'areas' => areas( $area ), 'definition_name' => $definition_name, 'definition_description' => $definition_description, ); @@ -172,11 +172,9 @@ elsif ( $phase eq 'New Term step 5' ) { $query_criteria .= " AND $crit <= '$value'"; } } - my %report_areas = map @$_, get_report_areas(); $template->param( 'step_5' => 1, 'area' => $area, - 'areaname' => $report_areas{$area}, 'definition_name' => $definition_name, 'definition_description' => $definition_description, 'query' => $query_criteria, @@ -208,14 +206,17 @@ if (!$no_html){ } sub areas { + + my $selected = shift; + my $areas = get_report_areas(); my @a; - foreach (@$areas) { + foreach my $area ( @$areas ) { push @a, { - id => $_->[0], - name => $_->[1], - selected => ($_->[0] eq $area), + id => $area, + selected => ( $area eq $selected ) }; } + return \@a; } diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl index ad72b44..9fe7387 100755 --- a/reports/guided_reports.pl +++ b/reports/guided_reports.pl @@ -87,12 +87,11 @@ if ( !$phase ) { elsif ( $phase eq 'Build new' ) { # build a new report $template->param( 'build1' => 1 ); - my $areas = get_report_areas(); $template->param( - 'areas' => [map { id => $_->[0], name => $_->[1] }, @$areas], - 'usecache' => $usecache, + 'areas' => get_report_areas(), + 'usecache' => $usecache, 'cache_expiry' => 300, - 'public' => '0', + 'public' => '0', ); } elsif ( $phase eq 'Use saved' ) { -- 1.7.9.5