Allow choice of default search pane
[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 adv_pane_box;
30         var prefSvc;
31         var data;
32         var saved_message;
33         var cleared_message;
34         function my_init() {
35             JSAN.use('OpenILS.data');
36             data = new OpenILS.data();
37             data.init({'via':'stash'});
38             search_lib_box = document.getElementById('search_lib');
39             pref_lib_box = document.getElementById('pref_lib');
40             adv_pane_box = document.getElementById('adv_pane');
41             // NOTE: If this ever deals with custom trees, this is where you likely want to mess with things.
42             add_aou(data.tree.aou, '');
43             prefSvc = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch).QueryInterface(Components.interfaces.nsIPrefBranch2);
44             saved_message = document.getElementById('saved_message').textContent;
45             cleared_message = document.getElementById('cleared_message').textContent;
46             if (data.search_lib) {
47                 search_lib_box.value = data.search_lib;
48             } else {
49                 search_lib_box.selectedIndex = 0;
50             }
51             if (data.pref_lib) {
52                 pref_lib_box.value = data.pref_lib;
53             } else {
54                 pref_lib_box.selectedIndex = 0;;
55             }
56             if (data.adv_pane) {
57                 adv_pane_box.value = data.adv_pane;
58             } else {
59                 adv_pane_box.selectedIndex = 0;
60             }
61         }
62         function add_aou(aou, depth) {
63             search_lib_box.appendItem(depth + aou.name(), aou.id(), '');
64             pref_lib_box.appendItem(depth + aou.name(), aou.id(), '');
65             for(var i = 0; i < aou.children().length; i++)
66                 add_aou(aou.children()[i], depth + '  ');
67         }
68         function update_prefs() {
69             prefSvc.setIntPref('open-ils.' + data.server_unadorned + '.search_lib', search_lib_box.value);
70             prefSvc.setIntPref('open-ils.' + data.server_unadorned + '.pref_lib', pref_lib_box.value);
71             prefSvc.setCharPref('open-ils.' + data.server_unadorned + '.adv_pane', adv_pane_box.value);
72             data.search_lib = search_lib_box.value;
73             data.pref_lib = pref_lib_box.value;
74             data.adv_pane = adv_pane_box.value;
75             data.stash('search_lib');
76             data.stash('pref_lib');
77             data.stash('adv_pane');
78             alert(saved_message);
79         }
80         function clear_prefs() {
81             prefSvc.clearUserPref('open-ils.' + data.server_unadorned + '.search_lib');
82             prefSvc.clearUserPref('open-ils.' + data.server_unadorned + '.pref_lib');
83             prefSvc.clearUserPref('open-ils.' + data.server_unadorned + '.adv_pane');
84             data.search_lib = null;
85             data.pref_lib = null;
86             data.adv_pane = null;
87             data.stash('search_lib');
88             data.stash('pref_lib');
89             data.stash('adv_pane');
90             alert(cleared_message);
91         }
92     ]]>
93     </script>
94     <commandset id="search_prefs_cmds">
95         <command id="save_search_prefs" oncommand="update_prefs()" />
96         <command id="clear_search_prefs" oncommand="clear_prefs()" />
97     </commandset>
98     <vbox id="search_prefs_main">
99         <groupbox>
100             <caption label="&staff.search_prefs.search_lib.caption;"/>
101             <description>&staff.search_prefs.search_lib.description;</description>
102             <menulist id="search_lib">
103                 <menupopup>
104                 </menupopup>
105             </menulist>
106         </groupbox>
107         <groupbox>
108             <caption label="&staff.search_prefs.pref_lib.caption;"/>
109             <description>&staff.search_prefs.pref_lib.description;</description>
110             <menulist id="pref_lib">
111                 <menupopup>
112                 </menupopup>
113             </menulist>
114         </groupbox>
115         <groupbox>
116             <caption label="&staff.search_prefs.adv_pane.caption;"/>
117             <description>&staff.search_prefs.adv_pane.description;</description>
118             <menulist id="adv_pane">
119                 <menupopup>
120                     <menuitem label="&staff.search_prefs.adv_pane.advanced;" value="advanced" />
121                     <menuitem label="&staff.search_prefs.adv_pane.numeric;" value="numeric" />
122                     <menuitem label="&staff.search_prefs.adv_pane.expert;" value="expert" />
123                 </menupopup>
124             </menulist>
125         </groupbox>
126         <button id="save_button" command="save_search_prefs" label="&staff.search_prefs.save.label;" accesskey="&staff.search_prefs.save.accesskey;"/>
127         <button id="clear_button" command="clear_search_prefs" label="&staff.search_prefs.clear.label;" accesskey="&staff.search_prefs.clear.accesskey;"/>
128     </vbox>
129     <description id="saved_message" style="display:none">&staff.search_prefs.saved_message;</description>
130     <description id="cleared_message" style="display:none">&staff.search_prefs.cleared_message;</description>
131 </window>