finished dupe patron search plugin
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 11 Jun 2009 15:15:57 +0000 (15:15 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 11 Jun 2009 15:15:57 +0000 (15:15 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@13369 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/ui/default/actor/user/register.js
Open-ILS/web/templates/default/actor/user/register.tt2

index 5a434b0..bffd23e 100644 (file)
@@ -367,6 +367,7 @@ function uEditDupeSearch(type, value) {
     switch(type) {
 
         case 'name':
+            openils.Util.hide('uedit-dupe-names-link');
             var fname = findWidget('au', 'first_given_name').widget.attr('value');
             var lname = findWidget('au', 'family_name').widget.attr('value');
             if( !(fname && lname) ) return;
@@ -377,10 +378,12 @@ function uEditDupeSearch(type, value) {
             break;
 
         case 'email':
+            openils.Util.hide('uedit-dupe-email-link');
             search = {email : {value : value, group : 0}};
             break;
 
         case 'ident':
+            openils.Util.hide('uedit-dupe-ident-link');
             search = {ident : {value : value, group : 2}};
             break;
     }
@@ -391,7 +394,34 @@ function uEditDupeSearch(type, value) {
             params: [openils.User.authtoken, search],
             oncomplete : function(r) {
                 var resp = openils.Util.readResponse(r);
-                console.log(js2JSON(resp));
+
+                if(resp && resp.length > 0) {
+                    openils.Util.hide('uedit-help-div');
+                    openils.Util.show('uedit-dupe-div');
+                    var link;
+                    switch(type) {
+                        case 'name':
+                            link = dojo.byId('uedit-dupe-names-link');
+                            link.innerHTML = 'Found ' + resp.length + ' patrons with the same name';
+                            break;
+                        case 'email':
+                            link = dojo.byId('uedit-dupe-email-link');
+                            link.innerHTML = 'Found ' + resp.length + ' patrons with the same email';
+                            break;
+                        case 'ident':
+                            link = dojo.byId('uedit-dupe-ident-link');
+                            link.innerHTML = 'Found ' + resp.length + ' patrosn with the same identification';
+                            break;
+                    }
+
+                    openils.Util.show(link);
+                    link.onclick = function() {
+                        if(window.xulG)
+                            window.xulG.spawn_search(search);
+                        else
+                            console.log("running XUL patron search " + js2JSON(search));
+                    }
+                }
             }
         }
     );
@@ -403,7 +433,8 @@ function getByName(node, name) {
 
 
 function ueLoadContextHelp(fmcls, fmfield) {
-    openils.Util.removeCSSClass(dojo.byId('uedit-help-div'), 'hidden');
+    openils.Util.hide('uedit-dupe-div');
+    openils.Util.show('uedit-help-div');
     dojo.byId('uedit-help-field').innerHTML = fieldmapper.IDL.fmclasses[fmcls].field_map[fmfield].label;
     dojo.byId('uedit-help-text').innerHTML = fieldDoc[fmcls][fmfield].string();
 }
index 99867c1..101cdde 100644 (file)
         font-weight: bold;
         padding: 20px;
     }
+
+    #uedit-dupe-div {
+        position: fixed;
+        top:124px;
+        right:30px;
+        width:300px;
+        border:2px dashed #d9e8f9;
+        -moz-border-radius: 10px;
+        font-weight: bold;
+        padding: 20px;
+    }
+
     .uedit-help {
         width: 25px;
         border:1px solid #e0e0e0;
     <div id='uedit-help-text'/>
 </fieldset>
 
+<!-- duplicate patron search results -->
+<div id='uedit-dupe-div' class='hidden'>
+    <div><a href='javascript:void(0);' id='uedit-dupe-names-link'></a></div>
+    <div><a href='javascript:void(0);' id='uedit-dupe-email-link'></a></div>
+    <div><a href='javascript:void(0);' id='uedit-dupe-ident-link'></a></div>
+</div>
+
 [% END %]