From 3d358abbf1d069e66476e7edb21d6c43428521db 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 Conflicts: Open-ILS/xul/staff_client/chrome/content/main/menu.js Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul Signed-off-by: Dan Scott --- Open-ILS/web/opac/locale/en-US/lang.dtd | 1 + .../staff_client/chrome/content/main/main.js | 1 + .../staff_client/chrome/content/main/menu.js | 34 +++++++++++++++++++ .../chrome/content/main/menu_frame_menus.xul | 2 ++ .../defaults/preferences/prefs.js | 3 ++ .../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 e9a63bfab2..9e9187073d 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -855,6 +855,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 95984844a8..c6b8b8d05a 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/main.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/main.js @@ -321,6 +321,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 fe93b18793..ac82ea4868 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'); @@ -1653,6 +1661,13 @@ main.menu.prototype = { } } ], + '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'); @@ -2436,6 +2451,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 33b171ac56..5cc71b8443 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 @@ -263,6 +263,7 @@ + @@ -428,6 +429,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.43.2