From 44851383072d3ebbf2d8652ede6c84b67e64ac28 Mon Sep 17 00:00:00 2001 From: Jeff Godin Date: Wed, 30 Oct 2013 16:41:06 -0400 Subject: [PATCH] Improve username flow for staged users Staged users in most cases have a username that consists of a UUID. Rather than leave the UUID as their username or require staff to clear the field and replace it with a barcode or other value, it would be better to remove this username when loading the staged user in the user editor. This commit clears the username when loading a stage user if the username looks like a UUID. If a barcode has been staged for the loaded staged user, the username will be populated with that value. If there is no staged barcode, the username will remain blank and will be populated using the standard method after staff enters a value in the barcode field. Signed-off-by: Jeff Godin --- Open-ILS/web/js/ui/default/actor/user/register.js | 9 +++++++++ 1 file changed, 9 insertions(+) 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 6840b3994b..76f782ec11 100644 --- a/Open-ILS/web/js/ui/default/actor/user/register.js +++ b/Open-ILS/web/js/ui/default/actor/user/register.js @@ -582,6 +582,11 @@ function uEditLoadStageUser(stageUname) { } } + // Clear the usrname if it looks like a UUID + if (patron['usrname']().replace(/-/g,'').match(/[0-9a-f]{32}/)) { + patron['usrname'](''); + } + // copy the data into our new address objects // TODO: uses the first mailing address only if(data.mailing_addresses.length) { @@ -631,6 +636,10 @@ function uEditLoadStageUser(stageUname) { var card = new fieldmapper.ac(); card.id(-1); // virtual ID patron.card().barcode(data.cards[0].barcode()); + // Set usrname to barcode if usrname is empty + if (patron.usrname() == '') { + patron.usrname(card.barcode()); + } } return patron; -- 2.11.0