From 0c355ea9d8f5420efa138cd7b279fb1874ea265a Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 8 Dec 2015 16:17:40 -0500 Subject: [PATCH] LP#1452950 patron dupe search / plumbing Signed-off-by: Bill Erickson Signed-off-by: Galen Charlton --- .../src/templates/staff/circ/patron/t_edit.tt2 | 21 +++++++ .../web/js/ui/default/staff/circ/patron/regctl.js | 64 +++++++++++++++++++++- 2 files changed, 83 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 index 980ec0c470..419c23c3ef 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 @@ -79,6 +79,27 @@ + [% ELSIF field.match('phone') %] + + [% ELSIF field.match('ident_value') %] + + [% ELSIF field == 'first_given_name' OR field == 'family_name' %] + + [% ELSIF field == 'email' %] + + [% ELSIF field.match('street') OR field == 'city' %] + + [% ELSE %] diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js b/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js index 44f936ca03..739e09882a 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js @@ -373,6 +373,63 @@ angular.module('egCoreMod') }); } + service.dupe_patron_search = function(patron, type, value) { + var search; + + console.log('Dupe search called with "' + + type +"' and value " + value); + + switch (type) { + + // TODO hide dupe results links matching the type + // of the current search + + case 'name': + var fname = patron.first_given_name; + var lname = patron.family_name; + if (!(fname && lname)) return; + search = { + first_given_name : {value : fname, group : 0}, + family_name : {value : lname, group : 0} + }; + break; + + case 'email': + search = {email : {value : value, group : 0}}; + break; + + case 'ident': + search = {ident : {value : value, group : 2}}; + break; + + case 'phone': + search = {phone : {value : value, group : 2}}; + break; + + case 'address': + search = {}; + angular.forEach(['street1', 'street2', 'city', 'post_code'], + function(field) { + if(value[field]) + search[field] = {value : value[field], group: 1}; + } + ); + break; + } + + return egCore.net.request( + 'open-ils.actor', + 'open-ils.actor.patron.search.advanced', + egCore.auth.token(), search, null, null, 1 + ).then(function(res) { + + res = res.filter(function(id) {return id != patron.id}); + if (res.length == 0) return; + + console.log(js2JSON(res)); + }); + } + service.init_patron = function(current) { if (!current) @@ -481,8 +538,7 @@ angular.module('egCoreMod') var patron = egCore.idl.fromHash('au', phash); patron.home_ou(patron.home_ou().id()); - patron.expire_date( - patron.expire_date().toISOString().replace(/T.*/,'')); + patron.expire_date(patron.expire_date().toISOString()); patron.profile(patron.profile().id()); if (patron.dob()) patron.dob(patron.dob().toISOString().replace(/T.*/,'')); @@ -1037,6 +1093,10 @@ function PatronRegCtrl($scope, $routeParams, patronRegSvc.invalidate_field($scope.patron, field); } + $scope.dupe_value_changed = function(type, value) { + patronRegSvc.dupe_patron_search($scope.patron, type, value); + } + $scope.edit_passthru.save = function() { // toss the deleted addresses back into the patron's list of -- 2.11.0