LP#1452950 patron dupe search links
authorBill Erickson <berickxx@gmail.com>
Wed, 9 Dec 2015 16:42:50 +0000 (11:42 -0500)
committerGalen Charlton <gmc@esilibrary.com>
Thu, 25 Feb 2016 22:31:58 +0000 (17:31 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Open-ILS/src/templates/staff/circ/patron/t_edit.tt2
Open-ILS/src/templates/staff/css/circ.css.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/app.js
Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js

index 419c23c..23e51d7 100644 (file)
   <div>{{selected_field_doc.string()}}</div>
 </fieldset>
 
+<div id="reg-dupe-links">
+    [%# dupe_search_encoded is uri escaped in the JS %]
+    <div>
+        <a target="_blank" ng-show="dupe_counts.name"
+            href="/eg/staff/circ/patron/search?search={{dupe_search_encoded}}" >
+        [% l('Found [_1] patron(s) with the same name', '{{dupe_counts.name}}') %]
+        </a>
+    </div>
+    <div>
+        <a target="_blank" ng-show="dupe_counts.email"
+            href="/eg/staff/circ/patron/search?search={{dupe_search_encoded}}" >
+            [% l('Found [_1] patron(s) with the same email address', 
+            '{{dupe_counts.email}}') %]</a>
+    </div>
+    <div>
+        <a target="_blank" ng-show="dupe_counts.ident"
+            href="/eg/staff/circ/patron/search?search={{dupe_search_encoded}}" >
+            [% l('Found [_1] patron(s) with the same identification', 
+            '{{dupe_counts.ident}}') %]</a>
+    </div>
+    <div>
+        <a target="_blank" ng-show="dupe_counts.phone"
+            href="/eg/staff/circ/patron/search?search={{dupe_search_encoded}}" >
+            [% l('Found [_1] patron(s) with the same phone number', 
+            '{{dupe_counts.phone}}') %]</a>
+    </div>
+    <div>
+        <a target="_blank" ng-show="dupe_counts.address"
+            href="/eg/staff/circ/patron/search?search={{dupe_search_encoded}}" >
+            [% l('Found [_1] patron(s) with the same address', 
+            '{{dupe_counts.address}}') %]</a>
+    </div>
+</div>
+
+
 [% MACRO formfield(cls, field, path, input_type) BLOCK;
 
   # input field generator for common text/number/checkbox fields
index efc04f7..80373bb 100644 (file)
@@ -110,6 +110,14 @@ but the ones I'm finding aren't quite cutting it..*/
     margin-top: 20px;
 }
 
+#reg-dupe-links {
+    position: fixed;
+    top:180px;
+    right:20px;
+    padding: 10px;
+    margin-top: 10px;
+}
+
 #reg-field-doc legend {
     /* otherwise the font size is quite large */
     font-size: 100%;
index 2cd7d9d..6a184ae 100644 (file)
@@ -793,11 +793,16 @@ function($scope,  $q,  $routeParams,  $timeout,  $window,  $location,  egCore,
 
     // Handle URL-encoded searches
     if ($location.search().search) {
+        console.log('URL search = ' + $location.search().search);
         patronSvc.urlSearch = {search : JSON2js($location.search().search)};
 
         // why the double-JSON encoded sort?
-        patronSvc.urlSearch.sort = 
-            JSON2js(patronSvc.urlSearch.search.search_sort);
+        if (patronSvc.urlSearch.search.search_sort) {
+            patronSvc.urlSearch.sort = 
+                JSON2js(patronSvc.urlSearch.search.search_sort);
+        } else {
+            patronSvc.urlSearch.sort = [];
+        }
         delete patronSvc.urlSearch.search.search_sort;
     }
 
index 739e098..ed016fc 100644 (file)
@@ -381,9 +381,6 @@ angular.module('egCoreMod')
 
         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;   
@@ -422,11 +419,11 @@ angular.module('egCoreMod')
             '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));
+            return {
+                count : res.length,
+                search : search
+            };
         });
     }
 
@@ -685,6 +682,7 @@ function PatronRegCtrl($scope, $routeParams,
     // for existing patrons, disable barcode input by default
     $scope.disable_bc = $scope.focus_usrname = Boolean($scope.patron_id);
     $scope.focus_bc = !Boolean($scope.patron_id);
+    $scope.dupe_counts = {};
 
     if (!$scope.edit_passthru) {
         // in edit more, scope.edit_passthru is delivered to us by
@@ -1094,7 +1092,13 @@ function PatronRegCtrl($scope, $routeParams,
     }
 
     $scope.dupe_value_changed = function(type, value) {
-        patronRegSvc.dupe_patron_search($scope.patron, type, value);
+        $scope.dupe_counts[type] = 0;
+        patronRegSvc.dupe_patron_search($scope.patron, type, value)
+        .then(function(res) {
+            $scope.dupe_counts[type] = res.count;
+            $scope.dupe_search_encoded = 
+                encodeURIComponent(js2JSON(res.search));
+        });
     }
 
     $scope.edit_passthru.save = function() {