From 6807a06a11d309e94dbc5e286e45a5fdd3eaecab Mon Sep 17 00:00:00 2001 From: Jeff Godin Date: Wed, 30 Oct 2013 15:42:15 -0400 Subject: [PATCH] Add button to update expire date field When updating/renewing a patron (expired or not), it would be convenient to have a means of populating the expire date field with a value of perm_interval + today. Currently, staff are required to manually enter a date, or could toggle the profile from one profile then back to the desired profile, but this is not ideal. This commit adds a new button next to the expire date, which when activated will re-calculate the date based on the current profile's perm_interval and today's date. This is similar to how the expire date is populated when creating a new user, or when changing the profile group. A button is used here so that the updating of the expire date is an intentional process, not one that happens upon any edit. Signed-off-by: Jeff Godin Signed-off-by: Ben Shum --- .../src/templates/actor/user/register_table.tt2 | 7 +++++- Open-ILS/web/js/dojo/openils/actor/nls/register.js | 3 ++- Open-ILS/web/js/ui/default/actor/user/register.js | 25 ++++++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/templates/actor/user/register_table.tt2 b/Open-ILS/src/templates/actor/user/register_table.tt2 index ba3f246a8c..cdb5fa3c45 100644 --- a/Open-ILS/src/templates/actor/user/register_table.tt2 +++ b/Open-ILS/src/templates/actor/user/register_table.tt2 @@ -41,7 +41,12 @@ - + + + + + + diff --git a/Open-ILS/web/js/dojo/openils/actor/nls/register.js b/Open-ILS/web/js/dojo/openils/actor/nls/register.js index f7d13b6aad..d6dbd71103 100644 --- a/Open-ILS/web/js/dojo/openils/actor/nls/register.js +++ b/Open-ILS/web/js/dojo/openils/actor/nls/register.js @@ -40,5 +40,6 @@ "HOLD_NOTIFY_PHONE": "Phone: ", "HOLD_NOTIFY_EMAIL": "Email: ", "HOLD_NOTIFY_SMS": "SMS: ", - "REQUESTING_USER" : "Account requested by ${0} ${1}" + "REQUESTING_USER" : "Account requested by ${0} ${1}", + "UPDATE_EXPIRE_DATE": "Update Expire Date" } 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 671502a7a2..c31eb2fc54 100644 --- a/Open-ILS/web/js/ui/default/actor/user/register.js +++ b/Open-ILS/web/js/ui/default/actor/user/register.js @@ -84,6 +84,7 @@ function load() { allCards.attr("label", localeStrings.SEE_ALL); dojo.byId('uedit-dupe-username-warning').innerHTML = localeStrings.DUPE_USERNAME; generatePassword.attr("label", localeStrings.RESET_PASSWORD); + setExpireDate.attr("label", localeStrings.UPDATE_EXPIRE_DATE); dojo.byId('verifyPassword').innerHTML = localeStrings.VERIFY_PASSWORD; dojo.byId('parentGuardian').innerHTML = localeStrings.PARENT_OR_GUARDIAN; dojo.byId('userSettings').innerHTML = localeStrings.USER_SETTINGS; @@ -293,6 +294,8 @@ function load() { dojo.connect(generatePassword, 'onClick', generatePasswordHandler); + dojo.connect(setExpireDate, 'onClick', setExpireDateHandler); + if(!patron.isnew() && !checkGrpAppPerm(patron.profile()) && patron.id() != openils.User.user.id()) { // we are not allowed to edit this user, so disable the save option saveButton.attr('disabled', true); @@ -494,6 +497,28 @@ function generatePasswordHandler() { } /** + * Set Expire Date field based on today and current profile group + */ +function setExpireDateHandler() { + var profileWidget, expireWidget; + profileWidget = findWidget('au', 'profile'); + expireWidget = findWidget('au', 'expire_date'); + + // This technique is borrowed with slight modifications + // from the profile widget onChange handler + function found(items) { + if (items.length == 0) return; + var item = items[0]; + var interval = profileWidget.widget.store.getValue(item, 'perm_interval'); + expireWidget.widget.attr('value', dojo.date.add(new Date(), + 'second', openils.Util.intervalToSeconds(interval))); + } + + profileWidget.widget.store.fetch({onComplete:found, query:{id:profileWidget.widget.attr('value')}}); + +} + +/** * Loads a staged user and turns them into something the editor can understand */ function uEditLoadStageUser(stageUname) { -- 2.11.0