From c6612f7295ea429f6deec3005840e5bab099231a Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Thu, 29 Sep 2011 19:26:17 -0400 Subject: [PATCH] Reverse Copy Location picker labels via WS Setting 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 --- Open-ILS/web/opac/locale/en-US/lang.dtd | 1 + .../xul/staff_client/chrome/content/main/main.js | 1 + .../xul/staff_client/chrome/content/main/menu.js | 34 ++++++++++++++++++++++ .../chrome/content/main/menu_frame_menus.xul | 2 ++ .../xul/staff_client/defaults/preferences/prefs.js | 3 ++ .../xul/staff_client/server/cat/copy_editor.js | 11 ++++++- 6 files changed, 51 insertions(+), 1 deletion(-) diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index 69dba21fc1..732ed646f0 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -854,6 +854,7 @@ + diff --git a/Open-ILS/xul/staff_client/chrome/content/main/main.js b/Open-ILS/xul/staff_client/chrome/content/main/main.js index 123e3de467..abfea68536 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/main.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/main.js @@ -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/'); } 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 a68b9bf94d..dc55b431aa 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js @@ -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); } } 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 014ffab0aa..df499f3276 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 @@ -237,6 +237,7 @@ + @@ -402,6 +403,7 @@ + diff --git a/Open-ILS/xul/staff_client/defaults/preferences/prefs.js b/Open-ILS/xul/staff_client/defaults/preferences/prefs.js index 3870af4686..bf3d5171c4 100644 --- a/Open-ILS/xul/staff_client/defaults/preferences/prefs.js +++ b/Open-ILS/xul/staff_client/defaults/preferences/prefs.js @@ -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); diff --git a/Open-ILS/xul/staff_client/server/cat/copy_editor.js b/Open-ILS/xul/staff_client/server/cat/copy_editor.js index b6b5d93ae9..cf541ff12c 100644 --- a/Open-ILS/xul/staff_client/server/cat/copy_editor.js +++ b/Open-ILS/xul/staff_client/server/cat/copy_editor.js @@ -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);', } ], -- 2.11.0