From: Jason Stephenson Date: Mon, 17 Oct 2011 15:27:41 +0000 (-0400) Subject: Rebranchify Joe Lewis' patch for lp787162. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fcollab%2Fdyrcona%2Flp787162;p=working%2FEvergreen.git Rebranchify Joe Lewis' patch for lp787162. Signed-off-by: Jason Stephenson --- 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 61d239ca83..94f620bf49 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js @@ -852,6 +852,10 @@ main.menu.prototype = { ); } ], + 'cmd_local_admin_asset_call_number_class' : [ + ['oncommand'], + function(event) { open_admin_page('asset_call_number.xhtml', 'menu.cmd_local_admin_asset_call_number_class.tab', true, event); } + ], 'cmd_server_admin_org_type' : [ ['oncommand'], function(event) { open_conify_page('actor/org_unit_type', null, event); } 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 4ec89a3925..73474be106 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 @@ -497,6 +497,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 ca7eedf47a..130d91969f 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 @@ -260,6 +260,7 @@ menu.local_admin.hold_matrix_matchpoint.tab=Hold Policies menu.local_admin.work_log.tab=Work Log menu.local_admin.patrons_due_refunds.tab=Patrons With Negative Balances menu.circulation.staged_patrons.tab=Pending Patrons +menu.cmd_local_admin_asset_call_number_class.tab=Edit Asset Call Number Class load_printer_settings_error_description=Printer settings did not load cleanly with this version of Evergreen. You should reconfigure your printer under Printer Settings Editor. load_printer_settings_error_title=Printer Settings staff.cat.util.copy_editor.batch_edit=Batch Edit diff --git a/Open-ILS/xul/staff_client/server/admin/asset_call_number.js b/Open-ILS/xul/staff_client/server/admin/asset_call_number.js new file mode 100644 index 0000000000..b998083874 --- /dev/null +++ b/Open-ILS/xul/staff_client/server/admin/asset_call_number.js @@ -0,0 +1,225 @@ +dojo.require('fieldmapper.AutoIDL'); +dojo.require('fieldmapper.Fieldmapper'); +dojo.require('fieldmapper.dojoData'); +dojo.require('fieldmapper.OrgUtils'); +dojo.require('dojo.cookie'); +dojo.require('openils.CGI'); +dojo.require('openils.User'); +dojo.require('openils.Event'); +dojo.require('openils.PermaCrud'); +dojo.require('openils.widget.AutoFieldWidget'); +dojo.require('openils.widget.ProgressDialog'); +dojo.require('openils.CGI') +dojo.require('openils.PermaCrud'); +dojo.require('openils.User'); +dojo.require('openils.Event'); +dojo.require('openils.widget.AutoFieldWidget'); + +//dojo.require('dijit.form.Select'); // Newer DOJO +dojo.require('dijit.form.Button'); +dojo.require('dijit.form.TextBox'); +dojo.require('dijit.layout.ContentPane'); + +/** + + + + + + + + + + + + + + + + + +*/ + + +var authtoken; + +var classifications; +var normalizers = ["asset.label_normalizer_dewey", "asset.label_normalizer_generic", "asset.label_normalizer_lc"] + +var nameInput; +var normalizerSelect; +var inputArea; + +var currentClassification; //The index of the current classification in classifications +var pcrud; //The pcrud instance for this doc. + +function initAssetCall() { + authtoken = new openils.CGI().param('ses') || dojo.cookie('ses'); + pcrud = new openils.PermaCrud({"authtoken":authtoken}); + + classifications = pcrud.retrieveAll("acnc"); // asset.call_number_class + + if(classifications == null) // If there was a problem, don't un-hide the page, let it show an error. + return; + + nameInput = dojo.byId('nameInput'); + inputArea = dojo.byId('inputArea'); + normalizerSelect = dojo.byId('normalizerSelect'); + + setUpClassifications(); + setUpNormalizers(); + + // If there is at least one element, choose it to display the form with. + if(classifications.length > 0) + selectAssetCallClass(0); +} + +/** + * Fill up the classification listbox. (left of screen) + */ +function setUpClassifications() { + accselect = dojo.byId('accselect'); + + for(i in classifications) { + var tmp = document.createElement('option'); + tmp.text = classifications[i].name(); + accselect.add(tmp, null); + } +} + + +function setUpNormalizers() { + // FIXME fetch normalizers, need a fm_IDL function for this. + + for( norm in normalizers ) { + var tmp = document.createElement('option'); + names = normalizers[norm].split("_"); + tmp.text = names[names.length -1]; + tmp.value = normalizers[norm]; + + normalizers[norm] = tmp + normalizerSelect.add(tmp, null); + } +} + +/** + * Caled when a class is chosen to set up the rest of the form. + */ +function selectAssetCallClass(selection_index) { + dojo.removeClass("startHidden", "hidden"); //The entry box. + dojo.addClass("startShown", "hidden"); //The error box. + + nameInput.value = classifications[selection_index].name(); + updateNormalizerList(classifications[selection_index].normalizer()); + clearInputArea(); + generateFields(classifications[selection_index].field()); + + currentClassification = selection_index; +} + +function clearInputArea() { + inputArea.innerHTML = ""; +} + +/** + * Generates a list of input boxes for the fields given in a csv style + * list. + */ +function generateFields(csv) { + fields = csv.split(","); + + for(f in fields) + appendInput(fields[f]); +} + +var lastid = 'a'; //Magic code to get new inputs to work properly. + +function saveNodeValues() { + nodevalue_dict = {} + current_inputs = dojo.query(".input"); + + current_inputs.forEach(function(node, index, arr){ + nodevalue_dict[node.id] = document.getElementById(node.id).value; + }); + + return nodevalue_dict; +} + +/** + * Appends an insert to the list of input boxes. + */ +function appendInput(value) { + + nodevalue_dict = saveNodeValues(); + + id = value; + if(value == null) { + value = ""; + lastid += 'a'; + id = lastid; + } + + + inputArea.innerHTML += "
\ +
\ + \ + \ +
"; + + // Add a new input after creating it. + //new dijit.form.TextBox({ 'class':'input', 'value': value, "id":id }, id+"continner"); + + + current_inputs.forEach(function(node, index, arr){ + document.getElementById(node.id).value = nodevalue_dict[node.id]; + }); +} + +function removeInput(id) { + dojo.removeClass(id, "input"); + dojo.addClass(id, "hidden"); + dojo.byId(id).innerHTML = ""; +} + +function updateNormalizerList(toSelect) { + //TODO fetch lists, and update with current + + for( norm in normalizers ) + if(normalizers[norm].value == toSelect) + normalizers[norm].selected = "selected"; + else + normalizers[norm].selected = ""; +} + +function generateCSV() { + csv = ""; + + dojo.query(".input").forEach(function(node, index, arr){ + temp = document.getElementById(node.id).value; + temp = temp.replace(/[^A-Za-z0-9]+/, ''); + + if(temp != "") + if(csv == "") + csv += temp; + else + csv += ","+temp; + }); + return csv; +} + +function submit() { + name = nameInput.value; + norm = normalizerSelect.value; + csv = generateCSV(); + + classifications[currentClassification].name(name); + classifications[currentClassification].normalizer(norm); + classifications[currentClassification].field(csv); + + output = pcrud.update(classifications, { + 'async': true, + 'oncomplete': function(r) { + selectAssetCallClass(currentClassification); + } + }); +} diff --git a/Open-ILS/xul/staff_client/server/admin/asset_call_number.xhtml b/Open-ILS/xul/staff_client/server/admin/asset_call_number.xhtml new file mode 100644 index 0000000000..bed8418283 --- /dev/null +++ b/Open-ILS/xul/staff_client/server/admin/asset_call_number.xhtml @@ -0,0 +1,110 @@ + + +]> + + + + + &staff.server.admin.callnumclass.title; + + + +