[open-ils-commits] [GIT] Evergreen ILS branch rel_2_11 updated. 68e4457925d14b2eb263cef58d2600c73185ac49

Evergreen Git git at git.evergreen-ils.org
Wed Aug 23 11:09:28 EDT 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, rel_2_11 has been updated
       via  68e4457925d14b2eb263cef58d2600c73185ac49 (commit)
       via  38393989ea24fe2265248c34e225cc871cb6b461 (commit)
      from  812946e5f8e1ff41a5640564b7c126272942fb75 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 68e4457925d14b2eb263cef58d2600c73185ac49
Author: Cesar Velez <cesar.velez at equinoxinitiative.org>
Date:   Tue May 23 16:36:44 2017 -0400

    LP#1098685: Require OPAC patron holds w/ phone/SMS notification to enter that info
    
    This provides some plain vanilla JS form validation, and error feedback
    using a yellow background color on the culprit input field.
    
    Signed-off by: Cesar Velez <cesar.velez at equinoxinitiative.org>
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>
    
    Signed-off-by: Chris Sharp <csharp at georgialibraries.org>
    
    Conflicts:
    	Open-ILS/src/templates/opac/parts/js.tt2
    
    Signed-off-by: Jason Etheridge <jason at EquinoxInitiative.org>

diff --git a/Open-ILS/src/templates/opac/parts/js.tt2 b/Open-ILS/src/templates/opac/parts/js.tt2
index 2fc0a4f..191f2cb 100644
--- a/Open-ILS/src/templates/opac/parts/js.tt2
+++ b/Open-ILS/src/templates/opac/parts/js.tt2
@@ -59,6 +59,16 @@
     IF CGI.https; url = url.replace('^http:', 'https:'); END; %]
 <script type='text/javascript' id='EIT' src='[% url %]'></script>
 [%- END %]
+[%- IF ctx.page == 'record' AND ctx.google_books_preview %]
+<script src='[% ctx.media_prefix %]/js/ui/default/opac/ac_google_books.js[% ctx.cache_key %]' async defer></script>
+[%- END %]
+
+<!-- Require some inputs and selections for browsers that don't support required form field element -->
+[% IF ctx.page == 'place_hold' %]
+  <script type="text/javascript" src="[% ctx.media_prefix %]/js/ui/default/opac/holds-validation.js[% ctx.cache_key %]">
+  </script>
+[% END %]
+
 [%- IF want_dojo; -%]
 <script type="text/javascript">
      var djConfig = {
@@ -122,28 +132,5 @@ var aou_hash = {
 };
 </script>
 
-<!-- Require radio parts selection for browsers that don't support required form field element -->
-[% IF ctx.page == 'place_hold' %]
-  <script type="text/javascript">
-    function validateRadioSelection (radios) {
-       for (i = 0; i < radios.length; ++ i)
-       {
-         if (radios[i].checked) return true;
-       }
-       return false;
-    }
-    function validateHoldForm() {
-      if (validateRadioSelection (document.getElementsByName("part")))
-      {
-        return true;
-       }
-       else
-       {
-          alert ("Please select a part");
-          return false;
-        }
-     }
-  </script>
-[% END %]
-
+<script type="text/javascript">if ($('client_tz_id')) { $('client_tz_id').value = OpenSRF.tz }</script>
 [%- END; # want_dojo -%]
diff --git a/Open-ILS/src/templates/opac/parts/place_hold.tt2 b/Open-ILS/src/templates/opac/parts/place_hold.tt2
index 8b898d8..186c6f4 100644
--- a/Open-ILS/src/templates/opac/parts/place_hold.tt2
+++ b/Open-ILS/src/templates/opac/parts/place_hold.tt2
@@ -23,7 +23,7 @@
               ELSE; some_holds_allowed = 1; END;
             END %]
       
-    <form method="post" name="PlaceHold" [% IF hdata.parts.size > 0 AND enable.radio.parts == 'true' %] onsubmit="return validateHoldForm()" [% END %] >
+    <form method="post" name="PlaceHold" onsubmit="return validateHoldForm()" >
         <input type="hidden" name="hold_type" value="[% CGI.param('hold_type') | html %]" />
         [%  
             redirect = CGI.param('hold_source_page') || CGI.param('redirect_to') || CGI.referer;
@@ -175,7 +175,7 @@
         <p>
             [% l('Notify when hold is ready for pickup?') %]
             <blockquote>
-                <input type="checkbox" id="email_notify" name="email_notify" value="t"
+                <input class="hold-alert-method" type="checkbox" id="email_notify" name="email_notify" value="t"
                     [% IF !ctx.user.email %]disabled="true"[% ELSIF ctx.default_email_notify %]checked="checked"[% END %]/>
                     <label for="email_notify">[% l('Yes, by Email') %]</label><br/>
                 <blockquote>
@@ -183,7 +183,7 @@
                      ELSE; l('Email Address:') %] <span name="email_address">[% ctx.user.email %]</span>[% END %]
                 </blockquote>
                 [%- IF allow_phone_notifications == 'true' %]
-                <input type="checkbox" id="phone_notify_checkbox" name="phone_notify_checkbox"
+                <input class="hold-alert-method" type="checkbox" id="phone_notify_checkbox" name="phone_notify_checkbox"
                     [% IF ctx.default_phone_notify %]checked="checked"[% END %]/>
                     <label for="phone_notify_checkbox">[% l('Yes, by Phone') %]</label><br/>
                 <blockquote>
@@ -193,7 +193,7 @@
                 </blockquote>
                 [%- END -%]
                 [% IF ctx.get_org_setting(ctx.search_ou, 'sms.enable') == 1 %]
-                <input type="checkbox" id="sms_notify_checkbox" name="sms_notify_checkbox"
+                <input class="hold-alert-method" type="checkbox" id="sms_notify_checkbox" name="sms_notify_checkbox"
                     [% IF ctx.default_sms_notify %]checked="checked"[% END %]/>
                     <label for="sms_notify_checkbox">[% l('Yes, by Text Messaging') %]</label><br/>
                 <blockquote>
diff --git a/Open-ILS/web/js/ui/default/opac/holds-validation.js b/Open-ILS/web/js/ui/default/opac/holds-validation.js
new file mode 100644
index 0000000..842366c
--- /dev/null
+++ b/Open-ILS/web/js/ui/default/opac/holds-validation.js
@@ -0,0 +1,76 @@
+/* JS form validation for holds page alert methods */
+function resetBackgrounds(names){
+    for (var key in names) {
+        if (names.hasOwnProperty(key)) {
+            var l = document.getElementsByName(names[key]);
+            if (l.length > 0) {
+                l[0].style.backgroundColor  = "";
+            }
+        }
+    }
+}
+
+function validateMethodSelections (alertMethodCboxes) {
+    var needsPhone = false;
+    var hasPhone = false;
+    
+    var needsEmail = false;
+    var hasEmail = false;
+    
+    var needsSms = false;
+    var hasSms = false;
+    var inputNames = { e: "email_address", ph: "phone_notify", sms: "sms_notify", carrier: "sms_carrier"};
+    resetBackgrounds(inputNames);
+
+    //Array.from(alertMethodCboxes).forEach(function(cbox){
+    for (var i = 0; i < alertMethodCboxes.length; i++){
+        var cbox = alertMethodCboxes[i];
+        if (cbox.checked && !cbox.disabled) {
+            switch(cbox.id){
+                case "email_notify_checkbox":
+                    needsEmail = true;
+                    hasEmail = document.getElementsByName(inputNames.e)[0].innerHTML !== "";
+                    break;
+                case "phone_notify_checkbox":
+                    needsPhone = true;
+                    hasPhone = document.getElementsByName(inputNames.ph)[0].value !== "";
+                    break;
+                case "sms_notify_checkbox":
+                    needsSms = true;
+                    var smsNumInput = document.getElementsByName(inputNames.sms)[0];
+                    hasSms = document.getElementsByName(inputNames.carrier)[0].value !== "" && smsNumInput.value !== ""; // todo: properly validate phone nums
+                break;
+            }
+        }
+    }
+    
+    var culprits = [];
+    var emailOK = (needsEmail && hasEmail) || (!needsEmail);
+    var phoneOK = needsPhone && hasPhone || (!needsPhone);
+    var smsOK = needsSms && hasSms || (!needsSms);
+    
+    if (!phoneOK) {
+        culprits.push("phone_notify");
+    }
+    if (!smsOK) {
+        culprits.push("sms_notify", "sms_carrier");
+    }
+    
+    var isFormOK = emailOK && phoneOK && smsOK;
+    return { isValid: isFormOK, culpritNames : culprits };
+}
+
+function validateHoldForm() {
+    var res = validateMethodSelections(document.getElementsByClassName("hold-alert-method"));
+    if (res.isValid)
+    {
+        return true;
+    } else {
+        alert ("Please complete hold notification method info.");
+        res.culpritNames.forEach(function(n){
+            document.getElementsByName(n)[0].style.backgroundColor  = "yellow";
+        });
+        return false;
+    }
+}
+

commit 38393989ea24fe2265248c34e225cc871cb6b461
Author: Cesar Velez <cesar.velez at equinoxinitiative.org>
Date:   Tue May 23 09:58:39 2017 -0400

    LP#1669534 - OPAC hold request should not default to first SMS carrier
    
    Added empty <option> tag to address this and related form validation issues.
    
    To test
    -------
    [0] Ensure that SMS messaging is enabled.
    [1] Apply the patch and go to the place hold form in the public
        catalog. Verify that no mobile carrier is selected.
    [2] Set the default SMS carrier and number for the user account
        and go back to the place hold form. Verify that the user's
        default carrier and number appear in the form.
    
    Signed-off by: Cesar Velez <cesar.velez at equinoxinitiative.org>
    Signed-off-by: Chris Sharp <csharp at georgialibraries.org>
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>
    
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>
    Signed-off-by: Jason Etheridge <jason at EquinoxInitiative.org>

diff --git a/Open-ILS/src/templates/opac/parts/sms_carrier_selector.tt2 b/Open-ILS/src/templates/opac/parts/sms_carrier_selector.tt2
index 919ba07..1f66d15 100644
--- a/Open-ILS/src/templates/opac/parts/sms_carrier_selector.tt2
+++ b/Open-ILS/src/templates/opac/parts/sms_carrier_selector.tt2
@@ -19,6 +19,7 @@
 %]
 [% IF NOT sms_carrier_hide_label; l('Mobile carrier:'); END; %]
 <select name="sms_carrier">
+    <option value="">[% l('') %]</option>
     [% FOR carrier IN carriers.sort('name','region') -%]
     <option value='[% carrier.id | html %]'[%
         default_carrier == carrier.id ? ' selected="selected"' : ''

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/src/templates/opac/parts/js.tt2           |   35 +++------
 Open-ILS/src/templates/opac/parts/place_hold.tt2   |    8 +-
 .../templates/opac/parts/sms_carrier_selector.tt2  |    1 +
 .../web/js/ui/default/opac/holds-validation.js     |   76 ++++++++++++++++++++
 4 files changed, 92 insertions(+), 28 deletions(-)
 create mode 100644 Open-ILS/web/js/ui/default/opac/holds-validation.js


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list