]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/cat/marc_new.xul
Convert a few strings to entities or JS properties that had hitherto escaped our...
[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:noet:sw=4:ts=4:
6 -->
7
8 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
9 <!-- STYLESHEETS -->
10 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
11 <?xml-stylesheet href="chrome://open_ils_staff_client/skin/global.css" type="text/css"?>
12 <?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
13
14 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
15 <!-- LOCALIZATION -->
16 <!DOCTYPE window PUBLIC "" ""[
17         <!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
18 ]>
19
20 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
21 <!-- OVERLAYS -->
22 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
23
24 <window id="example_template_win" 
25         onload="try { my_init(); font_helper(); } catch(E) { alert(E); }"
26         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
27
28         <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
29         <!-- BEHAVIOR -->
30         <script type="text/javascript">
31                 var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};
32         </script>
33         <scripts id="openils_util_scripts"/>
34
35         <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
36         <script>
37         <![CDATA[
38                 var catStrings;
39
40                 function $(id) { return document.getElementById(id); }
41
42                 function my_init() {
43                         try {
44                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
45
46                                 /* load translatable strings for cataloging interfaces */
47                 catStrings = document.getElementById('catStrings');
48
49                                 if (typeof JSAN == 'undefined') { 
50                                         throw( $('commonStrings').getString('common.jsan.missing') );
51                                 }
52                                 JSAN.errorLevel = "die"; // none, warn, or die
53                                 JSAN.addRepository('/xul/server/');
54                                 JSAN.use('util.error'); g.error = new util.error();
55                                 g.error.sdump('D_TRACE','my_init() for example_template.xul');
56
57                                 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
58                                         try { window.xulG.set_tab_name(catStrings.getString('staff.cat.marc_new.tab_name')); } catch(E) { alert(E); }
59                                 }
60
61                                 JSAN.use('util.network'); g.network = new util.network();
62                                 JSAN.use('util.widgets');
63                                 JSAN.use('util.functional');
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                                                                 'save' : {
95                                                                         'label' : catStrings.getString('staff.cat.marc_new.create_record.label'),
96                                                                         'func' : function(new_marcxml) {
97                                                                                 try {
98                                                                                         var robj = g.network.simple_request(
99                                                                                                 'MARC_XML_RECORD_IMPORT',
100                                                                                                 [ ses(), new_marcxml, catStrings.getString('staff.cat.marc_new.system_local.label'), 1 ]
101                                                                                         );
102                                                                                         if (typeof robj.ilsevent != 'undefined') throw(robj);
103                                                                                         alert(catStrings.getString('staff.cat.marc_new.record_created.label'));
104
105                                                                                         /* Replace tab with OPAC-view of record */
106
107                                                                                         var opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + robj.id();
108                                                                                         var content_params = {
109                                                                                                 'session' : ses(),
110                                                                                                 'authtime' : ses('authtime'),
111                                                                                                 'opac_url' : opac_url
112                                                                                         };
113                                                                                         xulG.set_tab(
114                                                                                                 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
115                                                                                                 {'tab_name': catStrings.getString('staff.cat.marc_new.retrieving.label')},
116                                                                                                 content_params
117                                                                                         );
118
119                                                                                 } catch(E) {
120                                                                                         g.error.standard_unexpected_error_alert(
121                                                                                                 catStrings.getString('staff.cat.marc_new.creating_record.error'), E
122                                                                                         );
123                                                                                 }
124                                                                         }
125                                                                 }
126                                                         };
127                                                         $('marc_editor').setAttribute('src',url);
128                                                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
129                                                         get_contentWindow($('marc_editor')).xulG = params;
130
131                                                         /* hide template widgets */
132                                                         $('actions').hidden = true;
133
134                                                         window.xulG.set_tab_name(template_name);
135
136                                                 } catch(E) {
137                                                         g.error.standard_unexpected_error_alert(
138                                                                 catStrings.getFormattedString('staff.cat.marc_new.loading_template.error', [template_name]), E
139                                                         );
140                                                 }
141
142                                         },
143                                         false
144                                 );
145
146                         } catch(E) {
147                                 g.error.standard_unexpected_error_alert('cat/marc_new.xul',E);
148                         }
149                 }
150
151         ]]>
152         </script>
153
154         <messagecatalog id="catStrings" src="/xul/server/locale/<!--#echo var='locale'-->/cat.properties" />
155         <messagecatalog id="circStrings" src="/xul/server/locale/<!--#echo var='locale'-->/circ.properties" />
156         <messagecatalog id="commonStrings" src="/xul/server/locale/<!--#echo var='locale'-->/common.properties" />
157
158         <vbox flex="1">
159                 <hbox id="actions">
160                         <hbox id="menu_placeholder" />
161                         <button id="load" label="&staff.cat.marc_new.load.label;" accesskey="&staff.cat.marc_new.load.accesskey;"/>
162                 </hbox>
163                 <iframe id="marc_editor" flex="1"/>
164         </vbox>
165
166 </window>
167