]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/cat/marc_new.xul
rethinking record bucket interface
[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 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
6 <!-- STYLESHEETS -->
7 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
8 <?xml-stylesheet href="chrome://open_ils_staff_client/skin/global.css" type="text/css"?>
9 <?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
10
11 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
12 <!-- LOCALIZATION -->
13 <!DOCTYPE window PUBLIC "" ""[
14         <!--#include virtual="/opac/locale/en-US/lang.dtd"-->
15 ]>
16
17 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
18 <!-- OVERLAYS -->
19 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
20
21 <window id="example_template_win" 
22         onload="try { my_init(); font_helper(); } catch(E) { alert(E); }"
23         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
24
25         <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
26         <!-- BEHAVIOR -->
27         <script type="text/javascript">
28                 var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};
29         </script>
30         <scripts id="openils_util_scripts"/>
31
32         <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
33         <script>
34         <![CDATA[
35
36                 function $(id) { return document.getElementById(id); }
37
38                 function my_init() {
39                         try {
40                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
41                 if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
42                                 JSAN.errorLevel = "die"; // none, warn, or die
43                                 JSAN.addRepository('/xul/server/');
44                                 JSAN.use('util.error'); g.error = new util.error();
45                                 g.error.sdump('D_TRACE','my_init() for example_template.xul');
46
47                                 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
48                                         try { window.xulG.set_tab_name('MARC Template'); } catch(E) { alert(E); }
49                                 }
50
51                                 JSAN.use('util.network'); g.network = new util.network();
52                                 JSAN.use('util.widgets');
53                                 JSAN.use('util.functional');
54
55                                 var templates = g.network.simple_request('MARC_XML_TEMPLATE_LIST',[]);
56                                 if (typeof templates.ilsevent != 'undefined') throw(templates);
57                                 var ml = util.widgets.make_menulist(
58                                         util.functional.map_list(
59                                                 templates.sort(),
60                                                 function(el) {
61                                                         return [ el /* The menu entry label */, el /* The menu entry value */ ];
62                                                 }
63                                         )
64                                 );
65                                 $('menu_placeholder').appendChild(ml);
66
67                                 $('load').addEventListener(
68                                         'command',
69                                         function(ev) {
70
71                                                 var template_name;
72                                                 try {
73
74                                                         template_name = $('menu_placeholder').firstChild.value;
75                                                         var marc = g.network.simple_request(
76                                                                 'MARC_XML_TEMPLATE_RETRIEVE',
77                                                                 [ template_name ]
78                                                         );
79                                                         if (typeof marc.ilsevent != 'undefined') throw(marc);
80         
81                                                         var url = urls.XUL_MARC_EDIT;
82                                                         var params = {
83                                                                 'record' : { 'marc' : marc },
84                                                                 'save' : {
85                                                                         'label' : 'Create Record',
86                                                                         'func' : function(new_marcxml) {
87                                                                                 try {
88                                                                                         var robj = g.network.simple_request(
89                                                                                                 'MARC_XML_RECORD_IMPORT',
90                                                                                                 [ ses(), new_marcxml, 'System Local', 1 ]
91                                                                                         );
92                                                                                         if (typeof robj.ilsevent != 'undefined') throw(robj);
93                                                                                         alert('Record created.');
94
95                                                                                         /* Replace tab with OPAC-view of record */
96
97                                                                                         var opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + robj.id();
98                                                                                         var content_params = {
99                                                                                                 'session' : ses(),
100                                                                                                 'authtime' : ses('authtime'),
101                                                                                                 'opac_url' : opac_url,
102                                                                                         };
103                                                                                         xulG.set_tab(
104                                                                                                 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
105                                                                                                 {'tab_name':'Retrieving title...'},
106                                                                                                 content_params
107                                                                                         );
108
109                                                                                 } catch(E) {
110                                                                                         g.error.standard_unexpected_error_alert(
111                                                                                                 'Error creating MARC record.', E
112                                                                                         );
113                                                                                 }
114                                                                         }
115                                                                 }
116                                                         };
117                                                         $('marc_editor').setAttribute('src',url);
118                                                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
119                                                         get_contentWindow($('marc_editor')).xulG = params;
120
121                                                         /* hide template widgets */
122                                                         $('actions').hidden = true;
123
124                                                         window.xulG.set_tab_name(template_name);
125
126                                                 } catch(E) {
127                                                         g.error.standard_unexpected_error_alert(
128                                                                 'Error loading MARC template: ' + template_name,
129                                                                 E
130                                                         );
131                                                 }
132
133                                         },
134                                         false
135                                 );
136
137                         } catch(E) {
138                                 g.error.standard_unexpected_error_alert('cat/marc_new.xul',E);
139                         }
140                 }
141
142         ]]>
143         </script>
144
145         <vbox flex="1">
146                 <hbox id="actions">
147                         <hbox id="menu_placeholder" />
148                         <button id="load" label="Load" accesskey="L"/>
149                 </hbox>
150                 <iframe id="marc_editor" flex="1"/>
151         </vbox>
152
153 </window>
154