LP#1777677: (follow-up) adjust test message buttons in registration form
authorGalen Charlton <gmc@equinoxinitiative.org>
Tue, 21 Jul 2020 21:24:46 +0000 (17:24 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 11 Sep 2020 19:51:31 +0000 (15:51 -0400)
This patch:

* moves the 'Send Test Email' button in the patron registration form
  to cuddle next to the 'Invalidate' button
* disables the 'Send Test Email' button if the email address is
  changed on the form
* disables the 'Send Test Text' button if the SMS carrier or
  SMS text number is changed on the form

The point of the last two changes is to prevent staff members
from sending a test message prior to saving changes to the email
address or SMS number, as otherwise the test methods would not
have access to the new values.

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/templates/staff/circ/patron/t_edit.tt2

index 05cd793..d15538e 100644 (file)
@@ -461,10 +461,10 @@ within the "form" by name for validation.
 <div class="row reg-field-row" ng-show="show_field('au.email')">
   [% draw_field_label('au', 'email') %]
   [% draw_form_input('au', 'email', '', 'email') %]
-  <div class="col-md-3" ng-if="base_email && !patron.isnew">
-    <button class="btn btn-default" ng-click="send_test_email()">[% l('Send Test Email') %]</button>
-  </div>
   <div class="col-md-3 patron-reg-example">
+    <button class="btn btn-default" ng-show="base_email && !patron.isnew"
+      ng-disabled="reg_form['patron.email'].$dirty"
+      ng-click="send_test_email()">[% l('Send Test Email') %]</button>
     <button ng-show="patron.email && !patron.isnew" 
       class="btn btn-default" 
       ng-click="invalidate_field('email')">[% l('Invalidate') %]</button>
@@ -782,12 +782,15 @@ within the "form" by name for validation.
   </div>
   <div class="col-md-3 reg-field-input">
     <input ng-required="hold_notify_type.sms" 
+      name="default_sms_text_number"
       ng-change="field_modified()" ng-model="user_settings['opac.default_sms_notify']"
       ng-blur="handle_field_changed(user_settings, 'opac.default_sms_notify')"
       type='text'/>
   </div>
   <div class="col-md-3" ng-if="base_default_sms && !patron.isnew">
-    <button class="btn btn-default" ng-click="send_test_sms()">[% l('Send Test Text') %]</button>
+    <button class="btn btn-default"
+      ng-disabled="reg_form['default_sms_text_number'].$dirty || reg_form['default_sms_text_carrier'].$dirty"
+      ng-click="send_test_sms()">[% l('Send Test Text') %]</button>
   </div>
 </div>
 
@@ -798,6 +801,7 @@ within the "form" by name for validation.
   <div class="col-md-3 reg-field-input">
     <span class="nullable">
       <select str-to-int ng-required="user_settings['opac.default_sms_notify']" class="form-control" ng-model="user_settings['opac.default_sms_carrier']" ng-options="c.id() as c.name() for c in sms_carriers"
+      name="default_sms_text_carrier"
       ng-blur="handle_field_changed(user_settings, 'opac.default_sms_carrier')">
         <option value="">Select a Carrier</option>
       </select>