From 9f59c1b74d3e66b8e41c92a7bd3e70571c464f62 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Fri, 22 Jun 2018 11:19:14 -0400 Subject: [PATCH] 2-hold-request-fields-that-make-use-of-user-preferences For new requests (or edited requests when a user barcode is scanned), the user's preferences (if any) for hold notifications and pickup library will be used to set various fields in the request dialog. Signed-off-by: Jason Etheridge --- Open-ILS/examples/fm_IDL.xml | 9 +- .../src/templates/staff/acq/requests/t_edit.tt2 | 16 ++-- .../js/ui/default/staff/acq/services/requests.js | 97 +++++++++++++++++++--- 3 files changed, 102 insertions(+), 20 deletions(-) diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 0ce5f7a4c2..1671334928 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -2288,7 +2288,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - + @@ -2299,6 +2299,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + + + + + diff --git a/Open-ILS/src/templates/staff/acq/requests/t_edit.tt2 b/Open-ILS/src/templates/staff/acq/requests/t_edit.tt2 index d3868756c1..a62a2281fc 100644 --- a/Open-ILS/src/templates/staff/acq/requests/t_edit.tt2 +++ b/Open-ILS/src/templates/staff/acq/requests/t_edit.tt2 @@ -98,22 +98,26 @@ -
+
- + + ng-disabled="mode=='view'" + ng-model="request.phone_notify"/>
diff --git a/Open-ILS/web/js/ui/default/staff/acq/services/requests.js b/Open-ILS/web/js/ui/default/staff/acq/services/requests.js index f3f1302dbe..453a8f5a95 100644 --- a/Open-ILS/web/js/ui/default/staff/acq/services/requests.js +++ b/Open-ILS/web/js/ui/default/staff/acq/services/requests.js @@ -6,8 +6,8 @@ angular.module('egCoreMod') .factory('egAcqRequests', - ['$uibModal','$q','egCore','ngToast', -function($uibModal , $q , egCore , ngToast) { + ['$uibModal','$q','egCore','egOrg','ngToast', +function($uibModal , $q , egCore , egOrg , ngToast) { var service = {}; @@ -29,7 +29,13 @@ function($uibModal , $q , egCore , ngToast) { ,'request_type' ,'usr' ] - ,'au' : ['card','home_ou'] + ,'au' : [ + 'card' + ,'home_ou' + ,'mailing_address' + ,'billing_address' + ,'settings' + ] } }; @@ -53,7 +59,13 @@ function($uibModal , $q , egCore , ngToast) { ,'request_status' ,'usr' ] - ,'au' : ['card','home_ou'] + ,'au' : [ + 'card' + ,'home_ou' + ,'mailing_address' + ,'billing_address' + ,'settings' + ] } }; @@ -187,6 +199,9 @@ function($uibModal , $q , egCore , ngToast) { if (request.need_before) { request.need_before = new Date(request.need_before); } + if (request.phone_notify) { + $m_scope.extra.phone_notify = true; + } if (request.pickup_lib) { $m_scope.request.pickup_lib = egCore.idl.fromHash('aou',request.pickup_lib); @@ -250,18 +265,36 @@ function($uibModal , $q , egCore , ngToast) { flesh : 1, flesh_fields : { 'au' : [ - 'mailing_address' - ,'billing_address' + 'card' ,'home_ou' + ,'mailing_address' + ,'billing_address' + ,'settings' ] } }, { atomic : true } - ).then(function(usr) { - $m_scope.extra.user_obj = - egCore.idl.toHash(usr[0]); - $m_scope.request.usr = - $m_scope.extra.user_obj.id; + ).then(function(users) { + var usr = egCore.idl.toHash(users[0]); + $m_scope.extra.user_obj = usr; + $m_scope.request.usr = usr.id; + angular.forEach(usr.settings, function(s) { + if (s.name == 'opac.hold_notify') { + if (s.value.match('phone')) { + $m_scope.extra.phone_notify = true; + } + if (s.value.match('email')) { + $m_scope.request.email_notify = true; + } + } + if (s.name == 'opac.default_phone') { + $m_scope.request.phone_notify = s.value; + } + if (s.name == 'opac.default_pickup_location') { + $m_scope.request.pickup_lib = + egOrg.get(s.value); + } + }); }); }); } @@ -283,9 +316,44 @@ function($uibModal , $q , egCore , ngToast) { if (mode=='create') { var aur_obj = egCore.idl.toHash(new egCore.idl.aurs()); if (row['usr']) { - aur_obj.usr = row['usr']; + return egCore.pcrud.search('au', { + id : row['usr'] + }, { + flesh : 1, + flesh_fields : { + 'au' : [ + 'card' + ,'home_ou' + ,'mailing_address' + ,'billing_address' + ,'settings' + ] + } + }, + { atomic : true } + ).then(function(users) { + var usr = egCore.idl.toHash(users[0]); + aur_obj.usr = usr.id; + angular.forEach(usr.settings, function(s) { + if (s.name == 'opac.hold_notify') { + if (s.value.match('email')) { + aur_obj.email_notify = true; + } + } + if (s.name == 'opac.default_phone') { + aur_obj.phone_notify = s.value; + } + if (s.name == 'opac.default_pickup_location') { + aur_obj.pickup_lib = egCore.idl.toHash( + egOrg.get(s.value) + ); + } + }); + return aur_obj; + }); + } else { + return aur_obj; } - return aur_obj; } else { return egCore.pcrud.search('aurs', { id : row['id'] @@ -311,6 +379,9 @@ function($uibModal , $q , egCore , ngToast) { if (aur_obj.need_before() && typeof aur_obj.need_before() == 'object') { aur_obj.need_before( aur_obj.need_before().toISOString() ); } + if (!data.extra.phone_notify) { + aur_obj.phone_notify(null); + } if (mode=='create') { aur_obj.isnew('t'); aur_obj.pickup_lib( aur_obj.pickup_lib().id() ); -- 2.11.0