Bug 7567 - Correct Filtering and Default dropdown values
authorMark Tompsett <mtompset@hotmail.com>
Sat, 14 Dec 2013 03:12:37 +0000 (22:12 -0500)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 7 Apr 2014 18:05:39 +0000 (18:05 +0000)
In the staff client, when you went to Home -> Tools -> News
the default 'Display location' is 'All'. Everything is correctly
displayed. However, if you change the filter it filters the
table correctly, but does not set the dropdown value to match.
This patch corrects this.

TEST PLAN
---------
 1) Home -> Tools -> News
 2) Change 'Display location' value and click 'Filter'.
    - Is the 'Display location' value the same now?
      (no)
    - Are the correct values displayed?
 3) Click 'New entry'
    - Is it anything other than 'All'?
      (no, and is this correct?)
 4) Click 'Cancel'
 5) Click 'Edit' for various news items with different locations.
    - Does the 'Display location' get proper set?
      (no)
 6) Apply patch
 7) Change the 'Display location' value and click 'Filter'.
    - Does the 'Display location' value stay the same?
      (this should be correct now)
    - Are the correct values displayed?
 8) Change the 'Display location' value to 'All' and click 'Filter'.
    - Does everything display?
 9) Change the 'Display location' value and click 'Filter'.
10) Click 'New entry'
    - Does it match what the filter was?
      (should match now)
11) Click 'Cancel'
12) Click 'Edit' for various news items with different locations.
    - Does the 'Display location' get proper set?
      (this should be correct now)

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>

koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt
tools/koha-news.pl

index 931b7d9..368b711 100644 (file)
@@ -64,23 +64,43 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div>
 
 [% UNLESS ( add_form ) %]
 <div id="toolbar" class="btn-toolbar">
-    <a class="btn btn-small" id="newentry" href="/cgi-bin/koha/tools/koha-news.pl?op=add_form"><i class="icon-plus"></i> New entry</a>
+    <a class="btn btn-small" id="newentry" href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&lang=[% lang %]"><i class="icon-plus"></i> New entry</a>
 </div>
 [% END %]
 
 [% IF ( add_form ) %]
+    [% IF ( op == 'add' ) %][% default_lang = lang %]
+    [% ELSE %][% default_lang = new_detail.lang %]
+    [% END %]
         <form name="add_form" method="post" action="/cgi-bin/koha/tools/koha-news.pl" >
             <input type="hidden" name="op" value="[% op %]" />
             <input type="hidden" name="id" value="[% id %]" />
                        <fieldset class="rows">
             <legend>OPAC and Koha news</legend>
            <ol> <li>
-            <label for="lang">Display location</label>
+            <label for="lang">([% new_detail.lang %])([% lang %])Display location</label>
             <select id="lang" name="lang">
-                <option value="koha">Librarian interface</option>
-                [% IF ( slip ) %]<option value="slip" selected="selected">Slip</option>[% ELSE %]<option value="slip">Slip</option>[% END %]
+                [% IF ( default_lang == "" ) %]
+                <option value=""     selected>All</option>
+                [% ELSE %]
+                <option value=""             >All</option>
+                [% END %]
+                [% IF ( default_lang == "koha" ) %]
+                <option value="koha" selected>Librarian interface</option>
+                [% ELSE %]
+                <option value="koha"         >Librarian interface</option>
+                [% END %]
+                [% IF ( default_lang == "slip" ) %]
+                <option value="slip" selected>Slip</option>
+                [% ELSE %]
+                <option value="slip"         >Slip</option>
+                [% END %]
                 [% FOREACH lang_lis IN lang_list %]
-                    [% IF ( lang_lis.selected ) %]<option value="[% lang_lis.language %]" selected="selected">OPAC ([% lang_lis.language %])</option>[% ELSE %]<option value="[% lang_lis.language %]">OPAC ([% lang_lis.language %])</option>[% END %]
+                [% IF ( lang_lis.language == default_lang ) %]
+                    <option value="[% lang_lis.language %]" selected>OPAC ([% lang_lis.language %])</option>
+                [% ELSE %]
+                    <option value="[% lang_lis.language %]"         >OPAC ([% lang_lis.language %])</option>
+                [% END %]
                 [% END %]
             </select>
             </li>
@@ -118,17 +138,27 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div>
         <form name="add_form" method="post" action="/cgi-bin/koha/tools/koha-news.pl" >
             <label for="lang">Display location:</label>
             <select name="lang" id="lang">
-            <option value="">All</option>
-            <option value="koha">Librarian interface</option>
-           <option value="slip">Slip</option>
+            [% IF ( lang == "" ) %]
+            <option value=""     selected>All</option>
+            [% ELSE %]
+            <option value=""             >All</option>
+            [% END %]
+            [% IF ( lang == "koha" ) %]
+            <option value="koha" selected>Librarian interface</option>
+            [% ELSE %]
+            <option value="koha"         >Librarian interface</option>
+            [% END %]
+            [% IF ( lang == "slip" ) %]
+            <option value="slip" selected>Slip</option>
+            [% ELSE %]
+            <option value="slip"         >Slip</option>
+            [% END %]
                 [% FOREACH lang_lis IN lang_list %]
-                    [% IF ( lang_lis.selected ) %]
-                        <option value="[% lang_lis.language %]" selected="selected">
-                    [% ELSE %]
-                        <option value="[% lang_lis.language %]">
-                    [% END %]
-                        OPAC ([% lang_lis.language %])
-                    </option>
+                [% IF ( lang_lis.language == lang ) %]
+                    <option value="[% lang_lis.language %]" selected>OPAC ([% lang_lis.language %])</option>
+                [% ELSE %]
+                    <option value="[% lang_lis.language %]">OPAC ([% lang_lis.language %])</option>
+                [% END %]
                 [% END %]
             </select>
             <input type="submit" class="button" value="Filter" />
@@ -156,15 +186,16 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div>
                             <td>
                                 <input type="checkbox" name="ids" value="[% opac_new.idnew %]" />
                             </td>
-                            <td>[% IF ( opac_new.lang == 'koha' ) %]
-                                   Librarian interface
-                                 [% ELSE %]
-                                    [% IF ( opac_new.lang == 'slip' ) %]
-                                       Slip
-                                    [% ELSE %]
-                                        OPAC
-                                   [% END %]
-                                [% END %]
+                            <td>[% SWITCH opac_new.lang %]
+                                [%   CASE "koha" %]
+                                    Librarian interface
+                                [%   CASE "slip" %]
+                                    Slip
+                                [%   CASE "" %]
+                                    All
+                                [%   CASE %]
+                                    OPAC ([% opac_new.lang %])
+                                [% END %]
                              </td>
 
                             <td>[% opac_new.number %]</td>
index 0461c0c..5578b31 100755 (executable)
@@ -7,6 +7,7 @@
 # Casta�eda, Carlos Sebastian - seba3c@yahoo.com.ar - Physics Library UNLP Argentina
 # Modified to include news to KOHA intranet - tgarip@neu.edu.tr NEU library -Cyprus
 # Copyright 2000-2002 Katipo Communications
+# Copyright (C) 2013    Mark Tompsett
 #
 # Koha is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -117,4 +118,5 @@ else {
         opac_news_count => $opac_news_count,
                );
 }
+$template->param( lang => $lang );
 output_html_with_http_headers $cgi, $cookie, $template->output;