Bug 2889 - templates should use [% IF ( loop.odd ) %] - Administration
authorOwen Leonard <oleonard@myacpl.org>
Mon, 14 Jul 2014 12:33:48 +0000 (08:33 -0400)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Wed, 15 Oct 2014 20:59:12 +0000 (17:59 -0300)
Some scripts pass a template variable to facilitate an alternate table
row class for styling. Other use the 'IF (loop.odd)' construction. I
think we're at the point where the CSS3 :nth-child() selector is
widely-supported enough that we can do without template-based solutions:

http://caniuse.com/#feat=css-sel3

This patch adds such a selector to the staff client CSS and removes the
corresponding template markup from Administration pages. The last in
this series of patches will remove the redundant CSS.

Also in this patch: a few minor markup corrections.

To test, apply the patch and clear your browser cache if necessary. View
the following pages and confirm that alternate table row highlighting
works as before:

 - Administration -> Budgets
 - Acquisitions   -> Vendor -> Contracts
 - Administration -> Budgets -> Budget -> Planning
 - Administration -> Authority types
 - Administration -> Authority types -> MARC structure
 - Administration -> Authority types -> MARC structure -> subfields
 - Administration -> MARC bibliographic framework
 - Administration -> MARC bibliographic framework -> MARC structure
 - Administration -> MARC bibliographic framework -> MARC structure -> Subfields
 - Administration -> Libraries and groups
 - Administration -> Cities and towns
 - Administration -> Classification sources
 - Administration -> Circulation and fines rules
 - Administration -> Currencies and exchange rates
 - Administration -> Item types
 - Administration -> Koha to MARC mapping
 - Administration -> System preferences -> Local use
 - Administration -> Z39.50 client targets

Signed-off-by: Nick Clemens <nick@quecheelibrary.org>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
22 files changed:
koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqcontract.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqplan.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_tag_structure.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/biblio_framework.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/branch_transfer_limits.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/classsources.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/clone-rules.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/koha2marclinks.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/printers.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/stopwords.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/systempreferences.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt

index 382701b..0f67416 100644 (file)
@@ -260,6 +260,7 @@ table+table {
 
 .highlighted-row { background-color: orange !important }
 
+tbody tr:nth-child(odd) td,
 tr.highlight td,
 tr.highlight th,
 tr.odd td,
index 51b8b8a..be49860 100644 (file)
           </thead>
           <tbody>
               [% FOREACH period_loo IN period_inactive_loop %]
-                  [% IF ( loop.odd ) %]
-                      <tr>
-                  [% ELSE %]
-                      <tr class="highlight">
-                  [% END %]
+                  <tr>
                   <td><a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% period_loo.budget_period_id %]" title="View funds for [% period_loo.budget_period_description %]">[% period_loo.budget_period_description %]</a></td>
                   <td><span title="[% period_loo.budget_period_startdate %]">[% period_loo.budget_period_startdate | $KohaDates %]</span></td>
                   <td><span title="[% period_loo.budget_period_enddate %]">[% period_loo.budget_period_enddate | $KohaDates %]</span></td>
index afbabfd..ed8336a 100644 (file)
@@ -181,7 +181,7 @@ function Check(ff) {
                             <th scope="col" colspan="2">&nbsp; </th>
                         </tr>
                     [% FOREACH loo IN loop %]
-                        [% IF ( loop.even ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
+                        <tr>
                         <td>
                             <a href="[% loo.script_name %]?op=add_form&amp;booksellerid=[% loo.booksellerid %]&amp;contractnumber=[% loo.contractnumber %]">[% loo.contractname %]</a>
                         </td>
index d5d8906..65cd9c4 100644 (file)
 
     <tbody>
     [% FOREACH budget_line IN budget_lines %]
-    [% UNLESS ( loop.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
+    <tr>
         [% IF ( budget_line.budget_lock ) %]
             <td class="locked" title="Fund locked">
         [% ELSE %]
index bc72266..f7b1d52 100644 (file)
@@ -262,11 +262,7 @@ function displayMoreConstraint(numlayer){
         <th>Delete</th>
     </tr>
     [% FOREACH loo IN loop %]
-    [% UNLESS ( loop.odd ) %]
-    <tr class="highlight">
-    [% ELSE %]
     <tr>
-    [% END %]
         <td>[% loo.tagsubfield %]</td>
         <td>
             [% IF ( loo.subfield_ignored ) %]
index 87c55b4..eabcf9e 100644 (file)
@@ -54,7 +54,7 @@
                 [% ELSE %]<a href="/cgi-bin/koha/admin/auth_tag_structure.pl">Default framework</a>
                 [% END %] &rsaquo; Data deleted
             [% ELSE %]
-                [% IF ( authtypecode ) %][% authtypecode %] Framework</a>
+                [% IF ( authtypecode ) %][% authtypecode %] Framework
                 [% ELSE %]Default framework
                 [% END %]
             [% END %]
 </div>
 <table id="table_authtagstructure">
     <thead>
-        <th>Tag</th>
-        <th>Lib</th>
-        <th>Repeatable</th>
-        <th>Mandatory</th>
-        <th>Authorized<br />value</th>
-        <th>Subfields</th>
-        <th>Edit</th>
-        <th>Delete</th>
+        <tr>
+            <th>Tag</th>
+            <th>Lib</th>
+            <th>Repeatable</th>
+            <th>Mandatory</th>
+            <th>Authorized<br />value</th>
+            <th>Subfields</th>
+            <th>Edit</th>
+            <th>Delete</th>
+            </tr>
     </thead>
-    [% FOREACH loo IN loop %]
-    [% UNLESS ( loop.odd ) %]
-    <tr class="highlight">
-    [% ELSE %]
-    <tr>
-    [% END %]
-        <td><b>[% loo.tagfield %]</b></td>
-        <td>[% loo.liblibrarian %]</td>
-        <td>[% IF ( loo.repeatable ) %]Yes[% ELSE %]No[% END %]</td>
-        <td>[% IF ( loo.mandatory ) %]Yes[% ELSE %]No[% END %]</td>
-        <td>[% loo.authorised_value %]</td>
-        <td><a href="[% loo.subfield_link %]" class="button">subfields</a></td>
-        <td><a href="[% loo.edit %]">Edit</a></td>
-        <td><a href="[% loo.delete %]">Delete</a></td>
-    </tr>
-    [% END %]
+    <tbody>
+        [% FOREACH loo IN loop %]
+        <tr>
+            <td><b>[% loo.tagfield %]</b></td>
+            <td>[% loo.liblibrarian %]</td>
+            <td>[% IF ( loo.repeatable ) %]Yes[% ELSE %]No[% END %]</td>
+            <td>[% IF ( loo.mandatory ) %]Yes[% ELSE %]No[% END %]</td>
+            <td>[% loo.authorised_value %]</td>
+            <td><a href="[% loo.subfield_link %]" class="button">subfields</a></td>
+            <td><a href="[% loo.edit %]">Edit</a></td>
+            <td><a href="[% loo.delete %]">Delete</a></td>
+        </tr>
+        [% END %]
+    </tbody>
     </table>
 
 [% END %]
index dcc606d..2c12808 100644 (file)
        </tr>
        
        [% FOREACH loo IN loop %]
-        [% IF ( loop.odd ) %]
                <tr>
-        [% ELSE %]
-        <tr class="highlight">
-        [% END %]
                        <td>[% loo.authtypecode %]</td>
                        <td>[% loo.authtypetext %]</td>
                        <td>[% loo.summary %]</td>
index fcba389..791e971 100644 (file)
     </tr>
     <!-- note highlight assignment appears backwards because we already have a normal row for Default -->
     [% FOREACH loo IN loop %]
-        [% IF ( loop.odd ) %]<tr class="highlight">
-        [% ELSE %]<tr>
-        [% END %]
+        <tr>
             <td>[% loo.frameworkcode %]</td>
             <td>[% loo.frameworktext %]</td>
             <td><a href="marctagstructure.pl?frameworkcode=[% loo.frameworkcode %]" >MARC structure</a></td>
index 7e8165f..375152c 100644 (file)
@@ -95,7 +95,7 @@
 
                        <tbody>
                                        [% FOREACH to_branch_loo IN codes_loo.to_branch_loop %]
-                                               [% UNLESS ( loop.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
+                        <tr>
                                                        <td><label style="min-width:400px;" for="[% to_branch_loo.code %][% to_branch_loo.toBranch %]row">[% to_branch_loo.toBranch %] - [% to_branch_loo.toBranchname %]</label></td>
                                                        <td>
                                                        [% IF ( to_branch_loo.isChecked ) %]
index f12107f..df49e26 100644 (file)
@@ -186,11 +186,7 @@ tinyMCE.init({
             <th>&nbsp;</th>
         </tr></thead><tbody>
         [% FOREACH branche IN branches %]
-       [% IF ( loop.odd ) %]
-        <tr>
-       [% ELSE %]
-               <tr class="highlight">
-       [% END %]
+            <tr>
                 <td>[% branche.branch_name |html %]</td>
                 <td>[% branche.branch_code |html %]</td>
                 <td>
index 0265634..fa5629c 100644 (file)
                        <th>&nbsp;</th>
                </thead>
                [% FOREACH loo IN loop %]
-               [% UNLESS ( loop.odd ) %]
-               <tr class="highlight">
-               [% ELSE %]
-               <tr>
-               [% END %]
+        <tr>
                        <td>[% loo.cityid %]</td>
                        <td>[% loo.city_name %]</td>
                        <td>[% loo.city_state %]</td>
index 140c033..8f9446f 100644 (file)
@@ -250,11 +250,7 @@ function CheckRuleForm(f) {
     <th>Actions</th>
   </tr>
   [% FOREACH class_source IN class_sources %]
-  [% IF ( loop.odd ) %]
   <tr>
-  [% ELSE %]
-  <tr class="highlight">
-  [% END %]
     <td>[% class_source.code %]</td>
     <td>[% class_source.description %]</td>
     <td>[% IF ( class_source.used ) %]Yes[% ELSE %]No[% END %]</td>
index 74d6ef4..146b203 100644 (file)
@@ -1,5 +1,5 @@
 [% INCLUDE 'doc-head-open.inc' %]
-<title>Koha &rsaquo; Administration &rsaquo; Issuing Rules &rsaquo; Clone Issuing Rules</title>
+<title>Koha &rsaquo; Administration &rsaquo; Issuing rules &rsaquo; Clone issuing rules</title>
 [% INCLUDE 'doc-head-close.inc' %]
 </head>
 <body id="admin_clone-rules" class="admin">
index 522420b..9a691fb 100644 (file)
@@ -266,11 +266,7 @@ Item types administration
     <th>Actions</th>
   </thead>
   [% FOREACH loo IN loop %]
-    [% UNLESS ( loop.odd ) %]
-  <tr class="highlight">
-    [% ELSE %]
-  <tr>
-    [% END %]
+    <tr>
    [% UNLESS ( noItemTypeImages ) %] <td>[% IF ( loo.imageurl ) %]<img src="[% loo.imageurl %]" alt="" />[% ELSE %]&nbsp;[% END %]</td>[% END %]
     <td>
       <a href="[% loo.script_name %]?op=add_form&amp;itemtype=[% loo.itemtype |html %]">
index 35134fa..a96dd7d 100644 (file)
     <th>&nbsp;</th>
 </tr>
 [% FOREACH loo IN loop %]
-[% UNLESS ( loop.odd ) %]
-<tr class="highlight">
-[% ELSE %]
 <tr>
-[% END %]
     <td><a href="[% loo.edit %]">[% loo.kohafield %]</a></td>
     <td>[% loo.tagfield %]</td>
     <td>[% loo.tagsubfield %]</td>
index c12ddf1..bfa8815 100644 (file)
@@ -391,11 +391,7 @@ function populateHiddenCheckboxes(tab) {
     <th>Delete</th>
 </tr>
 [% FOREACH loo IN loop %]
-[% UNLESS ( loop.odd ) %]
-<tr class="highlight">
-[% ELSE %]
 <tr>
-[% END %]
     <td><a href="/cgi-bin/koha/admin/marc_subfields_structure.pl?op=add_form&amp;tagfield=[% loo.tagfield %]&amp;frameworkcode=[% frameworkcode %]#sub[% loo.tagsubfield %]field">[% loo.tagsubfield %]</a></td>
     <td>
         [% IF ( loo.subfield_ignored ) %]
index 219389d..049f419 100644 (file)
@@ -192,7 +192,7 @@ $(document).ready(function() {
     <tbody>
     [% IF ( select_display ) %]
         [% FOREACH loo IN loop %]
-            [% IF ( loop.odd ) %]<tr>[% ELSE %]<tr class="highlight">[% END %]
+            <tr>
             <td>[% loo.tagfield %]</td>
             <td>[% loo.liblibrarian %]</td>
             <td>[% IF ( loo.repeatable ) %]Yes[% ELSE %]No[% END %]</td>
index 151e8d6..0e77e8b 100644 (file)
                        <th>&nbsp;</th>
                </tr>
                [% FOREACH loo IN loop %]
-               [% IF ( loop.odd ) %]<tr>[% ELSE %]<tr class="highlight">[% END %]
+        <tr>
                        <td>[% loo.printername %]</td>
                        <td>[% loo.printqueue %]</td>
                        <td>[% loo.printtype %]</td>
index 535c740..8bc5809 100644 (file)
@@ -162,11 +162,7 @@ for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde
             </thead>
             <tbody>
                                [% FOREACH rule IN rules %]
-                                       [% UNLESS ( loop.odd ) %]
-                                       <tr class="highlight" id="row_[% loop.count %]">
-                                       [% ELSE %]
                                        <tr id="row_[% loop.count %]">
-                                       [% END %]
                                                        <td>[% IF ( rule.default_humancategorycode ) %]
                                                                        <em>All</em>
                                                                [% ELSE %]
index 6ba5697..db1016f 100644 (file)
             <th></th>
         </tr>
         [% FOREACH loo IN loop %]
-           [% IF ( loop.odd ) %]<tr>
-           [% ELSE %]<tr class="highlight">
-           [% END %]
+            <tr>
             <td>[% loo.word %]</td>
             <td><a href="[% loo.script_name %]?op=delete_confirm&amp;searchfield=[% loo.word %]">Delete</a></td>
         </tr>
index 6ca3274..2d27d83 100644 (file)
         </tr></thead>
     [% END %]
     <tbody>[% FOREACH loo IN loop %]
-    [% UNLESS ( loop.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
+        <tr>
 
         <td><strong><a href="[% loo.edit %]">[% loo.variable %]</a></strong></td><td> [% loo.explanation |html %]</td>
         [% IF ( loo.oneline ) %]
index 10298ce..fd27234 100644 (file)
         </tr></thead>
         <tbody>
         [% FOREACH loo IN loop %]
-            [% UNLESS ( loop.odd ) %]
-                <tr class="highlight">
-            [% ELSE %]
-                <tr>
-            [% END %]
+            <tr>
             <td><a href="[% loo.script_name %]?op=edit&amp;id=[% loo.id %]">[% loo.servername %]</a></td><td>[% loo.host %]:[% loo.port %]</td><td>[% loo.db %]</td><td>[% loo.userid %]</td><td>[% IF loo.password %]########[% END %]</td><td>[% IF ( loo.checked ) %]Yes[% ELSE %]No[% END %]</td><td>[% loo.rank %]</td>
             <td>[% loo.syntax %]</td><td>[% loo.encoding %]</td><td>[% loo.timeout %]</td>
             <td>[% IF ( loo.recordtype == 'biblio' )  %]