]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/cat/marc_new.xul
Add cointainer() and record_list() filters to QueryParser
[Evergreen.git] / Open-ILS / xul / staff_client / server / cat / marc_new.xul
1 <?xml version="1.0"?>
2 <!-- Application: Evergreen Staff Client -->
3 <!-- Screen: Example Template for remote xul -->
4 <!--
5     vim:et:sw=4:ts=4:
6 -->
7
8 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
9 <!-- STYLESHEETS -->
10 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
11 <?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
12
13 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
14 <!-- LOCALIZATION -->
15 <!DOCTYPE window PUBLIC "" ""[
16     <!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
17 ]>
18
19 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
20 <!-- OVERLAYS -->
21 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
22
23 <window id="example_template_win" 
24     onload="try { my_init(); font_helper(); persist_helper(); } catch(E) { alert(E); }"
25     xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
26
27     <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
28     <!-- BEHAVIOR -->
29         <script type="text/javascript">
30         var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};
31     </script>
32         <scripts id="openils_util_scripts"/>
33
34     <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
35     <script>
36     <![CDATA[
37         var catStrings;
38
39         function $(id) { return document.getElementById(id); }
40
41         function my_init() {
42             try {
43                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
44
45                 /* load translatable strings for cataloging interfaces */
46                 catStrings = document.getElementById('catStrings');
47
48                 if (typeof JSAN == 'undefined') { 
49                     throw( $('commonStrings').getString('common.jsan.missing') );
50                 }
51                 JSAN.errorLevel = "die"; // none, warn, or die
52                 JSAN.addRepository('/xul/server/');
53                 JSAN.use('util.error'); g.error = new util.error();
54                 g.error.sdump('D_TRACE','my_init() for example_template.xul');
55
56                 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
57                     try { window.xulG.set_tab_name(catStrings.getString('staff.cat.marc_new.tab_name')); } catch(E) { alert(E); }
58                 }
59
60                 JSAN.use('util.network'); g.network = new util.network();
61                 JSAN.use('util.widgets');
62                 JSAN.use('util.functional');
63                 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
64
65                 var templates = g.network.simple_request('MARC_XML_TEMPLATE_LIST',[]);
66                 if (typeof templates.ilsevent != 'undefined') throw(templates);
67                 var ml = util.widgets.make_menulist(
68                     util.functional.map_list(
69                         templates.sort(),
70                         function(el) {
71                             return [ el /* The menu entry label */, el /* The menu entry value */ ];
72                         }
73                     )
74                 );
75                 $('menu_placeholder').appendChild(ml);
76
77                 $('load').addEventListener(
78                     'command',
79                     function(ev) {
80
81                         var template_name;
82                         try {
83
84                             template_name = $('menu_placeholder').firstChild.value;
85                             var marc = g.network.simple_request(
86                                 'MARC_XML_TEMPLATE_RETRIEVE',
87                                 [ template_name ]
88                             );
89                             if (typeof marc.ilsevent != 'undefined') throw(marc);
90     
91                             var url = urls.XUL_MARC_EDIT;
92                             var params = {
93                                 'record' : { 'marc' : marc },
94                                 'marc_control_number_identifier': g.data.hash.aous['cat.marc_control_number_identifier'] || 'Set cat.marc_control_number_identifier in Library Settings',
95                                 'fast_add_item' : function(doc_id,cn_label,cp_barcode) {
96                                     try {
97                                         JSAN.use('cat.util'); return cat.util.fast_item_add(doc_id,cn_label,cp_barcode);
98                                     } catch(E) {
99                                         alert(E);
100                                     }
101                                 },
102                                 'save' : {
103                                     'label' : catStrings.getString('staff.cat.marc_new.create_record.label'),
104                                     'func' : function(new_marcxml) {
105                                         try {
106                                             var robj = g.network.simple_request(
107                                                 'MARC_XML_RECORD_IMPORT',
108                                                 [ ses(), new_marcxml, catStrings.getString('staff.cat.marc_new.system_local.label'), 1 ]
109                                             );
110                                             if (typeof robj.ilsevent != 'undefined') throw(robj);
111
112                                             /* Replace tab with OPAC-view of record */
113
114                                             var opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + robj.id();
115                                             var content_params = {
116                                                 'session' : ses(),
117                                                 'authtime' : ses('authtime'),
118                                                 'opac_url' : opac_url
119                                             };
120                                             return { 
121                                                 'id' : robj.id(), 
122                                                 'on_complete' : function() {
123                                                     try {
124                                                         xulG.set_tab(
125                                                             xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
126                                                             {'tab_name': catStrings.getString('staff.cat.marc_new.retrieving.label')},
127                                                             content_params
128                                                         );
129                                                     } catch(E) {
130                                                         alert(E);
131                                                     } 
132                                                 }
133                                             };
134
135                                         } catch(E) {
136                                             g.error.standard_unexpected_error_alert(
137                                                 catStrings.getString('staff.cat.marc_new.creating_record.error'), E
138                                             );
139                                         }
140                                     }
141                                 },
142                                 'lock_tab' : xulG.lock_tab,
143                                 'unlock_tab' : xulG.unlock_tab
144                             };
145                             var marc_editor = document.createElement('iframe');
146                             $('marc_editor_box').appendChild(marc_editor);
147                             marc_editor.setAttribute('flex','1');
148                             marc_editor.setAttribute('src',url);
149                             netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
150                             get_contentWindow(marc_editor).xulG = params;
151
152                             /* hide template widgets */
153                             $('actions').hidden = true;
154
155                             window.xulG.set_tab_name(template_name);
156
157                         } catch(E) {
158                             g.error.standard_unexpected_error_alert(
159                                 catStrings.getFormattedString('staff.cat.marc_new.loading_template.error', [template_name]), E
160                             );
161                         }
162
163                     },
164                     false
165                 );
166
167             } catch(E) {
168                 g.error.standard_unexpected_error_alert('cat/marc_new.xul',E);
169             }
170         }
171
172     ]]>
173     </script>
174
175     <messagecatalog id="catStrings" src="/xul/server/locale/<!--#echo var='locale'-->/cat.properties" />
176     <messagecatalog id="circStrings" src="/xul/server/locale/<!--#echo var='locale'-->/circ.properties" />
177
178     <vbox id="marc_editor_box" flex="1">
179         <hbox id="actions">
180             <hbox id="menu_placeholder" />
181             <button id="load" label="&staff.cat.marc_new.load.label;" accesskey="&staff.cat.marc_new.load.accesskey;"/>
182         </hbox>
183     </vbox>
184
185 </window>
186