LP1895675 Bootstrap OPAC: Add notification method testing to My Account
authorTerran McCanna <tmccanna@georgialibraries.org>
Fri, 28 Oct 2022 22:19:58 +0000 (18:19 -0400)
committerJane Sandberg <js7389@princeton.edu>
Fri, 4 Nov 2022 03:21:58 +0000 (20:21 -0700)
This adds the work done in the TPAC for LP1777677 to the Bootstrap OPAC.
A test email button is added to My Account > Preferences, and a test
text message button is added to My Account > Preferences > Notification
Preferences.

Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Signed-off-by: Christine Burns <christine.burns@bc.libraries.coop>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>

Open-ILS/src/templates-bootstrap/opac/myopac/prefs.tt2
Open-ILS/src/templates-bootstrap/opac/myopac/prefs_notify.tt2
Open-ILS/src/templates-bootstrap/opac/myopac/test_notification.tt2 [new file with mode: 0644]
Open-ILS/src/templates-bootstrap/opac/parts/header.tt2
Open-ILS/src/templates-bootstrap/opac/parts/js.tt2
Open-ILS/src/templates-bootstrap/opac/parts/sms_carrier_selector.tt2

index 5c34b56..a7b1aa0 100755 (executable)
@@ -2,8 +2,10 @@
     WRAPPER "opac/parts/myopac/base.tt2";
     myopac_page = "prefs";
     parent="prefs";
-    prefs_page = 'prefs' %]
- <h3>[% l('Account Information and Preferences') %]</h3>
+    prefs_page = 'prefs';
+    can_call_action_trigger = 'true' %]
+
+<h3>[% l('Account Information and Preferences') %]</h3>
 <div id="acct_info_main">
     <table title="[% l('Account preference') %]" class='light_border table table-hover'>
         <tbody id='myopac_summary_tbody'>
                 <span class='light_border'><a class="btn btn-sm btn-action" href='update_email'
                     title="[% l('Update Email Address') %]"><i class="fas fa-user-cog"></i> [% l('Change') %]</a></span>
                 [%- END %]
+                [%- IF ctx.user.email %]
+                    <span class='light_border'>
+                    <a href="#" class="btn btn-sm btn-action" onclick="sendTestEmail(
+                        [% ctx.user.id %], '[% ctx.authtoken %]')"
+                        title="[% l('Send Test Email') %]">
+                        <i class="fas fa-envelope"></i> [% l('Send Test Email') %]
+                    </a>
+                    </span>
+                [%- END %]
+                </td>
+            </tr>
+            <tr id="test_notification_banner" style="display:none">
+                <td></td>
+                <td colspan='2'>
+                    [% INCLUDE "opac/myopac/test_notification.tt2" message_type = "email" %]
                 </td>
             </tr>
 
index 348bd45..bb76c0b 100755 (executable)
@@ -2,8 +2,8 @@
     WRAPPER "opac/parts/myopac/base.tt2";
     myopac_page = "prefs_notify";
     parent="prefs";
-    prefs_page = 'prefs_notify'
-%]
+    prefs_page = 'prefs_notify';
+    can_call_action_trigger = 'true' %]
 
 <h3>[% l('Notification Preferences') %]</h3>
 
                         <td>[% INCLUDE "opac/parts/sms_carrier_selector.tt2" sms_carrier_hide_label="true" %]</td>
                     </tr>
                     [% setting = 'opac.default_sms_notify' %]
-                    <tr id="test_notification_banner" style="display:none">
-                        <td colspan="4">
-                            [% INCLUDE "opac/myopac/test_notification.tt2" message_type = "sms" %]
-                        </td>
-                    </tr>
                     <tr>
                         <td><label for='[% setting %]'>[% l('Default Mobile Number') %]</label></td>
                         <td>
                             <input onchange="record_change(event)" id='[% setting %]' name='[% setting %]' type="text"
                                 [% IF ctx.user_setting_map.$setting; %] value='[% ctx.user_setting_map.$setting | html %]' [% END %]/>
                             [% IF ctx.user_setting_map.$setting; %]
-                            <a href="#" onclick="sendTestSMS(
-                            [% ctx.user.id %], '[% ctx.authtoken %]'
-                            )"
-                            title="[% l('Send Test Text Message') %]">[% l('Send Test Text Message') %]</a><br />
+                                <span class='light_border'>
+                                <a href="#" class="btn btn-sm btn-action" onclick="sendTestSMS(
+                                    [% ctx.user.id %], '[% ctx.authtoken %]'
+                                    )"
+                                    title="[% l('Send Test Text Message') %]">
+                                    <i class="fas fa-mobile"></i> [% l('Send Test Text Message') %]
+                                </a>
+                                </span><br />
                             [% l('Hint: use the full 10 digits of your phone #, no spaces, no dashes'); %]
                             [% END %]
                         </td>
                     </tr>
                     [% END %]
+                    <tr id="test_notification_banner" style="display:none">
+                        <td colspan='3'>
+                            [% INCLUDE "opac/myopac/test_notification.tt2" message_type = "sms" %]
+                        </td>
+                    </tr>
                     [% FOR optin IN ctx.opt_in_settings %]
                     <tr>
                         <td><label for='[% optin.cust.name | uri %]'>[% optin.cust.label | html %]</label></td>
diff --git a/Open-ILS/src/templates-bootstrap/opac/myopac/test_notification.tt2 b/Open-ILS/src/templates-bootstrap/opac/myopac/test_notification.tt2
new file mode 100644 (file)
index 0000000..77ef5f5
--- /dev/null
@@ -0,0 +1,18 @@
+<div class="p-3 mb-2 bg-success text-white">
+    [% l('Message Sent') %]
+</div>
+<div class="p-3 mb-2 border border-success">
+    [% l('If you do not receive ') %] [% IF message_type == "email" %]
+        [% l('an email') %]
+    [% ELSIF message_type == "sms" %]
+        [% l('a text') %]
+    [% END %] [% l(' message, contact your library for more information.') %]
+    <br/>
+    [% ctx.user.home_ou.name %]<br/>
+    [%- IF ctx.user.home_ou.phone; %]
+        [% ctx.user.home_ou.phone %]<br/>
+    [%- END %]
+    [%- IF ctx.user.home_ou.email %]
+        [% ctx.user.home_ou.email %]<br/>
+    [%- END %]
+</div>
\ No newline at end of file
index f54b472..4bda61e 100755 (executable)
         want_dojo = 1;
     END;
 
+    # ... and for interfaces that require manual trigger of action triggers
+    IF can_call_action_trigger == 'true';
+        want_dojo = 1;
+    END;
+
     # Especially useful for image 'alt' tags and link title tags,
     # where the content may need to be unique (making it longer)
     # but should not exceed 75 chars for ideal screen reader support.
index 87b7752..74e5ff8 100755 (executable)
     [% INCLUDE "opac/parts/ebook_api/login_js.tt2" IF (ctx.page == 'login') %]
 [% END %]
 
+<script src='[% ctx.media_prefix %]/js/ui/default/opac/test_notification.js'></script>
+
 <!-- provide a JS friendly org unit hash -->
 <script >
 var aou_hash = {
index 30662e6..88085ae 100755 (executable)
     END;
 %]
 [% IF NOT sms_carrier_hide_label; '<label for="sms_carrier">' _ l('Mobile carrier:') _ '</label>'; END; %]
-<select onchange="record_change(event)" name="sms_carrier" id="sms_carrier" [% IF sms_carrier_hide_label; 'aria-label="' _ l('Mobile carrier') _ '"'; END; %]>
+<select onchange="record_change(event)" id="sms_carrier" name="sms_carrier" id="sms_carrier" [% IF sms_carrier_hide_label; 'aria-label="' _ l('Mobile carrier') _ '"'; END; %]>
     <option value="">[% l('Please select your mobile carrier') %]</option>
     [% FOR carrier IN carriers.sort('name','region') -%]
     <option value='[% carrier.id | html %]'[%
         default_carrier == carrier.id || ahr.sms_carrier == carrier.id ? ' selected="selected"' : ''
     %]>[% carrier.name | html %] ([% carrier.region | html %])</option>
     [% END -%]
-</select>
+</select><br/>
 [% IF NOT sms_carrier_hide_warning; l('Note: carrier charges may apply'); END; %]