Bugzilla – Attachment 123332 Details for
Bug 28495
Add validation to branchcode upon library creation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28495: Improve validation of library entry form
Bug-28495-Improve-validation-of-library-entry-form.patch (text/plain), 6.82 KB, created by
Nick Clemens (kidclamp)
on 2021-07-30 14:45:51 UTC
(
hide
)
Description:
Bug 28495: Improve validation of library entry form
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2021-07-30 14:45:51 UTC
Size:
6.82 KB
patch
obsolete
>From 9365fd21167dc9b1917ac5524f022fa06a5db2ff Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Wed, 9 Jun 2021 11:35:27 +0000 >Subject: [PATCH] Bug 28495: Improve validation of library entry form > >This patch adds validation of the "Library code" field so that entry is >limited to letters and numbers. > >Also changed: Updated the email fields to add the "email" type attribute >(see also Bug 27805). > >To test, apply the patch and go to Administration -> Libraries -> New >library. > >- Try entering various strings in the "Library code" field. If you enter > anything other than letters and numbers an error message should be > displaed on blur or on submit. >- Try submitting the form with no data in the "Library code" and/or > "Name" field. The fields should be required. >- Test entering various strings in the email-type fields: > Email, Ill staff email, Reply-To, and Return-Path. Non-email entries > should trigger a message, "Please enter a valid email address." > >Signed-off-by: Salman Ali <salman.ali@inLibro.com> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > .../prog/en/modules/admin/branches.tt | 38 +++++++++++-------- > 1 file changed, 23 insertions(+), 15 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt >index 01b2c0f455..8ddda78da3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt >@@ -125,7 +125,7 @@ Libraries › Administration › Koha > > [% IF op == 'add_form' %] > <h3>[% IF library %]Modify library[% ELSE %]New library[% END %]</h3> >- <form action="/cgi-bin/koha/admin/branches.pl" id="Aform" name="Aform" class="validated" method="post"> >+ <form action="/cgi-bin/koha/admin/branches.pl" id="Aform" name="Aform" method="post"> > <fieldset class="rows"> > <input type="hidden" name="op" value="add_validate" /> > [% IF library %] >@@ -182,11 +182,11 @@ Libraries › Administration › Koha > <li><label for="branchcountry">Country: </label><input type="text" name="branchcountry" id="branchcountry" size="60" value="[% library.branchcountry | html %]" /></li> > <li><label for="branchphone">Phone: </label><input type="text" name="branchphone" id="branchphone" size="60" value="[% library.branchphone | html %]" /></li> > <li><label for="branchfax">Fax: </label><input type="text" name="branchfax" id="branchfax" size="60" value="[% library.branchfax | html %]" /></li> >- <li><label for="branchemail">Email: </label><input type="text" name="branchemail" id="branchemail" class="email" size="80" value="[% library.branchemail | html %]" /></li> >+ <li><label for="branchemail">Email: </label><input type="email" name="branchemail" id="branchemail" class="email" size="80" value="[% library.branchemail | html %]" /></li> > [% IF (Koha.Preference('ILLModule')) %] > <li> > <label for="branchillemail">ILL staff email: </label> >- <input type="text" name="branchillemail" id="branchillemail" class="email" size="80" value="[% library.branchillemail | html %]" /> >+ <input type="email" name="branchillemail" id="branchillemail" class="email" size="80" value="[% library.branchillemail | html %]" /> > <div class="hint"> > [% IF ( CAN_user_parameters_manage_sysprefs ) %] > Default: <a target="_blank" href="/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=ILLDefaultStaffEmail">ILLDefaultStaffEmail</a> system preference >@@ -198,7 +198,7 @@ Libraries › Administration › Koha > [% END %] > <li> > <label for="branchreplyto">Reply-To: </label> >- <input type="text" name="branchreplyto" id="branchreplyto" class="email" size="80" value="[% library.branchreplyto | html %]" /> >+ <input type="email" name="branchreplyto" id="branchreplyto" class="email" size="80" value="[% library.branchreplyto | html %]" /> > <div class="hint"> > [% IF ( CAN_user_parameters_manage_sysprefs ) %] > Default: <a target="_blank" href="/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=ReplyToDefault">ReplyToDefault</a> system preference >@@ -209,7 +209,7 @@ Libraries › Administration › Koha > </li> > <li> > <label for="branchreturnpath">Return-Path: </label> >- <input type="text" name="branchreturnpath" id="branchreturnpath" class="email" size="80" value="[% library.branchreturnpath | html %]" /> >+ <input type="email" name="branchreturnpath" id="branchreturnpath" class="email" size="80" value="[% library.branchreturnpath | html %]" /> > <div class="hint"> > [% IF ( CAN_user_parameters_manage_sysprefs ) %] > Default: <a target="_blank" href="/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=ReturnpathDefault">ReturnpathDefault</a> system preference >@@ -328,6 +328,16 @@ Libraries › Administration › Koha > [% Asset.js("lib/tiny_mce/tinymce.min.js") | $raw %] > [% INCLUDE 'str/tinymce_i18n.inc' %] > <script> >+ jQuery.validator.addMethod( "letters_numbers", function(value,element){ >+ var patt = /^[a-zA-Z0-9]+$/g; >+ if (patt.test(element.value)) { >+ return true; >+ } else { >+ return false; >+ } >+ }, _("Library code can only contain letters and numbers.") >+ ); >+ > var columns_settings = [% TablesSettings.GetColumns( 'admin', 'libraries', 'libraries', 'json' ) | $raw %]; > $(document).ready(function() { > >@@ -496,17 +506,15 @@ Libraries › Administration › Koha > ] > }, columns_settings); > >- [% UNLESS library %] >- $("#Aform").on("submit", function( event ) { >- if ( $("#branchcode").val().match(/\s/) ) { >- event.preventDefault(); >- alert(_("The library code entered contains whitespace characters. Please remove any whitespace characters from the library code")); >- return false; >- } else { >- return true; >+ $("#Aform").validate({ >+ rules: { >+ branchcode: { >+ required: true, >+ letters_numbers: true > } >- }); >- [% END %] >+ } >+ }); >+ > }); > > tinyMCE.init({ >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 28495
:
121737
|
121867
|
123318
|
123332
|
123333