Bug 18980: Remove js function Check from opac-shelves
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Wed, 21 Jun 2017 14:53:56 +0000 (16:53 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 10 Aug 2017 16:20:31 +0000 (13:20 -0300)
This function only serves to check if the shelf name is not empty. It
does not even work since it incorrectly refers to f.addshelf (while it
should test #shelfname).
We can solve this and improve consistency by doing the same as in the
staff template with html5 required.

Test plan:
[1] Without this patch it was possible to add a list without a name in
    OPAC (with js error: TypeError: f.addshelf is undefined).
[2] With this patch, verify that you cannot do this anymore.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Signed-off-by: Marc VĂ©ron <veron@veron.ch>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt

index 0417531..f662c88 100644 (file)
                                 <ol>
                                     <li>
                                         <label class="required" for="shelfname">List name: </label>
-                                        <input type="text" id="shelfname" name="shelfname" maxlength="255" value="[% shelf.shelfname |html %]" /></li>
+                                        <input type="text" id="shelfname" name="shelfname" maxlength="255" value="[% shelf.shelfname |html %]" required="required" class="required"/> <span class="required">Required</span></li>
                                     <li>
                                         <label for="sortfield" >Sort this list by: </label>
                                         <select name="sortfield" id="sortfield">
                             </fieldset>
 
                             <fieldset class="action">
-                                <input type="submit" onclick="Check(this.form); return false;" value="Save" class="btn" />
+                                <input type="submit" value="Save" class="btn" />
                                 [% IF referer == 'view' %]
                                     <a href="/cgi-bin/koha/opac-shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber %]" class="cancel">Cancel</a>
                                 [% ELSE %]
@@ -938,24 +938,6 @@ $(function() {
     AdjustRemark();
 }); // document.ready
 
-function Check(f) {
-    var _alertString="";
-    var alertString2;
-
-    if(f.addshelf.value.length ==0){
-        _alertString += _("- You must enter a list name") + "\n";
-    }
-
-    if (_alertString.length==0) {
-        f.submit();
-    } else {
-        alertString2 = _("Form not submitted because of the following problem(s)");
-        alertString2 += "\n------------------------------------------------------------------------------------\n\n";
-        alertString2 += _alertString;
-        alert(alertString2);
-    }
-}
-
 function AdjustRemark() {
     var category;
     if( $("#category").length > 0 ) {