From 59768a80fbcf76f68f6ca879591cdc54d521a4f5 Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 23 Jun 2006 13:42:22 +0000 Subject: [PATCH] added duration editing git-svn-id: svn://svn.open-ils.org/ILS/trunk@4734 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../perlmods/OpenILS/Application/Circ/NonCat.pm | 3 +- Open-ILS/xul/staff_client/server/admin/admin.css | 5 ++- .../xul/staff_client/server/admin/non_cat_types.js | 37 +++++++++++++++++++--- .../staff_client/server/admin/non_cat_types.xhtml | 28 ++++++++++++++++ 4 files changed, 66 insertions(+), 7 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/NonCat.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/NonCat.pm index 4126db7ce2..a6a51c8ca5 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/NonCat.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/NonCat.pm @@ -52,7 +52,7 @@ __PACKAGE__->register_method( /); sub create_noncat_type { - my( $self, $client, $authtoken, $name, $orgId ) = @_; + my( $self, $client, $authtoken, $name, $orgId, $interval ) = @_; my( $staff, $evt ) = $U->checkses($authtoken); return $evt if $evt; @@ -71,6 +71,7 @@ sub create_noncat_type { my $type = Fieldmapper::config::non_cataloged_type->new; $type->name($name); $type->owning_lib($orgId); + $type->circ_duration($interval); my $id = $U->simplereq( 'open-ils.storage', diff --git a/Open-ILS/xul/staff_client/server/admin/admin.css b/Open-ILS/xul/staff_client/server/admin/admin.css index ba3fd6665b..4163e55bc9 100644 --- a/Open-ILS/xul/staff_client/server/admin/admin.css +++ b/Open-ILS/xul/staff_client/server/admin/admin.css @@ -11,10 +11,13 @@ body { font-family: Verdana, Tahoma; font-size: 10pt; background-color: white;} .data_grid_padded tbody td { padding: 10px; } .insert_row { border: 2px solid #A0B0A0; padding: 50px;} .padded { padding-left: 7px; padding-right: 7px; } -select { width: 12em; } .select_big { width: 15em; } .context_help { font-weight: bold; color: blue; } +select { width: 12em; } +select:disabled { color: #555555; } +input[type="text"]:disabled { color: #555555; } + button { color:#050; font-family:'trebuchet ms',helvetica,sans-serif; diff --git a/Open-ILS/xul/staff_client/server/admin/non_cat_types.js b/Open-ILS/xul/staff_client/server/admin/non_cat_types.js index fb9aa419c2..d9dce429ca 100644 --- a/Open-ILS/xul/staff_client/server/admin/non_cat_types.js +++ b/Open-ILS/xul/staff_client/server/admin/non_cat_types.js @@ -47,7 +47,9 @@ function ncCreateNew() { var name = $('nc_new_name').value; if(!name) return; var org = getSelectorVal($('nc_new_owner')); - var req = new Request(CREATE_NON_CAT_TYPE, SESSION, name, org ); + var time = $('nc_new_interval_count').value; + var type = getSelectorVal($('nc_new_interval_type')); + var req = new Request(CREATE_NON_CAT_TYPE, SESSION, name, org, time + ' ' + type ); req.send(true); var res = req.result(); if(checkILSEvent(res)) throw res; @@ -71,19 +73,37 @@ function ncDisplayTypes(r) { return 0; }); - for( var idx = 0; idx != types.length; idx++ ) { + var type = types[idx]; var org = findOrgUnit( type.owning_lib() ); var row = rowTemplate.cloneNode(true); + row.id = 'nc_row_' + type.id(); $n(row, 'nc_name').appendChild(text(type.name())); - $n(row, 'nc_owner').appendChild( text( org.name() )); + $n(row, 'nc_owner').appendChild(text(org.name())); + + var idata = _splitInterval(type.circ_duration()); + $n(row, 'nc_interval_count').value = idata[0]; + setSelector( $n(row, 'nc_interval_type'), idata[1]); + ncSetRowCallbacks( type, org, tbody, row ); tbody.appendChild(row); } } +/* this is a kind of brittle, but works with the data we create */ +function _splitInterval( interval ) { + interval = interval.split(/ /); + var time = interval[0]; + var type = interval[1]; + if( time.match(/:/) ) return [ time.replace(/(\d{2}):\d{2}:\d{2}/,'$1'), 'hours' ]; + if( type.match(/h/) ) return [ time, 'hours' ]; + if( type.match(/d/) ) return [ time, 'days' ]; + if( type.match(/w/) ) return [ time, 'weeks' ]; + if( type.match(/m/) ) return [ time, 'months' ]; +} + function ncSetRowCallbacks( type, owner, tbody, row ) { checkDisabled( $n(row, 'nc_edit'), owner, 'UPDATE_NON_CAT_TYPE'); @@ -108,9 +128,15 @@ function ncEditType( tbody, row, type ) { var name = $n(row, 'nc_edit_name'); name.value = type.name(); + var idata = _splitInterval(type.circ_duration()); + $n(row, 'nc_edit_interval_count').value = idata[0]; + setSelector( $n(row, 'nc_edit_interval_type'), idata[1]); + $n(row, 'nc_edit_submit').onclick = function() { var name = $n(row, 'nc_edit_name').value; - ncEditSubmit( type, name ); + var time = $n(row, 'nc_edit_interval_count').value; + var tp = getSelectorVal($n(row, 'nc_edit_interval_type')); + ncEditSubmit( type, name, time + ' ' + tp ); }; $n(row, 'nc_edit_cancel').onclick = @@ -124,9 +150,10 @@ function ncEditType( tbody, row, type ) { name.select(); } -function ncEditSubmit( type, name ) { +function ncEditSubmit( type, name, interval ) { if(!name) return; type.name(name); + type.circ_duration(interval); var req = new Request( UPDATE_NON_CAT_TYPE, SESSION, type ); req.send(true); var res = req.result(); diff --git a/Open-ILS/xul/staff_client/server/admin/non_cat_types.xhtml b/Open-ILS/xul/staff_client/server/admin/non_cat_types.xhtml index 58f65e13fc..ef5da6064a 100644 --- a/Open-ILS/xul/staff_client/server/admin/non_cat_types.xhtml +++ b/Open-ILS/xul/staff_client/server/admin/non_cat_types.xhtml @@ -42,6 +42,15 @@ + + + + @@ -55,6 +64,7 @@ Name Owning Location + Duration Edit Delete @@ -63,6 +73,15 @@ + + + + @@ -77,6 +96,15 @@ + + + + -- 2.11.0