[open-ils-commits] r16719 - in trunk/Open-ILS/web: js/ui/default/actor/user templates/default/actor/user (phasefx)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Jun 15 00:01:26 EDT 2010
Author: phasefx
Date: 2010-06-15 00:01:23 -0400 (Tue, 15 Jun 2010)
New Revision: 16719
Modified:
trunk/Open-ILS/web/js/ui/default/actor/user/register.js
trunk/Open-ILS/web/templates/default/actor/user/register.tt2
Log:
in patron editor, prevent Save and Save & Clone from working with an invalid form, or duplicate barcode or usrname
Modified: trunk/Open-ILS/web/js/ui/default/actor/user/register.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/actor/user/register.js 2010-06-14 20:20:31 UTC (rev 16718)
+++ trunk/Open-ILS/web/js/ui/default/actor/user/register.js 2010-06-15 04:01:23 UTC (rev 16719)
@@ -44,6 +44,8 @@
var optInSettings;
var allCardsTemplate;
+var dupeUsrname = false;
+var dupeBarcode = false;
if(!window.xulG) var xulG = null;
@@ -602,6 +604,7 @@
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 @@
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 @@
var usrname = input.widget.attr('value');
if(!usrname) {
+ dupeUsrname = false;
dojo.addClass(dojo.byId('uedit-dupe-username-warning'), 'hidden');
return;
}
@@ -647,8 +653,10 @@
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 _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);
Modified: trunk/Open-ILS/web/templates/default/actor/user/register.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/actor/user/register.tt2 2010-06-14 20:20:31 UTC (rev 16718)
+++ trunk/Open-ILS/web/templates/default/actor/user/register.tt2 2010-06-15 04:01:23 UTC (rev 16719)
@@ -86,9 +86,16 @@
</style>
-<table>
- [% INCLUDE default/actor/user/register_table.tt2 %]
-</table>
+<div dojoType="dijit.form.Form" id="myForm" jsId="myForm" encType="multipart/form-data" action="" method="">
+ <script type="dojo/method" event="onSubmit">
+ /* we don't want to use the form action, but uEditSave and UEditSaveClone from the Save buttons. We
+ do want to use the Form's validation features, which we do from within UEditSave, etc. */
+ return false;
+ </script>
+ <table>
+ [% INCLUDE default/actor/user/register_table.tt2 %]
+ </table>
+</div>
<div id='uedit-save-div'>
<button dojoType='dijit.form.Button' jsId='saveButton' onClick='uEditSave'>Save</button>
More information about the open-ils-commits
mailing list