LP1902265: implement per-hold notification updates in Bootstrap OPAC
authorGarry Collum <gcollum@gmail.com>
Tue, 10 Nov 2020 17:54:52 +0000 (12:54 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Mon, 8 Feb 2021 15:32:29 +0000 (10:32 -0500)
In the Bootstrap Opac:

* Adds a Notify Method column to the patron's hold list.
* Adds email, phone, and sms notifiction editing to the hold's
  edit screen.
* Also, adds <label> tags to the existing form fields in the edit
  page for accessibility and some bootstrappy form elements to
  format the appearance of the form.

The SMS fields do not appear unless the Library Setting for
"Enable features that send SMS text messages" is set to true.

To test work with the above OU setting off, and then on.

* Place holds for a patron with and without an email address.
* If a patron has a defualt SMS carrier, this carrier should pop up
  in the list by default.

Signed-off-by: Garry Collum <gcollum@gmail.com>
Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>

Open-ILS/src/templates-bootstrap/opac/myopac/holds.tt2
Open-ILS/src/templates-bootstrap/opac/myopac/holds/edit.tt2
Open-ILS/src/templates-bootstrap/opac/parts/hold_notify.tt2 [new file with mode: 0755]
Open-ILS/src/templates-bootstrap/opac/parts/sms_carrier_selector.tt2

index f95d9ae..07130d3 100755 (executable)
@@ -1,6 +1,7 @@
 [%  PROCESS "opac/parts/header.tt2";
     PROCESS "opac/parts/misc_util.tt2";
     PROCESS "opac/parts/hold_status.tt2";
+    PROCESS "opac/parts/hold_notify.tt2";
     PROCESS "opac/parts/myopac/column_sort_support.tt2";
     WRAPPER "opac/parts/myopac/base.tt2";
     myopac_page = "holds";
@@ -86,6 +87,7 @@
                 <th>[% l('Pickup Location') %]</th>
                 <th>[% l('Cancel if not filled by') %]</th>
                 <th>[% l('Status') %]</th>
+                <th>[% l('Notify Method') %]</th>
                 <th>[% l('Notes') %]</th>
                 <th>[% l('Edit') %]</th>
             </tr>
                             [% PROCESS get_hold_status hold=hold; %]
                         </div>
                     </td>
+                    <td>
+                    <span class="sr-only">Notify Method</span>
+                        <div>
+                            [% PROCESS get_hold_notify h=ahr; %]
+                        </div>
+                    </td>
                     <td class="hold_notes">
                     <span class="sr-only">Notes</span>
                     [%- FOREACH pubnote IN ahr.notes;
index e5212e5..603d9cf 100755 (executable)
         </div>
 
         <div class="row">
-            <div class="col-12">
+            <div class="col-12 mb-3">
             <strong>[% l('Status') %]</strong>: [% hold.human_status %]
             </div>
             <div class="col-12">
              <input type="hidden" name="action" value="edit" />
                             <input type="hidden" name="hold_id"
                                 value="[% ahr.id %]" />
-                            [% l('Pickup library') %]
+                            <div class="form-group">
+                            <label for="pickup_lib">[% l('Pickup library') %]</library>
 
                             [% INCLUDE build_org_selector
-                                name='pickup_lib' value=ahr.pickup_lib
+                                name='pickup_lib' id='pickup_lib' value=ahr.pickup_lib
                                 can_have_vols_only=1 hold_pickup_lib=1 %]
+                            </div>
             </div>
-            <div class="col-12">
+            <div class="col-sm-6">
             [% IF hold.hold.status < 3 OR hold.hold.status == 7 %]
                     [%# The following actions cannot be performed on holds that
                         have already been captured... %]
-
-                            [% l('Cancel unless filled by') %]
-
+                            
+                            <label for="expire_time">[% l('Cancel unless filled by') %]</label>
                             <div class="input-group date" data-provide="datepicker">
-                                <input type="text" class="form-control" name="expire_time"  value="[% expire_time | html %]" data-date-format="mm/dd/yyyy">
+                                <input type="text" class="form-control" id="expire_time" name="expire_time"
+                                    value="[% expire_time | html %]" data-date-format="mm/dd/yyyy">
                                 <div class="input-group-addon">
                                     <span class="glyphicon glyphicon-th"></span>
                                 </div>
                             </div>
-
-
-                            [% l('Active?') %]
-
-                            <select class="form-control" name="frozen">
-                                <option value="f"[% ahr.frozen == 't' ? '' :' selected="selected"' %]>
-                                    [% l('Yes, this hold is active now') %]
-                                </option>
-                                <option value="t"[% ahr.frozen == 't' ? ' selected="selected"' : '' %]>
-                                    [% l('No, this hold is suspended') %]
-                                </option>
-                            </select>
-
-                            [% l('If suspended, activate on') %]
-
-                         <div class="input-group date" data-provide="datepicker">
+                            <div class="form-group mt-2">
+                                <label for="frozen">[% l('Active?') %]</label>
+                                <select class="form-control" name="frozen" id="frozen">
+                                    <option value="f"[% ahr.frozen == 't' ? '' :' selected="selected"' %]>
+                                        [% l('Yes, this hold is active now') %]
+                                    </option>
+                                    <option value="t"[% ahr.frozen == 't' ? ' selected="selected"' : '' %]>
+                                        [% l('No, this hold is suspended') %]
+                                    </option>
+                                </select>
+                            </div>
+                            <label for="datepicker">[% l('If suspended, activate on') %]</label>
+                            <div class="input-group date" data-provide="datepicker">
                                 <input type="text" class="form-control" name="thaw_date" id="datepicker" value="[% thaw_date | html %]" data-date-format="mm/dd/yyyy">
                                 <div class="input-group-addon">
                                     <span class="glyphicon glyphicon-th"></span>
                                 </div>
                             </div>
 
+                        <div class="form-check mt-3">
+                            <input class="form-check-input" type="checkbox" name="email_notify" id="email_notify"
+                                [% IF ahr.email_notify == 't' %] checked [% END %] />
+                            <label class="form-check-label" for="email_notify">[% l('Email notification') %]</label>
+                        </div>
+
+                        <div class="form-group">
+                            <label for="phone_notify">[% l('Phone notification - Enter phone number') %]</label>
+                            <input type="text" class="form-control" name="phone_notify" id="phone_notify"
+                                value="[% ahr.phone_notify | html %]" />
+                        </div>
+
+                        [% IF ctx.get_org_setting(ctx.search_ou, 'sms.enable') == 1%]
+                        <div class="form-group">
+                            <label for="sms_notify">[% l('SMS notification - Enter mobile phone number') %]</label>
+                            <input onblur="check_sms_carrier(event)" type="text" class="form-control" name="sms_notify" id="sms_notify"
+                                value="[% ahr.sms_notify | html %]" />
+                        </div>
+                        <div class="form-group">
+                            <label for="sms_carrier">[% l('Mobile carrier') %]</label>
+                            [% INCLUDE "opac/parts/sms_carrier_selector.tt2" ahr, sms_carrier_hide_warning="true", sms_carrier_hide_label="true" %]
+                        </div>
+                        [% END %]
 
                     [% END %]
 
diff --git a/Open-ILS/src/templates-bootstrap/opac/parts/hold_notify.tt2 b/Open-ILS/src/templates-bootstrap/opac/parts/hold_notify.tt2
new file mode 100755 (executable)
index 0000000..46c8738
--- /dev/null
@@ -0,0 +1,28 @@
+[% BLOCK get_hold_notify %]
+    [% # get hash of sms carriers keyed by id:
+        temp = ctx.search_csc('active','t');
+        tcos = { '0' => 'None' };
+        FOR o IN temp;
+            id = o.id;
+            tcos.$id = o;
+        END;
+    %]
+    [% SET any_notify = 0 %]
+    <div>
+    [% IF h.email_notify == 't' %]
+        [% any_notify = 1 %]
+        <strong>[% l("Email") %]</strong>: [% l("Yes") %]<br/>
+    [% END %]
+    [% IF h.phone_notify %]
+        [% any_notify = 1 %]
+        <strong>[% l("Phone") %]</strong>: [% h.phone_notify | html %]<br/>
+    [% END %]
+    [% IF h.sms_notify %]
+        [% any_notify = 1, cid = h.sms_carrier; %]
+        <strong>[% l("SMS") %]</strong>: [% h.sms_notify | html %] ([% tcos.$cid.name() | html %])<br/>
+    [% END %]
+    [% UNLESS any_notify %]
+        <span class="text-danger">[% l("None") %]</span>
+    [% END %]
+    </div>
+[% END %]
index 95ba8ff..30662e6 100755 (executable)
     END;
 %]
 [% IF NOT sms_carrier_hide_label; '<label for="sms_carrier">' _ l('Mobile carrier:') _ '</label>'; END; %]
-<select name="sms_carrier" id="sms_carrier" [% IF sms_carrier_hide_label; 'aria-label="' _ l('Mobile carrier') _ '"'; END; %]>
+<select onchange="record_change(event)" 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 ? ' selected="selected"' : ''
+        default_carrier == carrier.id || ahr.sms_carrier == carrier.id ? ' selected="selected"' : ''
     %]>[% carrier.name | html %] ([% carrier.region | html %])</option>
     [% END -%]
 </select>