From ed082bed4c4214422f3d74881da63ff704e677b0 Mon Sep 17 00:00:00 2001 From: phasefx Date: Sat, 1 May 2010 08:33:51 +0000 Subject: [PATCH] Dedicated interface for circ.staff_client.do_not_auto_attempt_print org unit setting (given that the generic one does not handle settings of type array very well--particularly enumeration of allowed array values) git-svn-id: svn://svn.open-ils.org/ILS/trunk@16368 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/locale/en-US/lang.dtd | 11 ++ .../staff_client/chrome/content/main/constants.js | 2 + .../xul/staff_client/chrome/content/main/menu.js | 6 + .../chrome/content/main/menu_frame_menus.xul | 4 + .../chrome/locale/en-US/offline.properties | 1 + .../admin/do_not_auto_attempt_print_setting.js | 161 +++++++++++++++++++++ .../admin/do_not_auto_attempt_print_setting.xul | 60 ++++++++ .../server/locale/en-US/admin.properties | 6 + 8 files changed, 251 insertions(+) create mode 100644 Open-ILS/xul/staff_client/server/admin/do_not_auto_attempt_print_setting.js create mode 100644 Open-ILS/xul/staff_client/server/admin/do_not_auto_attempt_print_setting.xul diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index 29eca0129..63f9cc17e 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -1545,6 +1545,15 @@ + + + + + + + + + @@ -1757,6 +1766,8 @@ + + diff --git a/Open-ILS/xul/staff_client/chrome/content/main/constants.js b/Open-ILS/xul/staff_client/chrome/content/main/constants.js index 0ac7b7104..3e8cb1b19 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -152,6 +152,7 @@ var api = { 'FM_AOU_IDS_RETRIEVE_VIA_RECORD_ID.authoritative' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.actor.org_unit.retrieve_by_title.authoritative', 'secure' : false }, 'FM_AOUS_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.org_unit_setting.values.ranged.retrieve' }, 'FM_AOUS_SPECIFIC_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.ou_setting.ancestor_default' }, + 'FM_AOUS_UPDATE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.org_unit.settings.update' }, 'FM_AOUT_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.org_types.retrieve', 'secure' : false }, 'FM_ASC_BATCH_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.stat_cat.asset.retrieve.batch', 'secure' : false }, 'FM_ASC_RETRIEVE_VIA_AOU' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.stat_cat.asset.retrieve.all', 'secure' : false }, @@ -345,6 +346,7 @@ var urls = { 'XUL_DEBUG_FILTER_CONSOLE' : '/xul/server/util/filter_console.xul', 'XUL_DEBUG_SHELL' : '/xul/server/util/shell.html', 'XUL_DEBUG_XULEDITOR' : '/xul/server/util/xuledit.xul', + 'XUL_DO_NOT_AUTO_ATTEMPT_PRINT_SETTING' : '/xul/server/admin/do_not_auto_attempt_print_setting.xul', 'XUL_FANCY_PROMPT' : '/xul/server/util/fancy_prompt.xul', 'XUL_HOLD_CAPTURE' : '/xul/server/circ/hold_capture.xul', /*'XUL_HOLD_PULL_LIST' : '/xul/server/admin/hold_pull_list.xhtml',*/ diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu.js b/Open-ILS/xul/staff_client/chrome/content/main/menu.js index 2124e1da1..137c9ed4a 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js @@ -564,6 +564,12 @@ main.menu.prototype = { ['oncommand'], function() { open_admin_page('printer_settings.html', 'menu.cmd_local_admin_printer.tab', true); } ], + 'cmd_local_admin_do_not_auto_attempt_print_setting' : [ + ['oncommand'], + function() { + obj.set_tab(obj.url_prefix(urls.XUL_DO_NOT_AUTO_ATTEMPT_PRINT_SETTING),{'tab_name':offlineStrings.getString('menu.cmd_local_admin_do_not_auto_attempt_print_setting.tab')},{}); + } + ], 'cmd_local_admin_closed_dates' : [ ['oncommand'], function() { open_admin_page('closed_dates.xhtml', 'menu.cmd_local_admin_closed_dates.tab', true); } diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul index 3d617f7ec..014e08ba1 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul @@ -105,6 +105,9 @@ + @@ -344,6 +347,7 @@ + diff --git a/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties b/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties index facfd9322..e6d7bec1e 100644 --- a/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties +++ b/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties @@ -214,6 +214,7 @@ list.dump_extended_format.record_separator==-=-= menu.cmd_survey_wizard.inadequate_perm=You are lacking the CREATE_SURVEY permission and/or working locations. menu.cmd_local_admin_fonts_and_sounds.tab=Global Font and Sound Settings menu.cmd_local_admin_printer.tab=Printer Settings Editor +menu.cmd_local_admin_do_not_auto_attempt_print_setting.tab='Do Not Attempt Auto-Print' Setting menu.cmd_local_admin_closed_dates.tab=Closed Dates Editor menu.cmd_local_admin_copy_locations.tab=Copy Locations Editor menu.cmd_local_admin_lib_settings.tab=Library Settings Editor diff --git a/Open-ILS/xul/staff_client/server/admin/do_not_auto_attempt_print_setting.js b/Open-ILS/xul/staff_client/server/admin/do_not_auto_attempt_print_setting.js new file mode 100644 index 000000000..e1eaea094 --- /dev/null +++ b/Open-ILS/xul/staff_client/server/admin/do_not_auto_attempt_print_setting.js @@ -0,0 +1,161 @@ +var error; +var network; +var data; +var coust_obj; + +function my_init() { + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); } + JSAN.errorLevel = "die"; // none, warn, or die + JSAN.addRepository('/xul/server/'); + JSAN.use('util.error'); error = new util.error(); + error.sdump('D_TRACE','my_init() for main_test.xul'); + JSAN.use('util.network'); network = new util.network(); + JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.stash_retrieve(); + + dojo.require('openils.PermaCrud'); + coust_obj = new openils.PermaCrud({authtoken:ses()}).search('coust',{'name':'circ.staff_client.do_not_auto_attempt_print'})[0]; + document.getElementById('caption').setAttribute('label',coust_obj.label()); + document.getElementById('caption').setAttribute('tooltiptext',coust_obj.name()); + append_to_vbox('desc',coust_obj.description()); + + render_current_setting(); + + document.getElementById('apply').addEventListener( + 'command', + apply_setting, + false + ); + + render_lib_menu(); + + } catch(E) { + try { error.standard_unexpected_error_alert('main/test.xul',E); } catch(F) { alert(E); } + } +} + +function append_to_vbox(id,node) { + if (typeof node == 'string') { var text = document.createTextNode(node); node = document.createElement('description'); node.appendChild(text); } + document.getElementById(id).appendChild(node); +} + +function admin_string(s,p) { + var mc = document.getElementById('adminStrings'); + if (p) { + return mc.getFormattedString(s,p); + } else { + return mc.getString(s); + } +} + +function apply_setting(ev) { + var values = []; + if (document.getElementById('checkout').checked) { values.push('Checkout'); } + if (document.getElementById('bill_pay').checked) { values.push('Bill Pay'); } + if (document.getElementById('hold_slip').checked) { values.push('Hold Slip'); } + if (document.getElementById('transit_slip').checked) { values.push('Transit Slip'); } + if (document.getElementById('hold_transit_slip').checked) { values.push('Hold/Transit Slip'); } + var org = document.getElementById('lib_menulist').value; + var result = network.simple_request('FM_AOUS_UPDATE',[ ses(), org, { 'circ.staff_client.do_not_auto_attempt_print' : values } ]); + if (result == 1) { + alert(admin_string('staff.admin.staff.do_not_auto_attempt_print_setting.update_success')); + render_current_setting(); + } else { + error.standard_unexpected_error_alert(admin_string('staff.admin.staff.do_not_auto_attempt_print_setting.update_failure'),result); + } +} + +function render_current_setting() { + JSAN.use('util.widgets'); + + util.widgets.remove_children('current'); + + /* FIXME: would be good to have an .authoritative version of FM_AOUS_SPECIFIC_RETRIEVE */ + var aous_req = network.simple_request('FM_AOUS_SPECIFIC_RETRIEVE',[ ses('ws_ou'), 'circ.staff_client.do_not_auto_attempt_print', ses() ]); + if (aous_req) { + append_to_vbox( + 'current', + admin_string( + 'staff.admin.staff.do_not_auto_attempt_print_setting.current_setting_preamble', + [ ses('ws_ou_shortname'), data.hash.aou[ aous_req.org ].shortname() ] + ) + ); + + for (var i in aous_req.value) { + var label = document.createElement('label'); + label.setAttribute('value', ' ' + aous_req.value[i]); + append_to_vbox('current',label); + } + + /* update data.hash.aous while we have fresh data */ + + data.hash.aous['circ.staff_client.do_not_auto_attempt_print'] = aous_req.value; + data.stash('hash'); + + } else { + append_to_vbox( + 'current', + admin_string( + 'staff.admin.staff.do_not_auto_attempt_print_setting.current_setting_nonexistent', + [ ses('ws_ou_shortname') ] + ) + ); + } +} + + +function render_lib_menu() { + try { + JSAN.use('util.functional'); JSAN.use('util.fm_utils'); JSAN.use('util.widgets'); + + var work_ous = network.simple_request( + 'PERM_RETRIEVE_WORK_OU', + [ ses(), 'ADMIN_ORG_UNIT_SETTING_TYPE'] + ); + if (work_ous.length == 0) { + return; + } else { + document.getElementById('apply').disabled = false; + } + + var my_libs = []; + for (var i = 0; i < work_ous.length; i++ ) { + var perm_depth = data.hash.aout[ data.hash.aou[ work_ous[i] ].ou_type() ].depth(); + + var my_libs_tree = network.simple_request( + 'FM_AOU_DESCENDANTS_RETRIEVE', + [ work_ous[i], perm_depth ] + ); + if (!instanceOf(my_libs_tree,aou)) { /* FIXME - workaround for weird descendants call result */ + my_libs_tree = my_libs_tree[0]; + } + my_libs = my_libs.concat( util.fm_utils.flatten_ou_branch( my_libs_tree ) ); + } + + var x = document.getElementById('menu'); + util.widgets.remove_children( x ); + + var default_lib = my_libs[0].id(); + + var ml = util.widgets.make_menulist( + util.functional.map_list( + my_libs, + function(obj) { + return [ + obj.shortname(), + obj.id(), + false, + ( data.hash.aout[ obj.ou_type() ].depth() ) + ]; + } + ), + default_lib + ); + ml.setAttribute('id','lib_menulist'); + + x.appendChild( ml ); + } catch(E) { + alert('Error in do_not_auto_attempt_print_setting.js, render_lib_menu(): ' + E); + } +} diff --git a/Open-ILS/xul/staff_client/server/admin/do_not_auto_attempt_print_setting.xul b/Open-ILS/xul/staff_client/server/admin/do_not_auto_attempt_print_setting.xul new file mode 100644 index 000000000..bece26a35 --- /dev/null +++ b/Open-ILS/xul/staff_client/server/admin/do_not_auto_attempt_print_setting.xul @@ -0,0 +1,60 @@ + + + + + + + + + + + + +]> + + + + + + + + + + + + + + +