Reverse Copy Location picker labels via WS Setting user/tsbere/copy_location_picker
authorThomas Berezansky <tsbere@mvlc.org>
Thu, 29 Sep 2011 23:26:17 +0000 (19:26 -0400)
committerThomas Berezansky <tsbere@mvlc.org>
Fri, 30 Sep 2011 14:34:13 +0000 (10:34 -0400)
If the setting is set then place the name before the org unit. This allows
for typing of the start of the name without having to deal with the org
unit shortname "eating" the start of the label (and thus type-in), but
preserves the information the org unit provides.

As an example, instead of having to type:
CONS : St
To get close to the default "Stacks" in a long list you could just type
St
And likely get to, or close to, Stacks.

The option can be toggled from the Workstation Administration menu.

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/xul/staff_client/chrome/content/main/main.js
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/defaults/preferences/prefs.js
Open-ILS/xul/staff_client/server/cat/copy_editor.js

index 69dba21..732ed64 100644 (file)
 <!ENTITY staff.main.menu.admin.client.toolbars.label_position "Label Position">
 <!ENTITY staff.main.menu.admin.client.toolbars.label_position.side "Next to icons">
 <!ENTITY staff.main.menu.admin.client.toolbars.label_position.under "Under icons">
+<!ENTITY staff.main.menu.admin.client.copy_editor.copy_location.label "Copy Editor: Copy Location Name First">
 <!ENTITY staff.main.menu.admin.non_cat_type_edit.accesskey "n">
 <!ENTITY staff.main.menu.admin.non_cat_type_edit.label "Non-Cataloged Type Editor">
 <!ENTITY staff.main.menu.admin.offline_xacts.accesskey "T">
index 123e3de..abfea68 100644 (file)
@@ -312,6 +312,7 @@ function main_init() {
         G =  {};
         
         G.pref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
+        G.pref.QueryInterface(Components.interfaces.nsIPrefBranch2);
         if (! G.pref.prefHasUserValue('general.useragent.override')) {
             G.pref.setCharPref('general.useragent.override',navigator.userAgent + ' oils_xulrunner /xul/server/');
         }
index a68b9bf..dc55b43 100644 (file)
@@ -140,6 +140,14 @@ main.menu.prototype = {
             }
         }
 
+        var cl_first = xulG.pref.getBoolPref('oils.copy_editor.copy_location_name_first');
+        var menuitems = document.getElementsByAttribute('command','cmd_copy_editor_copy_location_first_toggle');
+        for(var i = 0; i < menuitems.length; i++)
+            menuitems[i].setAttribute('checked', cl_first ? 'true' : 'false');
+
+        xulG.pref.addObserver('', this, false);
+        window.addEventListener("unload", function(e) { this.stop_observing(); }, false);
+
         var network_meter = String( obj.data.hash.aous['ui.network.progress_meter'] ) == 'true';
         if (! network_meter) {
             var x = document.getElementById('network_progress');
@@ -1585,6 +1593,13 @@ main.menu.prototype = {
                         xulG.pref.clearUserPref('open-ils.menu.toolbar.labelbelow');
                 }
             ],
+            'cmd_copy_editor_copy_location_first_toggle' : [
+                ['oncommand'],
+                function() {
+                    var curvalue = xulG.pref.getBoolPref('oils.copy_editor.copy_location_name_first');
+                    xulG.pref.setBoolPref('oils.copy_editor.copy_location_name_first', !curvalue);
+                }
+            ],
         };
 
         JSAN.use('util.controller');
@@ -2368,6 +2383,25 @@ commands:
         else
             // user_false is used to indicate the user said "None of the above" to avoid fall-through erroring later.
             return "user_false";
+    },
+
+    'observe' : function(subject, topic, data) {
+        if (topic != "nsPref:changed") {
+            return;
+        }
+
+        switch(data) {
+            case 'oils.copy_editor.copy_location_name_first':
+                var cl_first = xulG.pref.getBoolPref('oils.copy_editor.copy_location_name_first');
+                var menuitems = document.getElementsByAttribute('command','cmd_copy_editor_copy_location_first_toggle');
+                for(var i = 0; i < menuitems.length; i++)
+                    menuitems[i].setAttribute('checked', cl_first ? 'true' : 'false');
+            break;
+        }
+    },
+
+    'stop_observing' : function() {
+        xulG.pref.removeObserver('oils.copy_editor.*', this);
     }
 }
 
index 014ffab..df499f3 100644 (file)
     <command id="cmd_toolbar_mode_set" />
     <command id="cmd_toolbar_size_set" />
     <command id="cmd_toolbar_label_position_set" />
+    <command id="cmd_copy_editor_copy_location_first_toggle" />
 </commandset>
 
 <!-- The File menu on the main menu -->
                 <menuitem label="&staff.server.admin.index.printer;" command="cmd_local_admin_printer"/>
                 <menuitem label="&staff.main.menu.admin.template_edit.label;" accesskey="&staff.main.menu.admin.template_edit.accesskey;" command="cmd_print_list_template_edit"/>
                 <menuitem label="&staff.server.admin.index.fonts_and_sounds;" command="cmd_local_admin_fonts_and_sounds"/>
+                <menuitem type="checkbox" label="&staff.main.menu.admin.client.copy_editor.copy_location.label;" command="cmd_copy_editor_copy_location_first_toggle"/>
                 <menu id="main.menu.admin.client.hotkeys" label="&staff.main.menu.admin.client.hotkeys;">
                     <menupopup id="main.menu.admin.client.hotkeys.popup">
                         <menuitem label="&staff.main.menu.admin.client.hotkeys.toggle.label;" accesskey="&staff.main.menu.admin.client.hotkeys.toggle.accesskey;" type="checkbox" autocheck="false" command="cmd_hotkeys_toggle"/>
index 3870af4..bf3d517 100644 (file)
@@ -29,3 +29,6 @@ pref("open-ils.toolbar.defaultnewtab", false);
 
 // Template Toolkit Opac Enabled in Staff Client
 pref("oils.use_tpac", false);
+
+// Copy location name first in copy editor
+pref("oils.copy_editor.copy_location_name_first", false);
index b6b5d93..cf541ff 100644 (file)
@@ -52,6 +52,15 @@ function my_init() {
 
         g.callnumbers = xul_param('callnumbers',{'concat':true,'JSON2js_if_cgi':true,'JSON2js_if_xpcom':true,'stash_name':'temp_callnumbers','clear_xpcom':true,'modal_xulG':true});
 
+        /******************************************************************************************************/
+        /* Get preference (if it exists) for copy location label order */
+
+        g.cl_first = false; // Default to legacy OU first mode
+        var prefs = Components.classes['@mozilla.org/preferences-service;1']
+            .getService(Components.interfaces['nsIPrefBranch']);
+        try {
+            g.cl_first = prefs.getBoolPref('oils.copy_editor.copy_location_name_first');
+        } catch(E) { }
 
         /******************************************************************************************************/
         /* Quick fix, this was defined inline in the global scope but now needs g.error and g.copies from my_init */
@@ -929,7 +938,7 @@ g.panes_and_field_names = {
         $('catStrings').getString('staff.cat.copy_editor.field.location.label'),
         { 
             render: 'typeof fm.location() == "object" ? fm.location().name() : g.data.lookup("acpl",fm.location()).name()', 
-            input: 'c = function(v){ g.apply("location",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( util.functional.map_list( g.get_acpl_list(), function(obj) { return [ g.data.hash.aou[ obj.owning_lib() ].shortname() + " : " + obj.name(), obj.id() ]; }).sort()); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
+            input: 'c = function(v){ g.apply("location",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( util.functional.map_list( g.get_acpl_list(), function(obj) { return [ ' + (g.cl_first ? 'obj.name() + " : " + g.data.hash.aou[ obj.owning_lib() ].shortname()' : 'g.data.hash.aou[ obj.owning_lib() ].shortname() + " : " + obj.name()') + ', obj.id() ]; }).sort()); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
 
         }
     ],