Rebranchify Joe Lewis' patch for lp787162. collab/dyrcona/lp787162
authorJason Stephenson <jstephenson@mvlc.org>
Mon, 17 Oct 2011 15:27:41 +0000 (11:27 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Mon, 17 Oct 2011 15:27:41 +0000 (11:27 -0400)
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Open-ILS/xul/staff_client/chrome/content/main/menu.js
Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul
Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties
Open-ILS/xul/staff_client/server/admin/asset_call_number.js [new file with mode: 0644]
Open-ILS/xul/staff_client/server/admin/asset_call_number.xhtml [new file with mode: 0644]
Open-ILS/xul/staff_client/server/locale/en-US/admin.properties

index 61d239c..94f620b 100644 (file)
@@ -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); }
index 4ec89a3..73474be 100644 (file)
                 <menuitem label="&staff.main.menu.admin.local_admin.conify.survey.label;" command="cmd_local_admin_survey"/>
                 <menuitem label="&staff.server.admin.index.transit_list;" command="cmd_local_admin_transit_list"/>
                 <menuitem label="&staff.main.menu.admin.local_admin.work_log.label;" accesskey="&staff.main.menu.admin.local_admin.work_log.accesskey;" command="cmd_local_admin_work_log"/>
+                <menuitem label="&staff.server.admin.index.call_number_class.label;" command="cmd_local_admin_asset_call_number_class"/>
             </menupopup>
         </menu>
         <menu id="main.menu.admin.server" label="&staff.main.menu.admin.server_admin.label;">
index ca7eedf..130d919 100644 (file)
@@ -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 (file)
index 0000000..b998083
--- /dev/null
@@ -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');
+
+/**
+ <class id="acnc" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="asset::call_number_class" oils_persist:tablename="asset.call_number_class" reporter:label="Call number classification scheme">
+        <fields oils_persist:primary="id" oils_persist:sequence="asset.call_number_class_id_seq">
+            <field reporter:label="Call number class ID" name="id" reporter_datatype="id"/>
+            <field reporter:label="Name" name="name" reporter:datatype="text"/>
+            <field reporter:label="Normalizer function" name="normalizer" reporter:datatype="text"/>
+            <field reporter:label="Call number fields" name="field" reporter:datatype="text"/>
+        </fields>
+        <links/>
+        <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+            <actions>
+                <create permission="ADMIN_CALL_NUMBER_CLASS" global_required="true"/>
+                <retrieve/>
+                <update permission="ADMIN_CALL_NUMBER_CLASS" global_required="true"/>
+                <delete permission="ADMIN_CALL_NUMBER_CLASS" global_required="true"/>
+            </actions>
+        </permacrud>
+    </class>
+*/
+
+
+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 += "<div class='input_container' id='"+id+"cont'>\
+                                                       <div id='"+id+"continner'></div>\
+                                                       <input class='input' id='"+id+"' dojoType='dijit.form.TextBox' type='text' value='"+value+"' />\
+                                   <button type='button' dojoType='dijit.form.Button' onClick='remove_input(\""+id+"cont\");'>[X]</button>\
+                                   <br /></div>";
+       
+       // 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 (file)
index 0000000..bed8418
--- /dev/null
@@ -0,0 +1,110 @@
+<?xml version='1.0' encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC 
+       "-//W3C//DTD XHTML 1.0 Transitional//EN" 
+       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" [
+       <!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
+]>
+
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xi="http://www.w3.org/2001/XInclude">
+<!-- This file is to aid in editing of the asset_call_number_class. -->
+       <head>
+               <title>&staff.server.admin.callnumclass.title;</title>
+               
+               <link type='text/css' rel='stylesheet' href='admin.css'/>
+               
+               <script type="text/javascript" djConfig="parseOnLoad: true,isDebug:false" src="/js/dojo/dojo/dojo.js" />
+               <script type="text/javascript" djConfig="parseOnLoad: true,isDebug:false" src="/js/dojo/dojo/openils_dojo.js" />
+               <script type='text/javascript' src='asset_call_number.js' />
+               
+               <style>
+                       body { margin:0px; padding:0px; }
+                       div { margin:0px; padding:0px; }
+                       
+                       .desc { font-weight:normal; vertical-align:top; text-align:left; }
+                       
+                       #titleBox {
+                               display:block;
+                               width:100%;
+                               border-bottom:1px solid black;
+                               height:100%;
+                       }
+                       
+                       /** Used to 1px bottom border on title box from affecting document height. **/
+                       #titleBoxOuter { height:10%; }
+                       
+                       #titleBox H1 { padding:10px; margin:0px; }
+                       
+                       /** Editing view **/
+                       #selectBox { width:20%; height:90%; float:left; }
+                       #editBox { width:80%; height:90%; float:left; }
+                       #selectBox select { display:block; width:100%; height:100%;}
+
+
+                       /** Error box **/
+                       #startShown { width:100%; height:90%; }
+               </style>
+       </head>
+       
+       <body onload="initAssetCall();">
+               
+               <div id="titleBoxOuter">
+                       <div id="titleBox">
+                               <h1 align="center">&staff.server.admin.callnumclass.title;</h1>
+                       </div>
+               </div>
+               
+               <!-- No need to show this if there is nothing to select -->
+               <div id="startHidden" class="hidden">
+               <div id="selectBox"> <select id="accselect" size="20" onchange="selectAssetCallClass(this.selectedIndex);" /> </div>
+               
+               <div id='editBox'>
+                       <table>
+                               <tr>
+                                       <td class="desc">&staff.server.admin.callnumclass.name;</td>
+                                       <td>
+                                               <input id="nameInput" type="text" size="22" dojoType='dijit.form.TextBox' />
+                                       </td>           
+                               </tr>
+                               <tr>
+                                       <td class="desc">&staff.server.admin.callnumclass.normalizer;</td>
+                                       <td><select size="1" id="normalizerSelect" /><br /></td>
+                               </tr>
+                       <tr>
+                               <td class="desc">&staff.server.admin.callnumclass.tag;</td>
+                               <td id="inputArea" dojoType="dijit.layout.ContentPane"></td>
+                       </tr>
+                       <tr>
+                               <td></td>
+                               <td>
+                                       <button dojoType="dijit.form.Button" type="button" value="&staff.server.admin.callnumclass.add_row;" onClick="appendInput(null);"> 
+                                               &staff.server.admin.callnumclass.add_row;
+                                       </button>
+                               </td>
+                       </tr>
+                       <tr>
+                               <td></td>
+                               <td align="right">
+                                       <button dojoType="dijit.form.Button" type="button" onClick="submit();">
+                                               &staff.server.admin.callnumclass.save;
+                                       </button>
+                               </td>
+                       </tr>
+                       </table>
+                       </div>
+               </div>
+               
+               <!-- Error box just in case something goes wrong, reminscent of 
+               the old IE couldn't connect to the Internet boxes. -->
+               <div id="startShown">
+                       <h1>&staff.server.admin.callnumclass.error_title;</h1>
+                       <p>&staff.server.admin.callnumclass.error_paragraph;
+                               <ul>
+                                       <li>&staff.server.admin.callnumclass.error_perm_bullet;</li>
+                                       <li>&staff.server.admin.callnumclass.error_ses_bullet;</li>
+                                       <li>&staff.server.admin.callnumclass.error_net_bullet;</li>
+                                       <li>&staff.server.admin.callnumclass.error_unknown_bullet;</li>
+                               </ul>
+                       </p>
+               </div>
+       </body>
+</html>
index 3f0428a..33ffad4 100644 (file)
@@ -102,6 +102,18 @@ staff.admin.offline_manage_xacts.no=No
 staff.admin.offline_manage_xacts.yes=Yes
 staff.admin.staff.do_not_auto_attempt_print_setting.update_success=Setting updated
 staff.admin.staff.do_not_auto_attempt_print_setting.update_failure=Setting not updated due to error
+staff.server.admin.callnumclass.title=Asset Call Number Class Editor
+staff.server.admin.callnumclass.name=Name:
+staff.server.admin.callnumclass.normalizer=Normalizer:
+staff.server.admin.callnumclass.tag=Tags/Subfields:
+staff.server.admin.callnumclass.add_row=Add Row
+staff.server.admin.callnumclass.save=Save
+staff.server.admin.callnumclass.error_title=Error
+staff.server.admin.callnumclass.error_paragraph=There was a problem processing your request because:
+staff.server.admin.callnumclass.error_perm_bullet=You do not have permission to view this page.
+staff.server.admin.callnumclass.error_ses_bullet=Your session has expired.
+staff.server.admin.callnumclass.error_net_bullet=There was an error connecting to the network.
+staff.server.admin.callnumclass.error_unknown_bullet=An unknown error occurred.
 # 1 - workstation library shortname   2 - setting library shortname
 staff.admin.staff.do_not_auto_attempt_print_setting.current_setting_preamble=Workstation library %1$s is currently suppressing auto-print for these receipt/slip types based on a setting inherited from %2$s:
 # 1 - workstation library shortname