Bug 16308 - Remove the use of "onclick" from Z39.50/SRU servers template
authorOwen Leonard <oleonard@myacpl.org>
Wed, 20 Apr 2016 13:36:20 +0000 (09:36 -0400)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 29 Apr 2016 15:46:49 +0000 (15:46 +0000)
This patch removes the use of event attributes in the markup in favor of
attaching events in JavaScript.

This patch also revises the SRU search fields mapping template
considerably while correcting multiple HTML validation issues:

- Corrected label/id pairs.
- Corrected incorrect capitalization.
- Removed redundant <legend>
- Restructured form so that it displays in two columns.

Also changed in the z3950 servers template: Replaced empty [%
script_name %] variable with actual path.

To test, apply the patch and go to Administration -> Z39.50/SRU servers/

- In the list of servers, select Actions -> Delete. You should be
  prompted to confirm your choice. Test both confirming and cancelling.
- Create or edit an SRU server.
  - After entering text in the server name field, moving to the next
    field should trigger transformation of that text to upper case.
  - On the SRU Search fields mapping line, clicking the "Modify" button
    should trigger a popup.
    - In the "Modify SRU search fields mapping" popup:
      - The fields should display in two columns.
      - All labels should be correctly associated with corresponding
        inputs.

Followed test plan, 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: Kyle M Hall <kyle@bywatersolutions.com>
koha-tmpl/intranet-tmpl/prog/en/modules/admin/sru_modmapping.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt

index 94da006..363ec5e 100644 (file)
@@ -1,5 +1,5 @@
 [% INCLUDE 'doc-head-open.inc' %]
-<title>Koha &rsaquo; SRU Search fields mapping</title>
+<title>Koha &rsaquo; SRU search fields mapping</title>
 [% INCLUDE 'doc-head-close.inc' %]
 
 <script type="text/javascript">
 <div id="custom-doc" class="yui-t7">
 
     <div id="bd">
-        <h1>Modify SRU Search fields mapping</h1>
+        <h1>Modify SRU search fields mapping</h1>
         <form id="form01" method="post">
             <fieldset class="rows">
-                <legend>Legend </legend>
-                <ul>
-                <li>
-                <label for="Title">Title: </label>
-                <input id="title" type="text" value="[% mapping.title %]" />
-                </li>
-                <li>
-                <label for="ISBN">ISBN: </label>
-                <input id="isbn" type="text" value="[% mapping.isbn %]" />
-                </li>
-                <li>
-                <label for="LCCall">LC Call No: </label>
-                <input id="lccall" type="text" value="[% mapping.lccall %]" />
-                </li>
-                <li>
-                <label for="Control number">Control no: </label>
-                <input id="controlnumber" type="text" value="[% mapping.controlnumber %]" />
-                </li>
-                <li>
-                <label for="Any">Any: </label>
-                <input id="srchany" type="text" value="[% mapping.srchany %]" />
-                </li>
-                <li>
-                <label for="Author">Author: </label>
-                <input id="author" type="text" value="[% mapping.author %]" />
-                </li>
-                <li>
-                <label for="ISSN">ISSN: </label>
-                <input id="issn" type="text" value="[% mapping.issn %]" />
-                </li>
-                <li>
-                <label for="Subject">Subject: </label>
-                <input id="subject" type="text" value="[% mapping.subject %]" />
-                </li>
-                <li>
-                <label for="Dewey">Dewey: </label>
-                <input id="dewey" type="text" value="[% mapping.dewey %]" />
-                </li>
-                <li>
-                <label for="Standard ID">Standard ID: </label>
-                <input id="stdid" type="text" value="[% mapping.stdid %]" />
-                </li>
-
-                </ul>
+                <div class="yui-g">
+                    <div class="yui-u first">
+                        <ol>
+                            <li>
+                                <label for="title">Title: </label>
+                                <input id="title" type="text" value="[% mapping.title %]" />
+                            </li>
+                            <li>
+                                <label for="isbn">ISBN: </label>
+                                <input id="isbn" type="text" value="[% mapping.isbn %]" />
+                            </li>
+                            <li>
+                                <label for="lccall">LC call number: </label>
+                                <input id="lccall" type="text" value="[% mapping.lccall %]" />
+                            </li>
+                            <li>
+                                <label for="controlnumber">Control number: </label>
+                                <input id="controlnumber" type="text" value="[% mapping.controlnumber %]" />
+                            </li>
+                            <li>
+                                <label for="srchany">Any: </label>
+                                <input id="srchany" type="text" value="[% mapping.srchany %]" />
+                            </li>
+                        </ol>
+                    </div>
+                    <div class="yui-u">
+                        <ol>
+                            <li>
+                                <label for="author">Author: </label>
+                                <input id="author" type="text" value="[% mapping.author %]" />
+                            </li>
+                            <li>
+                                <label for="issn">ISSN: </label>
+                                <input id="issn" type="text" value="[% mapping.issn %]" />
+                            </li>
+                            <li>
+                                <label for="subject">Subject: </label>
+                                <input id="subject" type="text" value="[% mapping.subject %]" />
+                            </li>
+                            <li>
+                                <label for="dewey">Dewey: </label>
+                                <input id="dewey" type="text" value="[% mapping.dewey %]" />
+                            </li>
+                            <li>
+                                <label for="stdid">Standard ID: </label>
+                                <input id="stdid" type="text" value="[% mapping.stdid %]" />
+                            </li>
+                        </ol>
+                    </div>
+                </div>
             </fieldset>
             <fieldset class="action">
                 <input type="submit" value="Save" class="submit" />
index 66d1a85..7e8fdd2 100644 (file)
             // enable recordtype to include field in post
             $('#recordtype').prop('disabled',false);
         });
+        $("#servername").on("blur",function(){
+            toUC(this);
+        });
+        $("#modify_sru_fields").on("click",function(){
+            ModMapping();
+        });
     });
     function ModMapping () {
         var map= $('#show_sru_fields').val();
-        window.open('/cgi-bin/koha/admin/sru_modmapping.pl?mapping='+map,'popup','width=800,height=400,resizable=no,toolbar=false,scrollbars=no,top');
+        window.open('/cgi-bin/koha/admin/sru_modmapping.pl?mapping='+map,'popup','width=800,height=400,resizable=yes,toolbar=false,scrollbars=yes,top');
     }
 [% ELSE %]
     $(document).ready(function() {
             ],
             "sPaginationType": "four_button"
         }));
+        $(".delete").on("click",function(e){
+            var servername = $(this).data("servername");
+            if( confirm( _("Are you sure you want to delete server %s?").format(servername) ) ) {
+                return true;
+            } else {
+                e.preventDefault();
+            }
+        });
     });
-    function ConfirmDelete(name,id) {
-        if( confirm( _("Choose OK if you really want to delete server ")+
-          name+'.')) {
-            window.location="[% script_name %]?op=delete_confirmed&id="+id;
-        }
-        return false;
-    }
 [% END %]
 //]]>
 </script>
             <input type="hidden" name="id" value="[% server.id %]" />
         [% ELSE %]
             <h1>New [% PROCESS ServerType %] server</h1>
-        [% END %]                
+        [% END %]
         <fieldset class="rows">
         <ol>
-        <li><label for="name">Server name: </label><input type="text" name="servername" id="servername" size="65" maxlength="100" onblur="toUC(this)" value="[% server.servername | html %]"/></li>
+        <li><label for="name">Server name: </label>
+            <input type="text" name="servername" id="servername" size="65" maxlength="100" value="[% server.servername | html %]"/>
+        </li>
 
         <li><label for="host" class="required">Hostname: </label> <input type="text" name="host" id="host" size="30" value="[% server.host %]" required="required" /> <span class="required">Required</span>
             [% IF (server.servertype||type) == 'sru' %]
         <li>
         <label for="sru_fields">SRU Search fields mapping: </label>
         <input type="hidden" name="sru_fields" id="sru_fields" value="[% server.sru_fields %]" />
-        <input type="text" name="show_sru_fields" id="show_sru_fields" size="100" value="[% server.sru_fields %]" disabled/> <input type="button" value="Modify" onclick="ModMapping()" />
+            <input type="text" name="show_sru_fields" id="show_sru_fields" size="100" value="[% server.sru_fields %]" disabled="disabled" /> <input type="button" id="modify_sru_fields" value="Modify" />
         </li>
         [% END %]
         <li>
         <tbody>
         [% FOREACH loo IN loop %]
             <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><a href="/cgi-bin/koha/admin/z3950servers.pl?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' )  %]
                 <span>Bibliographic</span>
                         Actions <b class="caret"></b>
                     </a>
                     <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="reportactions[% savedreport.id %]">
-                        <li><a href="[% loo.script_name %]?op=edit&amp;id=[% loo.id %]"><i class="fa fa-pencil"></i> Edit</a></li>
-                        <li><a href="[% loo.script_name %]?op=add&amp;id=[% loo.id %]"><i class="fa fa-copy"></i> Copy</a></li>
-                        <li><a href="javascript:void(0);" onclick="ConfirmDelete('[% loo.servername | replace("['\"]","") %]','[% loo.id %]');"><i class="fa fa-remove"></i> Delete</a></li>
+                        <li><a href="/cgi-bin/koha/admin/z3950servers.pl?op=edit&amp;id=[% loo.id %]"><i class="fa fa-pencil"></i> Edit</a></li>
+                        <li><a href="/cgi-bin/koha/admin/z3950servers.pl?op=add&amp;id=[% loo.id %]"><i class="fa fa-copy"></i> Copy</a></li>
+                        <li><a href="/cgi-bin/koha/admin/z3950servers.pl?op=delete_confirmed&amp;id=[% loo.id %]" class="delete" data-servername="[% loo.servername %]"><i class="fa fa-remove"></i> Delete</a></li>
                     </ul>
                 </div>
             </td>