LP#1755625 - Webstaff Patron Edit Multiple Email user/cesardv/lp1755625-webstaff_patron_multi_email_addr
authorCesar Velez <cesar.velez@equinoxinitiative.org>
Wed, 9 May 2018 15:40:40 +0000 (11:40 -0400)
committerCesar Velez <cesar.velez@equinoxinitiative.org>
Wed, 9 May 2018 15:52:38 +0000 (11:52 -0400)
This patch works around the fact that AngularJS binding doesn't seem to
work well with multiple email addresses (aka comma-separated email list)
in html5 input elements, even with the 'multiple' attribute. This custom
regex accepts RFC6068-like email address lists. Also misc regctl fix.

Signed-off by: Cesar Velez <cesar.velez@equinoxinitiative.org>

Open-ILS/src/templates/staff/circ/patron/t_edit.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js

index fa94d79..5364fdc 100644 (file)
@@ -113,13 +113,15 @@ MACRO draw_form_input(cls, field, path, type, disable) BLOCK;
 %]
   <div class="col-md-3 reg-field-input">
     <input 
-      type="[% type %]" 
+      [% IF type == 'email' %]type="text" pattern="^(?:\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}\b(?:,(?!$)|$))*$" multiple
+      [% ELSE %]type="[% type %]"
+      [% END %]
       class="form-control" 
       name="[% model %]"
       ng-change="field_modified()" 
       ng-required="field_required('[% cls %]', '[% field %]')"
       ng-blur="handle_field_changed([% base_obj %], '[% field %]')"
-      ng-pattern="field_pattern('[% cls %]', '[% field %]')"
+      [% IF type != 'email' %]ng-pattern="field_pattern('[% cls %]', '[% field %]')"[% END %]
       [% IF disable %]ng-disabled="[% disable %]"[% END %]
       ng-model="[% model %]"/>
   </div>
index 49b0dd6..329f94b 100644 (file)
@@ -652,7 +652,7 @@ angular.module('egCoreMod')
         service.existing_patron = current;
 
         var patron = egCore.idl.toHash(current);
-
+        patron.classname = "au";
         patron.home_ou = egCore.org.get(patron.home_ou.id);
         patron.expire_date = new Date(Date.parse(patron.expire_date));
         patron.dob = service.parse_dob(patron.dob);