]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/cat/marc_new.xul
remove some speedbump dialogs
[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="/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(); } 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
64                 var templates = g.network.simple_request('MARC_XML_TEMPLATE_LIST',[]);
65                 if (typeof templates.ilsevent != 'undefined') throw(templates);
66                 var ml = util.widgets.make_menulist(
67                     util.functional.map_list(
68                         templates.sort(),
69                         function(el) {
70                             return [ el /* The menu entry label */, el /* The menu entry value */ ];
71                         }
72                     )
73                 );
74                 $('menu_placeholder').appendChild(ml);
75
76                 $('load').addEventListener(
77                     'command',
78                     function(ev) {
79
80                         var template_name;
81                         try {
82
83                             template_name = $('menu_placeholder').firstChild.value;
84                             var marc = g.network.simple_request(
85                                 'MARC_XML_TEMPLATE_RETRIEVE',
86                                 [ template_name ]
87                             );
88                             if (typeof marc.ilsevent != 'undefined') throw(marc);
89     
90                             var url = urls.XUL_MARC_EDIT;
91                             var params = {
92                                 'record' : { 'marc' : marc },
93                                 'fast_add_item' : function(doc_id,cn_label,cp_barcode) {
94                                     try {
95                                         JSAN.use('cat.util'); return cat.util.fast_item_add(doc_id,cn_label,cp_barcode);
96                                     } catch(E) {
97                                         alert(E);
98                                     }
99                                 },
100                                 'save' : {
101                                     'label' : catStrings.getString('staff.cat.marc_new.create_record.label'),
102                                     'func' : function(new_marcxml) {
103                                         try {
104                                             var robj = g.network.simple_request(
105                                                 'MARC_XML_RECORD_IMPORT',
106                                                 [ ses(), new_marcxml, catStrings.getString('staff.cat.marc_new.system_local.label'), 1 ]
107                                             );
108                                             if (typeof robj.ilsevent != 'undefined') throw(robj);
109
110                                             /* Replace tab with OPAC-view of record */
111
112                                             var opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + robj.id();
113                                             var content_params = {
114                                                 'session' : ses(),
115                                                 'authtime' : ses('authtime'),
116                                                 'opac_url' : opac_url
117                                             };
118                                             return { 
119                                                 'id' : robj.id(), 
120                                                 'on_complete' : function() {
121                                                     try {
122                                                         xulG.set_tab(
123                                                             xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
124                                                             {'tab_name': catStrings.getString('staff.cat.marc_new.retrieving.label')},
125                                                             content_params
126                                                         );
127                                                     } catch(E) {
128                                                         alert(E);
129                                                     } 
130                                                 }
131                                             };
132
133                                         } catch(E) {
134                                             g.error.standard_unexpected_error_alert(
135                                                 catStrings.getString('staff.cat.marc_new.creating_record.error'), E
136                                             );
137                                         }
138                                     }
139                                 }
140                             };
141                             var marc_editor = document.createElement('iframe');
142                             $('marc_editor_box').appendChild(marc_editor);
143                             marc_editor.setAttribute('flex','1');
144                             marc_editor.setAttribute('src',url);
145                             netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
146                             get_contentWindow(marc_editor).xulG = params;
147
148                             /* hide template widgets */
149                             $('actions').hidden = true;
150
151                             window.xulG.set_tab_name(template_name);
152
153                         } catch(E) {
154                             g.error.standard_unexpected_error_alert(
155                                 catStrings.getFormattedString('staff.cat.marc_new.loading_template.error', [template_name]), E
156                             );
157                         }
158
159                     },
160                     false
161                 );
162
163             } catch(E) {
164                 g.error.standard_unexpected_error_alert('cat/marc_new.xul',E);
165             }
166         }
167
168     ]]>
169     </script>
170
171     <messagecatalog id="catStrings" src="/xul/server/locale/<!--#echo var='locale'-->/cat.properties" />
172     <messagecatalog id="circStrings" src="/xul/server/locale/<!--#echo var='locale'-->/circ.properties" />
173
174     <vbox id="marc_editor_box" flex="1">
175         <hbox id="actions">
176             <hbox id="menu_placeholder" />
177             <button id="load" label="&staff.cat.marc_new.load.label;" accesskey="&staff.cat.marc_new.load.accesskey;"/>
178         </hbox>
179     </vbox>
180
181 </window>
182