LP#1723498 Patron reg/edit dupe search repairs
authorBill Erickson <berickxx@gmail.com>
Thu, 9 Nov 2017 15:46:50 +0000 (10:46 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 10 Nov 2017 21:43:13 +0000 (16:43 -0500)
Avoid clobbering duplicate patron search links by managing search URLs
individually by search type and displaying a search link per search
type.

This change includes an improvement over the XUL version in that a link
will be displayed per matching phone number so each can be searched,
instead of only searching the most recently entered phone number.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Terra McCanna <tmccanna@georgialibraries.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/templates/staff/circ/patron/t_edit.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js

index ce8da85..ce365ab 100644 (file)
     [%# dupe_search_encoded is uri escaped in the JS %]
     <div class="alert alert-danger" ng-show="dupe_counts.name">
       <a target="_blank"
-        href="/eg/staff/circ/patron/search?search={{dupe_search_encoded}}&inactive=1">
+        href="/eg/staff/circ/patron/search?search={{dupe_search_encoded.name}}&inactive=1">
       [% l('[_1] patron(s) with same name', '{{dupe_counts.name}}') %]
       </a>
     </div>
     <div class="alert alert-danger" ng-show="dupe_counts.email">
       <a target="_blank"
-        href="/eg/staff/circ/patron/search?search={{dupe_search_encoded}}">
+        href="/eg/staff/circ/patron/search?search={{dupe_search_encoded.email}}">
         [% l('[_1] patron(s) with same email', 
         '{{dupe_counts.email}}') %]</a>
     </div>
     <div class="alert alert-danger" ng-show="dupe_counts.ident">
       <a target="_blank" 
-        href="/eg/staff/circ/patron/search?search={{dupe_search_encoded}}">
+        href="/eg/staff/circ/patron/search?search={{dupe_search_encoded.ident}}">
         [% l('[_1] patron(s) with same identification', 
         '{{dupe_counts.ident}}') %]</a>
     </div>
-    <div class="alert alert-danger" ng-show="dupe_counts.phone">
+    <div class="alert alert-danger" ng-show="dupe_counts.day_phone">
       <a target="_blank" 
-        href="/eg/staff/circ/patron/search?search={{dupe_search_encoded}}">
+        href="/eg/staff/circ/patron/search?search={{dupe_search_encoded.day_phone}}">
+        [% l('[_1] patron(s) with same phone', 
+        '{{dupe_counts.phone}}') %]</a>
+    </div>
+    <div class="alert alert-danger" ng-show="dupe_counts.evening_phone">
+      <a target="_blank" 
+        href="/eg/staff/circ/patron/search?search={{dupe_search_encoded.evening_phone}}">
+        [% l('[_1] patron(s) with same phone', 
+        '{{dupe_counts.phone}}') %]</a>
+    </div>
+    <div class="alert alert-danger" ng-show="dupe_counts.other_phone">
+      <a target="_blank" 
+        href="/eg/staff/circ/patron/search?search={{dupe_search_encoded.other_phone}}">
         [% l('[_1] patron(s) with same phone', 
         '{{dupe_counts.phone}}') %]</a>
     </div>
     <div class="alert alert-danger" ng-show="dupe_counts.address">
       <a target="_blank" 
-        href="/eg/staff/circ/patron/search?search={{dupe_search_encoded}}" >
+        href="/eg/staff/circ/patron/search?search={{dupe_search_encoded.address}}" >
         [% l('[_1] patron(s) with same address', 
         '{{dupe_counts.address}}') %]</a>
     </div>
index adf5c71..b80e307 100644 (file)
@@ -553,6 +553,8 @@ angular.module('egCoreMod')
 
         console.log('Dupe search called with "'+ type +'" and value '+ value);
 
+        if (type.match(/phone/)) type = 'phone'; // day_phone, etc.
+
         switch (type) {
 
             case 'name':
@@ -1646,15 +1648,19 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore ,
     }
 
     $scope.dupe_value_changed = function(type, value) {
+        if (!$scope.dupe_search_encoded)
+            $scope.dupe_search_encoded = {};
+
         $scope.dupe_counts[type] = 0;
+
         patronRegSvc.dupe_patron_search($scope.patron, type, value)
         .then(function(res) {
             $scope.dupe_counts[type] = res.count;
             if (res.count) {
-                $scope.dupe_search_encoded = 
+                $scope.dupe_search_encoded[type] = 
                     encodeURIComponent(js2JSON(res.search));
             } else {
-                $scope.dupe_search_encoded = '';
+                $scope.dupe_search_encoded[type] = '';
             }
         });
     }
@@ -1729,7 +1735,7 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore ,
                 }
             case 'evening_phone' : 
             case 'other_phone' : 
-                $scope.dupe_value_changed('phone', value);
+                $scope.dupe_value_changed(field_name, value);
                 break;
 
             case 'ident_value':