Bug 11672: Untranslatable dropdown on Guided Reports and dictionary
authorTomas Cohen Arazi <tomascohen@gmail.com>
Sun, 24 Aug 2014 05:11:50 +0000 (02:11 -0300)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Tue, 23 Sep 2014 18:32:21 +0000 (15:32 -0300)
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>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
C4/Reports/Guided.pm
koha-tmpl/intranet-tmpl/prog/en/modules/reports/dictionary.tt
koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt
reports/dictionary.pl
reports/guided_reports.pl

index a4c7c01..a8eb1d0 100644 (file)
@@ -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 = (
index ee40dcf..7ca9c82 100644 (file)
@@ -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> &rsaquo; <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a> &rsaquo; <a href="/cgi-bin/koha/reports/guided_reports.pl">Guided reports wizard</a>
 [% IF ( new_dictionary ) %] &rsaquo; <a href="/cgi-bin/koha/reports/dictionary.pl">Dictionary</a> &rsaquo; <strong>Name the new definition</strong>
 [% ELSIF ( step_2 ) %] &rsaquo; <a href="/cgi-bin/koha/reports/dictionary.pl">Dictionary</a> &rsaquo; <strong>Step 2: Choose the area </strong> 
         <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>
 </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>
 <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" />
index 05c6acb..447a5f2 100644 (file)
@@ -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 &rsaquo; Reports &rsaquo; Guided reports wizard
 [% IF ( saved1 ) %]&rsaquo; Saved reports
@@ -403,11 +414,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 %]
index 0ab6f24..f3e08d0 100755 (executable)
@@ -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;
 }
index ad72b44..9fe7387 100755 (executable)
@@ -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' ) {