From: Thomas Berezansky Date: Wed, 14 Sep 2011 17:37:27 +0000 (-0400) Subject: Remember MARC Template selection X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=552003348b8401db102b971c0dc7df1a838faf99;p=evergreen%2Fequinox.git Remember MARC Template selection Implement both a workstation default and "last used" for the MARC template selector. Workstation default is set with a new "Set Workstation Default" button. "Last used" will override the workstation default, and is updated every time you load a template. It is forgotten when you close the client. Signed-off-by: Thomas Berezansky Signed-off-by: Dan Scott --- diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index 4714957fc3..741b58df46 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -2772,6 +2772,8 @@ + + diff --git a/Open-ILS/xul/staff_client/server/cat/marc_new.xul b/Open-ILS/xul/staff_client/server/cat/marc_new.xul index 633d047fb4..859f410558 100644 --- a/Open-ILS/xul/staff_client/server/cat/marc_new.xul +++ b/Open-ILS/xul/staff_client/server/cat/marc_new.xul @@ -64,13 +64,21 @@ var templates = g.network.simple_request('MARC_XML_TEMPLATE_LIST',[]); if (typeof templates.ilsevent != 'undefined') throw(templates); + var default_template; + g.prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces['nsIPrefBranch']); + var default_template_key = 'oils.marc_new.default_template'; + if(g.data.last_marc_template) default_template = g.data.last_marc_template; + if(!default_template) { + var has_key = g.prefs.prefHasUserValue(default_template_key); + if(has_key) default_template = g.prefs.getCharPref(default_template_key); + } var ml = util.widgets.make_menulist( util.functional.map_list( templates.sort(), function(el) { return [ el /* The menu entry label */, el /* The menu entry value */ ]; } - ) + ), default_template ); $('menu_placeholder').appendChild(ml); @@ -87,7 +95,11 @@ [ template_name ] ); if (typeof marc.ilsevent != 'undefined') throw(marc); - + + g.data.stash_retrieve(); + g.data.last_marc_template = template_name; + g.data.stash('last_marc_template'); + var url = urls.XUL_MARC_EDIT; var params = { 'record' : { 'marc' : marc }, @@ -164,6 +176,24 @@ false ); + $('set_default').addEventListener( + 'command', + function(ev) { + var template_name; + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + template_name = $('menu_placeholder').firstChild.value; + g.prefs.setCharPref(default_template_key, template_name); + alert(catStrings.getFormattedString('staff.cat.marc_new.set_default.success', [template_name])); + } catch (E) { + g.error.standard_unexpected_error_alert( + catStrings.getFormattedString('staff.cat.marc_new.set_default.error', [template_name]), E + ); + } + }, + false + ); + } catch(E) { g.error.standard_unexpected_error_alert('cat/marc_new.xul',E); } @@ -179,6 +209,7 @@