re-adds the duplicate-barcode check that was lost with the new patron editor. TODO...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 7 Jun 2010 20:00:13 +0000 (20:00 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 7 Jun 2010 20:00:13 +0000 (20:00 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@16620 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index 4964d29..93a2129 100644 (file)
@@ -601,9 +601,25 @@ function attachWidgetEvents(fmcls, fmfield, widget) {
         if(fmfield == 'barcode') {
             dojo.connect(widget.widget, 'onChange',
                 function() {
-                    var un = findWidget('au', 'usrname');
-                    if(!un.widget.attr('value'))
-                        un.widget.attr('value', this.attr('value'));
+                    var barcode = this.attr('value');
+                    dojo.addClass(dojo.byId('uedit-dupe-barcode-warning'), 'hidden');
+                    fieldmapper.standardRequest(
+                        ['open-ils.actor', 'open-ils.actor.barcode.exists'],
+                        {
+                            params: [openils.User.authtoken, barcode],
+                            oncomplete : function(r) {
+                                var res = openils.Util.readResponse(r);
+                                if(res) {
+                                    dojo.removeClass(dojo.byId('uedit-dupe-barcode-warning'), 'hidden');
+                                } else {
+                                    dojo.addClass(dojo.byId('uedit-dupe-barcode-warning'), 'hidden');
+                                    var un = findWidget('au', 'usrname');
+                                    if(!un.widget.attr('value'))
+                                        un.widget.attr('value', barcode);
+                                }
+                            }
+                        }
+                    );
                 }
             );
             return;
index af67820..7f3506a 100644 (file)
@@ -1,7 +1,12 @@
 <tbody id='uedit-tbody'>
     <tr fmclass='ac' fmfield='barcode' required='required'>
         <td/><td/><td/>
-        <td><button dojoType='dijit.form.Button' jsId='replaceBarcode'>Replace Barcode</button></td>
+        <td>
+            <button dojoType='dijit.form.Button' jsId='replaceBarcode'>Replace Barcode</button>
+            <span id='uedit-dupe-barcode-warning' style='color:red; font-weight:bold' class='hidden'>
+                Barcode is already in use
+            </span>
+        </td>
         <td id='uedit-all-barcodes' class='hidden'>
             <button dojoType='dijit.form.Button' jsId='allCards'>See All</button>
         </td>