]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/chrome/content/main/search_prefs.xul
LP#1406370 Set Search Preferences Ordered by Name
[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             if (aou.children().length > 0) {
64                 aou.children().sort(function(a, b) {
65                     if (a.name() < b.name()) return -1;
66                     if (a.name() > b.name()) return 1;
67                     return 0;
68                 });
69             }
70             search_lib_box.appendItem(depth + aou.name(), aou.id(), '');
71             pref_lib_box.appendItem(depth + aou.name(), aou.id(), '');
72             for(var i = 0; i < aou.children().length; i++)
73                 add_aou(aou.children()[i], depth + '  ');
74         }
75         function update_prefs() {
76             prefSvc.setIntPref('open-ils.' + data.server_unadorned + '.search_lib', search_lib_box.value);
77             prefSvc.setIntPref('open-ils.' + data.server_unadorned + '.pref_lib', pref_lib_box.value);
78             prefSvc.setCharPref('open-ils.' + data.server_unadorned + '.adv_pane', adv_pane_box.value);
79             data.search_lib = search_lib_box.value;
80             data.pref_lib = pref_lib_box.value;
81             data.adv_pane = adv_pane_box.value;
82             data.stash('search_lib');
83             data.stash('pref_lib');
84             data.stash('adv_pane');
85             alert(saved_message);
86         }
87         function clear_prefs() {
88             prefSvc.clearUserPref('open-ils.' + data.server_unadorned + '.search_lib');
89             prefSvc.clearUserPref('open-ils.' + data.server_unadorned + '.pref_lib');
90             prefSvc.clearUserPref('open-ils.' + data.server_unadorned + '.adv_pane');
91             data.search_lib = null;
92             data.pref_lib = null;
93             data.adv_pane = null;
94             data.stash('search_lib');
95             data.stash('pref_lib');
96             data.stash('adv_pane');
97             alert(cleared_message);
98         }
99     ]]>
100     </script>
101     <commandset id="search_prefs_cmds">
102         <command id="save_search_prefs" oncommand="update_prefs()" />
103         <command id="clear_search_prefs" oncommand="clear_prefs()" />
104     </commandset>
105     <vbox id="search_prefs_main">
106         <groupbox>
107             <caption label="&staff.search_prefs.search_lib.caption;"/>
108             <description>&staff.search_prefs.search_lib.description;</description>
109             <menulist id="search_lib">
110                 <menupopup>
111                 </menupopup>
112             </menulist>
113         </groupbox>
114         <groupbox>
115             <caption label="&staff.search_prefs.pref_lib.caption;"/>
116             <description>&staff.search_prefs.pref_lib.description;</description>
117             <menulist id="pref_lib">
118                 <menupopup>
119                 </menupopup>
120             </menulist>
121         </groupbox>
122         <groupbox>
123             <caption label="&staff.search_prefs.adv_pane.caption;"/>
124             <description>&staff.search_prefs.adv_pane.description;</description>
125             <menulist id="adv_pane">
126                 <menupopup>
127                     <menuitem label="&staff.search_prefs.adv_pane.advanced;" value="advanced" />
128                     <menuitem label="&staff.search_prefs.adv_pane.numeric;" value="numeric" />
129                     <menuitem label="&staff.search_prefs.adv_pane.expert;" value="expert" />
130                 </menupopup>
131             </menulist>
132         </groupbox>
133         <button id="save_button" command="save_search_prefs" label="&staff.search_prefs.save.label;" accesskey="&staff.search_prefs.save.accesskey;"/>
134         <button id="clear_button" command="clear_search_prefs" label="&staff.search_prefs.clear.label;" accesskey="&staff.search_prefs.clear.accesskey;"/>
135     </vbox>
136     <description id="saved_message" style="display:none">&staff.search_prefs.saved_message;</description>
137     <description id="cleared_message" style="display:none">&staff.search_prefs.cleared_message;</description>
138 </window>