]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/cat/marc_new.xul
i18n for the MARC editor
[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
39                 function $(id) { return document.getElementById(id); }
40
41                 function my_init() {
42                         try {
43                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
44                                 if (typeof JSAN == 'undefined') { 
45                                         throw( document.getElementById('commonStrings').getString('common.jsan.missing') );
46                                 }
47                                 JSAN.errorLevel = "die"; // none, warn, or die
48                                 JSAN.addRepository('/xul/server/');
49                                 JSAN.use('util.error'); g.error = new util.error();
50                                 g.error.sdump('D_TRACE','my_init() for example_template.xul');
51
52                                 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
53                                         try { window.xulG.set_tab_name('MARC Template'); } catch(E) { alert(E); }
54                                 }
55
56                                 JSAN.use('util.network'); g.network = new util.network();
57                                 JSAN.use('util.widgets');
58                                 JSAN.use('util.functional');
59
60                                 var templates = g.network.simple_request('MARC_XML_TEMPLATE_LIST',[]);
61                                 if (typeof templates.ilsevent != 'undefined') throw(templates);
62                                 var ml = util.widgets.make_menulist(
63                                         util.functional.map_list(
64                                                 templates.sort(),
65                                                 function(el) {
66                                                         return [ el /* The menu entry label */, el /* The menu entry value */ ];
67                                                 }
68                                         )
69                                 );
70                                 $('menu_placeholder').appendChild(ml);
71
72                                 $('load').addEventListener(
73                                         'command',
74                                         function(ev) {
75
76                                                 var template_name;
77                                                 try {
78
79                                                         template_name = $('menu_placeholder').firstChild.value;
80                                                         var marc = g.network.simple_request(
81                                                                 'MARC_XML_TEMPLATE_RETRIEVE',
82                                                                 [ template_name ]
83                                                         );
84                                                         if (typeof marc.ilsevent != 'undefined') throw(marc);
85         
86                                                         var url = urls.XUL_MARC_EDIT;
87                                                         var params = {
88                                                                 'record' : { 'marc' : marc },
89                                                                 'save' : {
90                                                                         'label' : $('catStrings').getString('staff.cat.marc_new.create_record.label'),
91                                                                         'func' : function(new_marcxml) {
92                                                                                 try {
93                                                                                         var robj = g.network.simple_request(
94                                                                                                 'MARC_XML_RECORD_IMPORT',
95                                                                                                 [ ses(), new_marcxml, $('catStrings').getString('staff.cat.marc_new.system_local.label'), 1 ]
96                                                                                         );
97                                                                                         if (typeof robj.ilsevent != 'undefined') throw(robj);
98                                                                                         alert($('catStrings').getString('staff.cat.marc_new.record_created.label'));
99
100                                                                                         /* Replace tab with OPAC-view of record */
101
102                                                                                         var opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + robj.id();
103                                                                                         var content_params = {
104                                                                                                 'session' : ses(),
105                                                                                                 'authtime' : ses('authtime'),
106                                                                                                 'opac_url' : opac_url,
107                                                                                         };
108                                                                                         xulG.set_tab(
109                                                                                                 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
110                                                                                                 {'tab_name': $('catStrings').getString('staff.cat.marc_new.retrieving.label')},
111                                                                                                 content_params
112                                                                                         );
113
114                                                                                 } catch(E) {
115                                                                                         g.error.standard_unexpected_error_alert(
116                                                                                                 $('catStrings').getString('staff.cat.marc_new.creating_record.error'), E
117                                                                                         );
118                                                                                 }
119                                                                         }
120                                                                 }
121                                                         };
122                                                         $('marc_editor').setAttribute('src',url);
123                                                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
124                                                         get_contentWindow($('marc_editor')).xulG = params;
125
126                                                         /* hide template widgets */
127                                                         $('actions').hidden = true;
128
129                                                         window.xulG.set_tab_name(template_name);
130
131                                                 } catch(E) {
132                                                         g.error.standard_unexpected_error_alert(
133                                                                 $('catStrings').getFormattedString('staff.cat.marc_new.loading_template.error', [template_name]), E
134                                                         );
135                                                 }
136
137                                         },
138                                         false
139                                 );
140
141                         } catch(E) {
142                                 g.error.standard_unexpected_error_alert('cat/marc_new.xul',E);
143                         }
144                 }
145
146         ]]>
147         </script>
148
149         <messagecatalog id="catStrings" src="/xul/server/locale/<!--#echo var='locale'-->/cat.properties" />
150         <messagecatalog id="circStrings" src="/xul/server/locale/<!--#echo var='locale'-->/circ.properties" />
151         <messagecatalog id="commonStrings" src="/xul/server/locale/<!--#echo var='locale'-->/common.properties" />
152
153         <vbox flex="1">
154                 <hbox id="actions">
155                         <hbox id="menu_placeholder" />
156                         <button id="load" label="&staff.cat.marc_new.load.label;" accesskey="&staff.cat.marc_new.load.accesskey;"/>
157                 </hbox>
158                 <iframe id="marc_editor" flex="1"/>
159         </vbox>
160
161 </window>
162