From d7ff75183852859dc6c0db14c86ade712444535b Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 3 Feb 2006 20:43:22 +0000 Subject: [PATCH] added some more utility code and css copy locations editor now functions git-svn-id: svn://svn.open-ils.org/ILS/trunk@2968 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../xul/staff_client/server/admin/admin.css | 2 +- .../xul/staff_client/server/admin/adminlib.js | 17 +++ .../server/admin/copy_locations.js | 124 ++++++++++++++---- .../server/admin/copy_locations.xml | 94 ++++++++++--- .../server/admin/non_cat_types.js | 5 +- 5 files changed, 193 insertions(+), 49 deletions(-) diff --git a/Open-ILS/xul/staff_client/server/admin/admin.css b/Open-ILS/xul/staff_client/server/admin/admin.css index 2979b0ea5e..8f7acf922e 100644 --- a/Open-ILS/xul/staff_client/server/admin/admin.css +++ b/Open-ILS/xul/staff_client/server/admin/admin.css @@ -12,4 +12,4 @@ .padded { padding-left: 7px; padding-right: 7px; } select { width: 12em; } .select_big { width: 15em; } - +.context_help { font-weight: bold; color: blue; } diff --git a/Open-ILS/xul/staff_client/server/admin/adminlib.js b/Open-ILS/xul/staff_client/server/admin/adminlib.js index 945416b7e9..af55c167d2 100644 --- a/Open-ILS/xul/staff_client/server/admin/adminlib.js +++ b/Open-ILS/xul/staff_client/server/admin/adminlib.js @@ -52,7 +52,24 @@ function cleanTbody(tbody, key) { } +/** Inserts a row into a specified place in a table + * tbody is the table body + * row is the context row after which the new row is to be inserted + * newRow is the new row to insert + */ function insRow( tbody, row, newRow ) { if(row.nextSibling) tbody.insertBefore( newRow, row.nextSibling ); else{ tbody.appendChild(newRow); } } + + +/** Checks to see if a given node should be enabled + * A node should be enabled if the itemOrg is lower in the + * org tree than my permissions allow editing + * I.e. I can edit the context item because it's "below" me + */ +function checkDisabled( node, itemOrg, perm ) { + var itemDepth = findOrgDepth(itemOrg); + var mydepth = findOrgDepth(PERMS[perm]); + if( mydepth != -1 && mydepth <= itemDepth ) node.disabled = false; +} diff --git a/Open-ILS/xul/staff_client/server/admin/copy_locations.js b/Open-ILS/xul/staff_client/server/admin/copy_locations.js index b029aaeccf..be60fa2f1b 100644 --- a/Open-ILS/xul/staff_client/server/admin/copy_locations.js +++ b/Open-ILS/xul/staff_client/server/admin/copy_locations.js @@ -21,8 +21,14 @@ function clEditorInit() { $('user').appendChild(text(USER.usrname())); YES = $('yes').innerHTML; NO = $('no').innerHTML; - setTimeout( function() { - fetchHighestPermOrgs( SESSION, USER.id(), myPerms ); clGo(); }, 20 ); + + setTimeout( + function() { + fetchHighestPermOrgs( SESSION, USER.id(), myPerms ); + $('cl_new_name').focus(); + clBuildNew(); + clGo(); + }, 20 ); } @@ -30,12 +36,41 @@ function clHoldMsg() { alert($('cl_hold_msg').innerHTML); } -function clGo() { +function clGo() { var req = new Request(RETRIEVE_CL, SESSION, USER.home_ou()); req.callback(clDraw); req.send(); } +function clBuildNew() { + org = PERMS['CREATE_COPY_LOCATION']; + if(org == -1) return; + var selector = $('cl_new_owner'); + org = findOrgUnit(org); + buildOrgSel(selector, org, findOrgDepth(org)); + if(org.children() && org.children()[0]) + selector.disabled = false; + + var sub = $('sc_new_submit'); + sub.disabled = false; + sub.onclick = clCreateNew; +} + +function clCreateNew() { + var cl = new acpl(); + cl.name( $('cl_new_name').value ); + cl.owning_lib( getSelectorVal( $('cl_new_owner'))); + cl.holdable( ($('cl_new_hold_yes').checked) ? 1 : 0 ); + cl.opac_visible( ($('cl_new_vis_yes').checked) ? 1 : 0 ); + cl.circulate( ($('cl_new_circulate_yes').checked) ? 1 : 0 ); + + var req = new Request(CREATE_CL, SESSION, cl); + req.send(true); + var res = req.result(); + if(checkILSEvent(res)) throw res; + clGo(); +} + var rowTemplate; function clDraw(r) { @@ -67,44 +102,83 @@ function clBuildRow( tbody, row, cl ) { $n( row, 'cl_holdable').appendChild(text( (cl.holdable()) ? YES : NO ) ); $n( row, 'cl_visible').appendChild(text( (cl.opac_visible()) ? YES : NO ) ); $n( row, 'cl_circulate').appendChild(text( (cl.circulate()) ? YES : NO ) ); - $n( row, 'cl_edit').onclick = function() { clEdit( cl, tbody, row ); }; + + var edit = $n( row, 'cl_edit'); + edit.onclick = function() { clEdit( cl, tbody, row ); }; + checkDisabled( edit, cl.owning_lib(), 'UPDATE_COPY_LOCATION'); + + var del = $n( row, 'cl_delete' ); + del.onclick = function() { clDelete( cl, tbody, row ); }; + checkDisabled( del, cl.owning_lib(), 'DELETE_COPY_LOCATION'); } function clEdit( cl, tbody, row ) { cleanTbody(tbody, 'edit'); - var r = $('cl_new').cloneNode(true); + var r = $('cl_edit').cloneNode(true); r.setAttribute('edit','1'); - var name = $n(r, 'cl_new_name'); + var name = $n(r, 'cl_edit_name'); name.setAttribute('size', cl.name().length + 3); name.value = cl.name(); - $n(r, 'cl_new_owner').appendChild(text(findOrgUnit(cl.owning_lib()).name())); - - var yhold = $n( $n(r,'cl_new_holdable_yes'), 'cl_new_holdable'); - var nhold = $n( $n(r,'cl_new_holdable_no'), 'cl_new_holdable'); - var yvis = $n( $n(r,'cl_new_visible_yes'), 'cl_new_visible'); - var nvis = $n( $n(r,'cl_new_visible_no'), 'cl_new_visible'); - var ycirc = $n( $n(r,'cl_new_circulate_yes'), 'cl_new_circulate'); - var ncirc = $n( $n(r,'cl_new_circulate_no'), 'cl_new_circulate'); + $n(r, 'cl_edit_owner').appendChild(text(findOrgUnit(cl.owning_lib()).name())); - if(cl.holdable()) yhold.checked = true; - else nhold.checked = true; - if(cl.opac_visible()) yvis.checked = true; - else nvis.checked = true; - if(cl.circulate()) ycirc.checked = true; - else ncirc.checked = true; + var arr = _clOptions(r); + if(cl.holdable()) arr[0].checked = true; + else arr[1].checked = true; + if(cl.opac_visible()) arr[2].checked = true; + else arr[3].checked = true; + if(cl.circulate()) arr[4].checked = true; + else arr[5].checked = true; - $n(r, 'cl_new_cancel').onclick = function(){cleanTbody(tbody,'edit');} - $n(r, 'cl_new_commit').onclick = function(){clEditCommit( tbody, cl ); } + $n(r, 'cl_edit_cancel').onclick = function(){cleanTbody(tbody,'edit');} + $n(r, 'cl_edit_commit').onclick = function(){clEditCommit( tbody, r, cl ); } insRow(tbody, row, r); name.focus(); name.select(); } -function clEditCommit( tbody, cl ) { - alert("committing: " + cl.id()); - cleanTbody(tbody,'edit'); +function _clOptions(r) { + var arr = []; + arr[0] = $n( $n(r,'cl_edit_holdable_yes'), 'cl_edit_holdable'); + arr[1] = $n( $n(r,'cl_edit_holdable_no'), 'cl_edit_holdable'); + arr[2] = $n( $n(r,'cl_edit_visible_yes'), 'cl_edit_visible'); + arr[3] = $n( $n(r,'cl_edit_visible_no'), 'cl_edit_visible'); + arr[4] = $n( $n(r,'cl_edit_circulate_yes'), 'cl_edit_circulate'); + arr[5] = $n( $n(r,'cl_edit_circulate_no'), 'cl_edit_circulate'); + return arr; } + +function clEditCommit( tbody, r, cl ) { + + var arr = _clOptions(r); + if(arr[0].checked) cl.holdable(1); + else cl.holdable(0); + if(arr[2].checked) cl.opac_visible(1); + else cl.opac_visible(0); + if(arr[4].checked) cl.circulate(1); + else cl.circulate(0); + cl.name($n(r, 'cl_edit_name').value); + + var req = new Request( UPDATE_CL, SESSION, cl ); + req.send(true); + var res = req.result(); + if(checkILSEvent(res)) throw res; + + clGo(); +} + + +function clDelete( cl, tbody, row ) { + if(!confirm($('cl_delete_confirm').innerHTML)) return; + var req = new Request( DELETE_CL, SESSION, cl.id() ); + req.send(true); + var res = req.result(); + if(checkILSEvent(res)) throw res; + + clGo(); +} + + diff --git a/Open-ILS/xul/staff_client/server/admin/copy_locations.xml b/Open-ILS/xul/staff_client/server/admin/copy_locations.xml index 15a42041b9..0468cfdb55 100644 --- a/Open-ILS/xul/staff_client/server/admin/copy_locations.xml +++ b/Open-ILS/xul/staff_client/server/admin/copy_locations.xml @@ -31,6 +31,56 @@
Copy Locations Editor
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Create a new copy location
Name: + + Holdable: + Yes + + No + +
OPAC Visible: + Yes + + No + + Circulate: + Yes + + No + +
Owning Library: + +
+ +


@@ -40,7 +90,7 @@ @@ -55,8 +105,8 @@ - - + +
Owning Library Holdable - ?? + ?? OPAC Visible Circulate
@@ -68,43 +118,47 @@ If a copy location is "Holdable", copies in that location may have holds placed on them. + + Are you sure you wish to delete the selected copy location? + Note: If copies are currently attached to this location, the delete operation will fail. + - - - + + + - - + +
Yes - - + + No - - + + Yes - - + + No - - + + Yes - - + + No - - + +
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 33d33a3c36..c83bccfd29 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 @@ -84,9 +84,8 @@ function ncDisplayTypes(r) { } function ncSetRowCallbacks( type, owner, tbody, row ) { - var tdepth = findOrgDepth( owner ); - var mydepth = findOrgDepth( PERMS['UPDATE_NON_CAT_TYPE'] ); - if( mydepth != -1 && mydepth <= tdepth ) $n(row, 'nc_edit').disabled = false; + + checkDisabled( $n(row, 'nc_edit'), owner, 'UPDATE_NON_CAT_TYPE'); mydepth = findOrgDepth( PERMS['DELETE_NON_CAT_TYPE'] ); if( mydepth != -1 && mydepth <= tdepth ) $n(row, 'nc_delete').disabled = false; -- 2.43.2