[open-ils-commits] [GIT] Evergreen ILS branch rel_2_12 updated. f2b584ece6fd48a9b52106f6bc28f48ccf78af3a

Evergreen Git git at git.evergreen-ils.org
Fri Aug 25 13:37:31 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_12 has been updated
       via  f2b584ece6fd48a9b52106f6bc28f48ccf78af3a (commit)
      from  81b26198f1ad2c79c0cb872c05892dc1f3ce0030 (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 f2b584ece6fd48a9b52106f6bc28f48ccf78af3a
Author: Jeff Davis <jdavis at sitka.bclibraries.ca>
Date:   Tue Aug 22 12:39:10 2017 -0700

    LP#1684988: add opt-in check to patron service (2.12 edition)
    
    Signed-off-by: Jeff Davis <jdavis at sitka.bclibraries.ca>
    Signed-off-by: Jason Etheridge <jason at EquinoxInitiative.org>

diff --git a/Open-ILS/src/templates/staff/base_js.tt2 b/Open-ILS/src/templates/staff/base_js.tt2
index 1054c05..aba981e 100644
--- a/Open-ILS/src/templates/staff/base_js.tt2
+++ b/Open-ILS/src/templates/staff/base_js.tt2
@@ -87,6 +87,9 @@
     s.OP_CHANGE_PERM_MESSAGE = "[% l('Another staff member with the above permission may authorize this specific action.  Please notify your library administrator if you need this permission.  If you feel you have received this exception in error, please inform your friendly Evergreen developers or helpdesk staff of the above permission.') %]";
     s.PERM_OP_CHANGE_SUCCESS = "[% l('Permission Override Login Succeeded') %]";
     s.PERM_OP_CHANGE_FAILURE = "[% l('Permission Override Login Failed') %]";
+    s.OPT_IN_DIALOG_TITLE = "[% l('Verify Permission to Share Personal Information') %]";
+    s.OPT_IN_DIALOG = "[% l('Does patron [_1], [_2] from [_3] ([_4]) consent to having their personal information shared with your library?', '{{family_name}}', '{{first_given_name}}', '{{org_name}}', '{{org_shortname}}') %]";
+    s.OPT_IN_RESTRICTED = "[% l("This patron's record is not viewable at your library.") %]";
   }]);
 </script>
 
diff --git a/Open-ILS/src/templates/staff/circ/patron/index.tt2 b/Open-ILS/src/templates/staff/circ/patron/index.tt2
index 2589306..a50d655 100644
--- a/Open-ILS/src/templates/staff/circ/patron/index.tt2
+++ b/Open-ILS/src/templates/staff/circ/patron/index.tt2
@@ -51,8 +51,6 @@ angular.module('egCoreMod').run(['egStrings', function(s) {
   s.PAYMENT_OVER_MAX = "[% l('Payments over $[_1] are denied by policy.', '{{max_amount}}') %]";
   s.PATRON_NOTE_DELETE_CONFIRM_TITLE = "[% l('Delete Note?') %]";
   s.PATRON_NOTE_DELETE_CONFIRM = "[% l('Delete the note titled \"[_1]\" created on [_2]?', '{{note_title}}', '{{create_date | date}}') %]";
-  s.OPT_IN_DIALOG_TITLE = "[% l('Verify Permission to Share Personal Information') %]";
-  s.OPT_IN_DIALOG = "[% l('Does patron [_1], [_2] from [_3] ([_4]) consent to having their personal information shared with your library?', '{{family_name}}', '{{first_given_name}}', '{{org_name}}', '{{org_shortname}}') %]";
   s.PATRON_EDIT_COLLISION = "[% l('Patron record was modified by another user while you were editing it. Your changes were not saved; please reapply them.') %]";
 }]);
 </script>
diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js
index fe126d4..fe7901d 100644
--- a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js
+++ b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js
@@ -227,8 +227,8 @@ angular.module('egPatronApp', ['ngRoute', 'ui.bootstrap',
  * Patron service
  */
 .factory('patronSvc',
-       ['$q','$timeout','$location','egCore','egUser','$locale',
-function($q , $timeout , $location , egCore,  egUser , $locale) {
+       ['$q','$timeout','$location','egCore','egUser','egConfirmDialog','$locale',
+function($q , $timeout , $location , egCore,  egUser , egConfirmDialog , $locale) {
 
     var service = {
         // cached patron search results
@@ -344,9 +344,17 @@ function($q , $timeout , $location , egCore,  egUser , $locale) {
             }
 
             service.resetPatronLists();
-            service.current = user;
-            service.localFlesh(user);
-            return service.fetchUserStats();
+
+            return service.checkOptIn(user).then(
+                function() {
+                    service.current = user;
+                    service.localFlesh(user);
+                    return service.fetchUserStats();
+                },
+                function() {
+                    return $q.reject();
+                }
+            );
 
         } else if (id) {
             if (!force && service.current && service.current.id() == id) {
@@ -361,9 +369,16 @@ function($q , $timeout , $location , egCore,  egUser , $locale) {
 
             return egUser.get(id).then(
                 function(user) {
-                    service.current = user;
-                    service.localFlesh(user);
-                    return service.fetchUserStats();
+                    return service.checkOptIn(user).then(
+                        function() {
+                            service.current = user;
+                            service.localFlesh(user);
+                            return service.fetchUserStats();
+                        },
+                        function() {
+                            return $q.reject();
+                        }
+                    );
                 },
                 function(err) {
                     console.error(
@@ -572,6 +587,59 @@ function($q , $timeout , $location , egCore,  egUser , $locale) {
         });
     }
 
+    service.createOptIn = function(user_id) {
+        return egCore.net.request(
+            'open-ils.actor',
+            'open-ils.actor.user.org_unit_opt_in.create',
+            egCore.auth.token(), user_id);
+    }
+
+    service.checkOptIn = function(user) {
+        var deferred = $q.defer();
+        egCore.net.request(
+            'open-ils.actor',
+            'open-ils.actor.user.org_unit_opt_in.check',
+            egCore.auth.token(), user.id())
+        .then(function(optInResp) {
+            if (eg_evt = egCore.evt.parse(optInResp)) {
+                deferred.reject();
+                console.log('error on opt-in check: ' + eg_evt);
+            } else if (optInResp == 2) {
+                // opt-in disallowed at this location by patron's home library
+                deferred.reject();
+                alert(egCore.strings.OPT_IN_RESTRICTED);
+            } else if (optInResp == 1) {
+                // opt-in handled or not needed, do nothing
+                deferred.resolve();
+            } else {
+                // opt-in needed, show the opt-in dialog
+                var org = egCore.org.get(user.home_ou());
+                egConfirmDialog.open(
+                    egCore.strings.OPT_IN_DIALOG_TITLE,
+                    egCore.strings.OPT_IN_DIALOG,
+                    {   family_name : user.family_name(),
+                        first_given_name : user.first_given_name(),
+                        org_name : org.name(),
+                        org_shortname : org.shortname(),
+                        ok : function() {
+                            service.createOptIn(user.id())
+                            .then(function(resp) {
+                                if (evt = egCore.evt.parse(resp)) {
+                                    deferred.reject();
+                                    alert(evt);
+                                } else {
+                                    deferred.resolve();
+                                }
+                            });
+                        },
+                        cancel : function() { deferred.reject(); }
+                    }
+                );
+            }
+        });
+        return deferred.promise;
+    }
+
     // Avoid using parens [e.g. (1.23)] to indicate negative numbers, 
     // which is the Angular default.
     // http://stackoverflow.com/questions/17441254/why-angularjs-currency-filter-formats-negative-numbers-with-parenthesis

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

Summary of changes:
 Open-ILS/src/templates/staff/base_js.tt2           |    3 +
 Open-ILS/src/templates/staff/circ/patron/index.tt2 |    2 -
 .../web/js/ui/default/staff/circ/patron/app.js     |   84 ++++++++++++++++++--
 3 files changed, 79 insertions(+), 10 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list