From faf5f99f55357c0d790fb6acc187a9e230274b98 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 18 Feb 2009 17:15:13 +0000 Subject: [PATCH] added onchange to copy new barcodes into usrname field git-svn-id: svn://svn.open-ils.org/ILS/trunk@12218 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../web/js/ui/default/actor/user/register.js | 34 ++++++++++++++----- .../templates/default/actor/user/register.tt2 | 4 +-- 2 files changed, 28 insertions(+), 10 deletions(-) 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 6cff108ea9..7e4842d662 100644 --- a/Open-ILS/web/js/ui/default/actor/user/register.js +++ b/Open-ILS/web/js/ui/default/actor/user/register.js @@ -180,28 +180,46 @@ function fleshFMRow(row, fmcls, args) { widget._fmfield = fmfield; widget._addr = args.addr; widgetPile.push(widget); - attachEvents(fmcls, fmfield, widget); + attachWidgetEvents(fmcls, fmfield, widget); return widget; } -function attachEvents(fmcls, fmfield, widget) { +function findWidget(wtype, fmfield) { + return widgetPile.filter( + function(i){ + return (i._wtype == wtype && i._fmfield == fmfield); + } + ).pop(); +} + +function attachWidgetEvents(fmcls, fmfield, widget) { + + if(fmcls == 'ac') { + 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')); + } + ); + } + } + if(fmcls == 'au') { switch(fmfield) { case 'profile': // when the profile changes, update the expire date dojo.connect(widget.widget, 'onChange', function() { - - var expireWidget = widgetPile.filter( - function(i){return (i._fmfield == 'expire_date')})[0]; var self = this; - + var expireWidget = findWidget('au', 'expire_date'); function found(items) { if(items.length == 0) return; var item = items[0]; var interval = self.store.getValue(item, 'perm_interval'); - expireWidget.widget.attr('value', - dojo.date.add(new Date(), 'second', openils.Util.intervalToSeconds(interval))); + expireWidget.widget.attr('value', dojo.date.add(new Date(), + 'second', openils.Util.intervalToSeconds(interval))); } this.store.fetch({onComplete:found, query:{id:this.attr('value')}}); } diff --git a/Open-ILS/web/templates/default/actor/user/register.tt2 b/Open-ILS/web/templates/default/actor/user/register.tt2 index 4e4cd4e42a..ae66734620 100644 --- a/Open-ILS/web/templates/default/actor/user/register.tt2 +++ b/Open-ILS/web/templates/default/actor/user/register.tt2 @@ -11,6 +11,7 @@ text-align: left; } + #uedit-save-div { position: fixed; top:40px; @@ -56,7 +57,6 @@ } .uedit-addr-del-button {margin-left: 10px; color:red;} - @@ -110,7 +110,7 @@ - + -- 2.43.2