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;
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');
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 =
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();
<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>
<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>