]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/cat/bib_brief.js
org unit setting for making unified Volume/Item interface optional. fix the volume...
[working/Evergreen.git] / Open-ILS / xul / staff_client / server / cat / bib_brief.js
1 var docid;
2
3 function my_init() {
4     try {
5         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
6         if (typeof JSAN == 'undefined') { throw( document.getElementById("commonStrings").getString('common.jsan.missing') ); }
7         JSAN.errorLevel = "die"; // none, warn, or die
8         JSAN.addRepository('/xul/server/');
9         JSAN.use('util.error'); g.error = new util.error();
10         g.error.sdump('D_TRACE','my_init() for cat_bib_brief.xul');
11
12         JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
13
14         docid = xul_param('docid');
15
16         var key = location.pathname + location.search + location.hash;
17         if (!docid && typeof g.data.modal_xulG_stack != 'undefined' && typeof g.data.modal_xulG_stack[key] != 'undefined') {
18             var xulG = g.data.modal_xulG_stack[key][ g.data.modal_xulG_stack[key].length - 1 ];
19             if (typeof xulG == 'object') {
20                 docid = xulG.docid;
21             }
22         }
23
24         JSAN.use('util.network'); g.network = new util.network();
25         JSAN.use('util.date');
26
27         document.getElementById('caption').setAttribute('tooltiptext',document.getElementById('catStrings').getFormattedString('staff.cat.bib_brief.record_id', [docid]));
28
29         if (docid > -1) {
30
31             g.data.last_record = docid; g.data.stash('last_record');
32
33             g.network.simple_request(
34                 'MODS_SLIM_RECORD_RETRIEVE.authoritative',
35                 [ docid ],
36                 function (req) {
37                     var mods = req.getResultObject();
38                     
39                     if (window.xulG && typeof window.xulG.set_tab_name == 'function') {
40                         try {
41                             window.xulG.set_tab_name(mods.tcn());
42                         } catch(E) {
43                             g.error.sdump('D_ERROR','bib_brief.xul, set_tab: ' + E);
44                         }
45                     }
46
47                     g.network.simple_request(
48                         'FM_BRE_RETRIEVE_VIA_ID.authoritative',
49                         [ ses(), [ docid ] ],
50                         function (req) {
51                             try {
52                                 var meta = req.getResultObject();
53                                 if (typeof meta.ilsevent != 'undefined') throw(meta);
54                                 meta = meta[0];
55                                 var t = document.getElementById('caption').getAttribute('label');
56                                 if (get_bool( meta.deleted() )) { 
57                                     t += ' ' + document.getElementById('catStrings').getString('staff.cat.bib_brief.deleted') + ' '; 
58                                     document.getElementById('caption').setAttribute('style','background: red; color: white;');
59                                 }
60                                 if ( ! get_bool( meta.active() ) ) { 
61                                     t += ' ' + document.getElementById('catStrings').getString('staff.cat.bib_brief.inactive') + ' '; 
62                                     document.getElementById('caption').setAttribute('style','background: red; color: white;');
63                                 }
64                                 document.getElementById('caption').setAttribute('label',t);
65
66                                 bib_brief_overlay( { 'mvr' : mods, 'bre' : meta } );
67
68                             } catch(E) {
69                                 g.error.standard_unexpected_error_alert('meta retrieve',E);
70                             }
71                         }
72                     );
73                 }
74             );
75
76         } else {
77             var t = document.getElementById('caption').getAttribute('label');
78             t += ' ' + document.getElementById('catStrings').getString('staff.cat.bib_brief.noncat') + ' '; 
79             document.getElementById('caption').setAttribute('style','background: red; color: white;');
80             document.getElementById('caption').setAttribute('label',t);
81         }
82
83     } catch(E) {
84         var err_msg = document.getElementById("commonStrings").getFormattedString('common.exception', ['cat/bib_brief.xul', E]);
85         try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
86         alert(err_msg);
87     }
88 }
89
90 function unhide_add_volumes_button() {
91     if (xulG && typeof xulG == 'object' && typeof xulG['new_tab'] == 'function') {
92         document.getElementById('add_volumes').hidden = false;
93         document.getElementById('add_volumes_left_paren').hidden = false;
94         document.getElementById('add_volumes_right_paren').hidden = false;
95     }
96 }
97
98 function view_marc() {
99     try {
100         JSAN.use('util.window'); var win = new util.window();
101         if (docid < 0) {
102             alert(document.getElementById("catStrings").getString('staff.cat.bib_brief.noncat.alert'));
103         } else {
104             netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
105             //win.open( urls.XUL_MARC_VIEW + '?noprint=1&docid=' + docid, 'marc_view', 'chrome,resizable,modal,width=400,height=400');
106             win.open( urls.XUL_MARC_VIEW, 'marc_view', 'chrome,resizable,modal,width=400,height=400',{'noprint':1,'docid':docid});
107         }
108     } catch(E) {
109         g.error.standard_unexpected_error_alert('spawning marc display',E);
110     }
111 }
112
113 function spawn_patron(span) {
114     try {
115         if (typeof window.xulG == 'object' && typeof window.xulG.set_patron_tab == 'function') {
116             window.xulG.set_patron_tab( {}, { 'id' : span.getAttribute('au_id') } );
117         } else {
118             copy_to_clipboard( span.textContent );
119         }
120     } catch(E) {
121         g.error.standard_unexpected_error_alert('spawning patron display',E);
122     }
123 }
124
125 function add_volumes() {
126     try {
127         var edit = 0;
128         try {
129             edit = g.network.request(
130                 api.PERM_MULTI_ORG_CHECK.app,
131                 api.PERM_MULTI_ORG_CHECK.method,
132                 [
133                     ses(),
134                     ses('staff_id'),
135                     [ ses('ws_ou') ],
136                     [ 'CREATE_VOLUME', 'CREATE_COPY' ]
137                 ]
138             ).length == 0 ? 1 : 0;
139         } catch(E) {
140             g.error.sdump('D_ERROR','batch permission check: ' + E);
141         }
142
143         if (edit==0) {
144             alert(document.getElementById('offlineStrings').getString('staff.circ.copy_status.add_volumes.perm_failure'));
145             return; // no read-only view for this interface
146         }
147
148         var title = document.getElementById('offlineStrings').getFormattedString('staff.circ.copy_status.add_volumes.title', [docid]);
149
150         var url;
151         var unified_interface = String( g.data.hash.aous['ui.unified_volume_copy_editor'] ) == 'true';
152         if (unified_interface) {
153             var horizontal_interface = String( g.data.hash.aous['ui.cat.volume_copy_editor.horizontal'] ) == 'true';
154             url = window.xulG.url_prefix( horizontal_interface ? urls.XUL_VOLUME_COPY_CREATOR_HORIZONTAL : urls.XUL_VOLUME_COPY_CREATOR );
155         } else {
156             url = window.xulG.url_prefix( urls.XUL_VOLUME_COPY_CREATOR_ORIGINAL );
157         }
158         var w = xulG.new_tab(
159             url,
160             { 'tab_name' : title },
161             { 'doc_id' : docid, 'ou_ids' : [ ses('ws_ou') ] }
162         );
163     } catch(E) {
164         alert('Error in server/cat/bib_brief.js, add_volumes(): ' + E);
165     }
166 }