From: phasefx Date: Tue, 15 Jun 2010 04:01:23 +0000 (+0000) Subject: in patron editor, prevent Save and Save & Clone from working with an invalid form... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=6a866d67af63bf53d4f6d0ac91265331ed40983a;p=evergreen%2Ftadl.git in patron editor, prevent Save and Save & Clone from working with an invalid form, or duplicate barcode or usrname git-svn-id: svn://svn.open-ils.org/ILS/trunk@16719 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/js/ui/default/actor/user/register.js b/Open-ILS/web/js/ui/default/actor/user/register.js index 1979f91cd1..4f5593eb63 100644 --- a/Open-ILS/web/js/ui/default/actor/user/register.js +++ b/Open-ILS/web/js/ui/default/actor/user/register.js @@ -44,6 +44,8 @@ var stageUser; var optInSettings; var allCardsTemplate; +var dupeUsrname = false; +var dupeBarcode = false; if(!window.xulG) var xulG = null; @@ -602,6 +604,7 @@ function attachWidgetEvents(fmcls, fmfield, widget) { dojo.connect(widget.widget, 'onChange', function() { var barcode = this.attr('value'); + dupeBarcode = false; dojo.addClass(dojo.byId('uedit-dupe-barcode-warning'), 'hidden'); fieldmapper.standardRequest( ['open-ils.actor', 'open-ils.actor.barcode.exists'], @@ -610,8 +613,10 @@ function attachWidgetEvents(fmcls, fmfield, widget) { oncomplete : function(r) { var res = openils.Util.readResponse(r); if(res == '1') { + dupeBarcode = true; dojo.removeClass(dojo.byId('uedit-dupe-barcode-warning'), 'hidden'); } else { + dupeBarcode = false; dojo.addClass(dojo.byId('uedit-dupe-barcode-warning'), 'hidden'); var un = findWidget('au', 'usrname'); if(!un.widget.attr('value')) @@ -636,6 +641,7 @@ function attachWidgetEvents(fmcls, fmfield, widget) { var usrname = input.widget.attr('value'); if(!usrname) { + dupeUsrname = false; dojo.addClass(dojo.byId('uedit-dupe-username-warning'), 'hidden'); return; } @@ -647,8 +653,10 @@ function attachWidgetEvents(fmcls, fmfield, widget) { oncomplete : function(r) { var res = openils.Util.readResponse(r); if(res) { + dupeUsrname = true; dojo.removeClass(dojo.byId('uedit-dupe-username-warning'), 'hidden'); } else { + dupeUsrname = false; dojo.addClass(dojo.byId('uedit-dupe-username-warning'), 'hidden'); } } @@ -953,6 +961,11 @@ function uEditSaveClone() { _uEditSave(true); } function _uEditSave(doClone) { + if ( (! myForm.isValid()) || dupeUsrname || dupeBarcode ) { + alert('Form is invalid. Please edit and try again.'); + return; + } + for(var idx in widgetPile) { var w = widgetPile[idx]; var val = uEditWidgetVal(w); diff --git a/Open-ILS/web/templates/default/actor/user/register.tt2 b/Open-ILS/web/templates/default/actor/user/register.tt2 index 431cdea89e..2300b13e47 100644 --- a/Open-ILS/web/templates/default/actor/user/register.tt2 +++ b/Open-ILS/web/templates/default/actor/user/register.tt2 @@ -86,9 +86,16 @@ - - [% INCLUDE default/actor/user/register_table.tt2 %] -
+
+ + + [% INCLUDE default/actor/user/register_table.tt2 %] +
+