added duration editing
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 23 Jun 2006 13:42:22 +0000 (13:42 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 23 Jun 2006 13:42:22 +0000 (13:42 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@4734 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Circ/NonCat.pm
Open-ILS/xul/staff_client/server/admin/admin.css
Open-ILS/xul/staff_client/server/admin/non_cat_types.js
Open-ILS/xul/staff_client/server/admin/non_cat_types.xhtml

index 4126db7..a6a51c8 100644 (file)
@@ -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',
index ba3fd66..4163e55 100644 (file)
@@ -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;
index fb9aa41..d9dce42 100644 (file)
@@ -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();
index 58f65e1..ef5da60 100644 (file)
                                <tbody>
                                        <tr>
                                                <td><input id='nc_new_name'> </input></td>
+                                               <td>
+                                                       <input id='nc_new_interval_count' type='text' size='2' maxlength='2' value='14'/>
+                                                       <select id='nc_new_interval_type' style='width: 6em;'>
+                                                               <option value='hours'>Hours</option>
+                                                               <option value='days' selected='selected'>Days</option>
+                                                               <option value='weeks'>Weeks</option>
+                                                               <option value='months'>Months</option>
+                                                       </select>
+                                               </td>
                                                <td><select class='select_big' id='nc_new_owner' disabled='disabled'> </select></td>
                                                <td><input id='nc_new_submit' type='submit' value='Create' disabled='disabled'> </input></td>
                                        </tr>
@@ -55,6 +64,7 @@
                                        <tr>
                                                <td>Name</td>
                                                <td>Owning Location</td>
+                                               <td>Duration</td>
                                                <td>Edit</td>
                                                <td>Delete</td>
                                        </tr>
                                        <tr id='nc_row_template'>
                                                <td><b name='nc_name'> </b></td>
                                                <td name='nc_owner'/>
+                                               <td>
+                                                       <input name='nc_interval_count' type='text' size='2' maxlength='2' disabled='disabled'/>
+                                                       <select name='nc_interval_type' style='width: 6em;' disabled='disabled'>
+                                                               <option value='hours'>Hours</option>
+                                                               <option value='days'>Days</option>
+                                                               <option value='weeks'>Weeks</option>
+                                                               <option value='months'>Months</option>
+                                                       </select>
+                                               </td>
                                                <td><input name='nc_edit' type='submit' value='Edit' disabled='disabled'/></td>
                                                <td><input name='nc_delete' type='submit' value='Delete' disabled='disabled'/></td>
                                        </tr>
                                                <span class='padded'>
                                                        <input name='nc_edit_name' type='text'> </input>
                                                </span>
+                                               <span>
+                                                       <input name='nc_edit_interval_count' type='text' size='2' maxlength='2'/>
+                                                       <select name='nc_edit_interval_type' style='width: 6em;'>
+                                                               <option value='hours'>Hours</option>
+                                                               <option value='days'>Days</option>
+                                                               <option value='weeks'>Weeks</option>
+                                                               <option value='months'>Months</option>
+                                                       </select>
+                                               </span>
                                                <span class='padded'>
                                                        <input name='nc_edit_submit' type='submit' value='Submit'> </input>
                                                </span>