Bugzilla – Attachment 89597 Details for
Bug 22862
It should be possible to paste formatted phone numbers into the SMS messaging number field
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22862: Normalize SMS messaging numbers before validating them
Bug-22862-Normalize-SMS-messaging-numbers-before-v.patch (text/plain), 2.77 KB, created by
Katrin Fischer
on 2019-05-11 12:19:11 UTC
(
hide
)
Description:
Bug 22862: Normalize SMS messaging numbers before validating them
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2019-05-11 12:19:11 UTC
Size:
2.77 KB
patch
obsolete
>From 0af30fdc6d9cafd49046b81912e26f43fb8411e6 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 7 May 2019 14:53:29 -0400 >Subject: [PATCH] Bug 22862: Normalize SMS messaging numbers before validating > them > >Librarians often copy and paste patron data, including phone numbers. SMS phone numbers are now being validated to conform to the E.164 specification. It would be nice to try to normalize that data by stripping non-numeric data from the paste (i.e. dashes, parens, etc ). > >Test Plan: >1) Apply this patch >2) On the staff side, Attempt to enter invalid characters the SMS number field >3) Note you cannot enter invalid characters >4) Attempt to paste a phone number with invalid characters >5) Note those characters are removed on paste >6) Repeat these steps on the OPAC > >Signed-off-by: Liz Rea <wizzyrea@gmail.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > koha-tmpl/intranet-tmpl/prog/js/members.js | 6 ++++++ > .../bootstrap/en/modules/opac-messaging.tt | 22 ++++++++++++++++++++++ > 2 files changed, 28 insertions(+) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/members.js b/koha-tmpl/intranet-tmpl/prog/js/members.js >index bcca8ef83c..ea1f7d7707 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/members.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/members.js >@@ -315,6 +315,12 @@ $(document).ready(function(){ > function(value, element, phone) { > var e164 = "^\\+?[1-9]\\d{1,14}$"; > var re = new RegExp(e164); >+ >+ let has_plus = value.charAt(0) === '+'; >+ value = value.replace(/\D/g,''); >+ if ( has_plus ) value = '+' + value; >+ element.value = value; >+ > return this.optional(element) || re.test(value); > }, > jQuery.validator.messages.phone); >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt >index 9f4e6f7908..145a515447 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt >@@ -185,6 +185,28 @@ > }); > $("#info_digests").tooltip(); > }); >+ >+function normalizeSMS(value){ >+ let has_plus = value.charAt(0) === '+'; >+ let new_value = value.replace(/[^0-9]+/g, ''); >+ if ( has_plus ) new_value = '+' + new_value; >+ return new_value; >+} >+ >+var sms_input = document.getElementById('SMSnumber'); >+ >+sms_input.addEventListener('keyup', function(){ >+ var field = sms_input.value; >+ sms_input.value = normalizeSMS(field); >+}); >+ >+sms_input.addEventListener('paste', function(event) { >+ let paste = (event.clipboardData || window.clipboardData).getData('text'); >+ setTimeout(function () { >+ sms_input.value = normalizeSMS(paste); >+ }, 100); >+}); >+ > //]]> > </script> > [% END %] >-- >2.11.0
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 22862
:
89458
|
89474
|
89522
| 89597 |
89598