2 <!-- Application: Evergreen Staff Client -->
3 <!-- Screen: Patron Display -->
5 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
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 <?xml-stylesheet href="/xul/server/skin/cat.css" type="text/css"?>
12 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
14 <!DOCTYPE window PUBLIC "" ""[
15 <!--#include virtual="/opac/locale/en-US/lang.dtd"-->
18 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
20 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
22 <window id="record_buckets_win" title="Add to Bucket"
23 onload="try { my_init(); font_helper(); } catch(E) { alert(E); }" persist="height,width"
24 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
26 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
28 <script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};</script>
29 <scripts id="openils_util_scripts"/>
31 <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
34 function $(id) { return document.getElementById(id); }
35 function $c(n) { return document.createElement(n); }
39 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
40 if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
41 JSAN.errorLevel = "die"; // none, warn, or die
42 JSAN.addRepository('/xul/server/');
43 JSAN.use('util.error'); g.error = new util.error();
44 g.error.sdump('D_TRACE','my_init() for record_buckets.xul');
45 JSAN.use('util.network'); g.network = new util.network();
46 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
50 if (g.cgi.param('record_ids')) g.record_ids = g.record_ids.concat( JSON2js( g.cgi.param('record_ids') ) );
51 if (typeof window.xuLG == 'object' && typeof window.xulG.record_ids != 'undefined')
52 g.record_ids = g.record_ids.concat( window.xulG.record_ids );
53 if (typeof g.data.rb_temp_record_ids != 'undefined' && g.data.rb_temp_record_ids != null) {
54 g.record_ids = g.record_ids.concat( JSON2js( g.data.rb_temp_record_ids ) );
55 g.data.rb_temp_record_ids = undefined; g.data.stash('rb_temp_record_ids');
58 $('desc').appendChild( document.createTextNode(
59 (g.record_ids.length == 1 ?
60 'Copy this 1 record into which bucket?' :
61 'Copy these ' + g.record_ids.length + ' items into which bucket?')
63 var robj = g.network.simple_request('BUCKET_RETRIEVE_VIA_USER',[ ses(), g.data.list.au[0].id() ]);
64 if (typeof robj.ilsevent != 'undefined') throw(robj);
66 for (var i = 0; i < robj.biblio.length; i++) {
67 if (robj.biblio[i].btype() != 'staff_client') continue;
68 var listitem = $c('listitem');
69 listitem.setAttribute('label', robj.biblio[i].name());
70 listitem.setAttribute('id', robj.biblio[i].id());
71 $('bucket_list').appendChild(listitem);
73 try { $('bucket_list').selectedIndex = 0; } catch(E) { }
74 $('bucket_list').focus();
78 g.error.standard_unexpected_error_alert('Trying to init record_buckets_quick.xul',E);
85 g.new_bucket = function() {
87 var name = prompt('What would you like to name the bucket?','','Bucket Creation');
89 var bucket = new cbreb();
90 bucket.btype('staff_client');
91 bucket.owner( g.data.list.au[0].id() );
94 var bucket_id = g.network.simple_request('BUCKET_CREATE',[ses(),'biblio',bucket]);
95 if (typeof bucket_id == 'object') throw bucket_id;
97 g.add_to_bucket(bucket_id);
100 g.error.standard_unexpected_error_alert('Bucket creation failed.',E);
104 g.add_to_bucket = function(b) {
110 if ($('bucket_list').selectedItem) bucket_id = $('bucket_list').selectedItem.getAttribute('id');
114 if (!bucket_id) return;
115 for (var i = 0; i < g.record_ids.length; i++) {
116 var bucket_item = new cbrebi();
117 bucket_item.isnew('1');
118 bucket_item.bucket(bucket_id);
119 bucket_item.target_biblio_record_entry( g.record_ids[i] );
121 var robj = g.network.simple_request('BUCKET_ITEM_CREATE', [ ses(), 'biblio', bucket_item ]);
122 if (typeof robj == 'object') throw robj;
125 g.error.standard_unexpected_error_alert('Addition likely failed for bucket = ' + bucket_id + ' and record id = ' + g.record_ids[i],E);
131 g.advanced = function() {
132 JSAN.use('util.window'); var win = new util.window();
133 g.data.rb_temp_record_ids = js2JSON( g.record_ids ); g.data.stash('rb_temp_record_ids');
134 win.open(urls.XUL_RECORD_BUCKETS,'adv_record_buckets','chrome,resizable,modal');
141 <vbox flex="1" style="overflow: auto">
143 <caption label="Record Buckets"/>
144 <description id="desc"/>
145 <listbox id="bucket_list" rows="5" flex="1" style="overflow: auto"/>
147 <button label="Add to Selected Bucket" accesskey="A" oncommand="g.add_to_bucket()"/>
148 <button label="Add to New Bucket" accesskey="N" oncommand="g.new_bucket()"/>
152 <button label="Advanced" accesskey="v" oncommand="g.advanced()"/>
154 <button label="Cancel" accesskey="C" oncommand="window.close()"/>