Allow staff to pick search/pref libraries
[working/Evergreen.git] / Open-ILS / xul / staff_client / chrome / content / main / search_prefs.xul
1 <?xml version="1.0"?>
2 <!-- Application: Evergreen Staff Client -->
3 <!-- Screen: Workstation level search preferences -->
4 <!--
5  vim:noet:sw=4:ts=4:
6 -->
7
8 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
9 <?xml-stylesheet href="chrome://open_ils_staff_client/skin/global.css" type="text/css"?>
10
11 <!DOCTYPE window SYSTEM "chrome://open_ils_staff_client/locale/lang.dtd">
12
13 <?xul-overlay href="chrome://open_ils_staff_client/content/OpenILS/util_overlay_chrome.xul"?>
14
15 <window id="search_prefs_diag" 
16     onload="try { my_init(); } catch(E) { alert(E); }"
17     xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
18     <script type="text/javascript">
19         var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true;
20     </script>
21     <scripts id="openils_util_scripts"/>
22     <script type="text/javascript" src="JSAN.js"/>
23
24     <script>
25     <![CDATA[
26         var g = {};
27         var search_lib_box;
28         var pref_lib_box;
29         var prefSvc;
30         var data;
31         var saved_message;
32         function my_init() {
33             JSAN.use('OpenILS.data');
34             data = new OpenILS.data();
35             data.init({'via':'stash'});
36             search_lib_box = document.getElementById('search_lib');
37             pref_lib_box = document.getElementById('pref_lib');
38             // NOTE: If this ever deals with custom trees, this is where you likely want to mess with things.
39             add_aou(data.tree.aou, '');
40             prefSvc = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch).QueryInterface(Components.interfaces.nsIPrefBranch2);
41             saved_message = document.getElementById('saved_message').textContent;
42             if (data.search_lib) {
43                 search_lib_box.value = data.search_lib;
44                 pref_lib_box.value = data.pref_lib;
45             } else {
46                 search_lib_box.selectedIndex = 0;
47                 pref_lib_box.selectedIndex = 0;;
48             }
49         }
50         function add_aou(aou, depth) {
51             search_lib_box.appendItem(depth + aou.name(), aou.id(), '');
52             pref_lib_box.appendItem(depth + aou.name(), aou.id(), '');
53             for(var i = 0; i < aou.children().length; i++)
54                 add_aou(aou.children()[i], depth + '  ');
55         }
56         function update_prefs() {
57             prefSvc.setIntPref('open-ils.' + data.server_unadorned + '.search_lib', search_lib_box.value);
58             prefSvc.setIntPref('open-ils.' + data.server_unadorned + '.pref_lib', pref_lib_box.value);
59             data.search_lib = search_lib_box.value;
60             data.pref_lib = pref_lib_box.value;
61             data.stash('search_lib');
62             data.stash('pref_lib');
63             alert(saved_message);
64         }
65     ]]>
66     </script>
67     <commandset id="search_prefs_cmds">
68         <command id="save_search_prefs" oncommand="update_prefs()" />
69     </commandset>
70     <vbox id="search_prefs_main">
71         <groupbox>
72             <caption label="&staff.search_prefs.search_lib.caption;"/>
73             <description>&staff.search_prefs.search_lib.description;</description>
74             <menulist id="search_lib">
75                 <menupopup>
76                 </menupopup>
77             </menulist>
78         </groupbox>
79         <groupbox>
80             <caption label="&staff.search_prefs.pref_lib.caption;"/>
81             <description>&staff.search_prefs.pref_lib.description;</description>
82             <menulist id="pref_lib">
83                 <menupopup>
84                 </menupopup>
85             </menulist>
86         </groupbox>
87         <button id="save_button" command="save_search_prefs" label="&staff.search_prefs.save.label;" accesskey="&staff.search_prefs.save.accesskey;"/>
88     </vbox>
89     <description id="saved_message" style="display:none">&staff.search_prefs.saved_message;</description>
90 </window>