]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/cat/copy_buckets.js
rethinking record bucket interface
[Evergreen.git] / Open-ILS / xul / staff_client / server / cat / copy_buckets.js
1 dump('entering cat.copy_buckets.js\n');
2
3 if (typeof cat == 'undefined') cat = {};
4 cat.copy_buckets = function (params) {
5
6         JSAN.use('util.error'); this.error = new util.error();
7         JSAN.use('util.network'); this.network = new util.network();
8         JSAN.use('util.date');
9         JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
10         this.first_pause = true;
11 }
12
13 cat.copy_buckets.prototype = {
14         'selection_list1' : [],
15         'selection_list2' : [],
16         'bucket_id_name_map' : {},
17
18         'render_pending_copies' : function() {
19                 if (this.first_pause) {
20                         this.first_pause = false;
21                 } else {
22                         alert("Action completed.");
23                 }
24                 var obj = this;
25                 obj.list1.clear();
26                 for (var i = 0; i < obj.copy_ids.length; i++) {
27                         var item = obj.prep_item_for_list( obj.copy_ids[i] );
28                         if (item) obj.list1.append( item );
29                 }
30         },
31
32         'init' : function( params ) {
33
34                 var obj = this;
35
36                 obj.copy_ids = params['copy_ids'] || [];
37
38                 JSAN.use('circ.util');
39                 var columns = circ.util.columns( 
40                         { 
41                                 'barcode' : { 'hidden' : false },
42                                 'title' : { 'hidden' : false },
43                                 'location' : { 'hidden' : false },
44                                 'call_number' : { 'hidden' : false },
45                                 'status' : { 'hidden' : false },
46                                 'deleted' : { 'hidden' : false },
47                         } 
48                 );
49
50                 JSAN.use('util.list'); 
51
52         function retrieve_row(params) {
53             var row = params.row;
54             try {
55                 obj.network.simple_request('FM_ACP_DETAILS', [ ses(), row.my.copy_id ],
56                     function(blob_req) {
57                         try {
58                             var blob = blob_req.getResultObject();
59                             if (typeof blob.ilsevent != 'undefined') throw(blob);
60                             row.my.acp = blob.copy;
61                             row.my.mvr = blob.mvr;
62                             row.my.acn = blob.volume;
63                             row.my.ahr = blob.hold;
64                             row.my.circ = blob.circ;
65                             params.row_node.setAttribute('retrieve_id', js2JSON( [ blob.copy.id(), blob.copy.barcode(), row.my.bucket_item_id ] ));
66                             if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); }
67
68                         } catch(E) {
69                             obj.error.standard_unexpected_error_alert('Error retrieving details for item with copy id =' + row.my.acp_id, E);
70                         }
71                     }
72                 );
73             } catch(E) {
74                 obj.error.sdump('D_ERROR','retrieve_row: ' + E );
75             }
76             return row;
77         }
78
79                 obj.list1 = new util.list('pending_copies_list');
80                 obj.list1.init(
81                         {
82                                 'columns' : columns,
83                                 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
84                 'retrieve_row' : retrieve_row,
85                                 'on_select' : function(ev) {
86                                         try {
87                                                 JSAN.use('util.functional');
88                                                 var sel = obj.list1.retrieve_selection();
89                                                 document.getElementById('clip_button1').disabled = sel.length < 1;
90                                                 obj.selection_list1 = util.functional.map_list(
91                                                         sel,
92                                                         function(o) { return JSON2js(o.getAttribute('retrieve_id')); }
93                                                 );
94                                                 obj.error.sdump('D_TRACE','circ/copy_buckets: selection list 1 = ' + js2JSON(obj.selection_list1) );
95                                                 if (obj.selection_list1.length == 0) {
96                                                         obj.controller.view.copy_buckets_sel_add.disabled = true;
97                                                 } else {
98                                                         obj.controller.view.copy_buckets_sel_add.disabled = false;
99                                                 }
100                                         } catch(E) {
101                                                 alert('FIXME: ' + E);
102                                         }
103                                 },
104
105                         }
106                 );
107
108                 obj.render_pending_copies();
109         
110                 obj.list2 = new util.list('copies_in_bucket_list');
111                 obj.list2.init(
112                         {
113                                 'columns' : columns,
114                                 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
115                 'retrieve_row' : retrieve_row,
116                                 'on_select' : function(ev) {
117                                         try {
118                                                 JSAN.use('util.functional');
119                                                 var sel = obj.list2.retrieve_selection();
120                                                 document.getElementById('clip_button2').disabled = sel.length < 1;
121                                                 obj.selection_list2 = util.functional.map_list(
122                                                         sel,
123                                                         function(o) { return JSON2js(o.getAttribute('retrieve_id')); }
124                                                 );
125                                                 obj.error.sdump('D_TRACE','circ/copy_buckets: selection list 2 = ' + js2JSON(obj.selection_list2) );
126                                                 if (obj.selection_list2.length == 0) {
127                                                         obj.controller.view.copy_buckets_delete_item.disabled = true;
128                                                         obj.controller.view.copy_buckets_delete_item.setAttribute('disabled','true');
129                                                         obj.controller.view.copy_buckets_export.disabled = true;
130                                                         obj.controller.view.copy_buckets_export.setAttribute('disabled','true');
131                                                 } else {
132                                                         obj.controller.view.copy_buckets_delete_item.disabled = false;
133                                                         obj.controller.view.copy_buckets_delete_item.setAttribute('disabled','false');
134                                                         obj.controller.view.copy_buckets_export.disabled = false;
135                                                         obj.controller.view.copy_buckets_export.setAttribute('disabled','false');
136                                                 }
137                                         } catch(E) {
138                                                 alert('FIXME: ' + E);
139                                         }
140                                 },
141                         }
142                 );
143                 
144                 JSAN.use('util.controller'); obj.controller = new util.controller();
145                 obj.controller.init(
146                         {
147                                 'control_map' : {
148                                         'save_columns2' : [
149                                                 ['command'],
150                                                 function() { obj.list2.save_columns(); }
151                                         ],
152                                         'save_columns1' : [
153                                                 ['command'],
154                                                 function() { obj.list1.save_columns(); }
155                                         ],
156                                         'sel_clip2' : [
157                                                 ['command'],
158                                                 function() { obj.list2.clipboard(); }
159                                         ],
160                                         'sel_clip1' : [
161                                                 ['command'],
162                                                 function() { obj.list1.clipboard(); }
163                                         ],
164                                         'copy_buckets_menulist_placeholder' : [
165                                                 ['render'],
166                                                 function(e) {
167                                                         return function() {
168                                                                 JSAN.use('util.widgets'); JSAN.use('util.functional');
169                                                                 var items = [ ['Choose a bucket...',''], ['Retrieve shared bucket...',-1] ].concat(
170                                                                         util.functional.map_list(
171                                                                                 obj.network.simple_request(
172                                                                                         'BUCKET_RETRIEVE_VIA_USER',
173                                                                                         [ ses(), obj.data.list.au[0].id() ]
174                                                                                 ).copy,
175                                                                                 function(o) {
176                                                                                         obj.bucket_id_name_map[ o.id() ] = o.name();
177                                                                                         return [ o.name(), o.id() ];
178                                                                                 }
179                                                                         ).sort( 
180                                                         function( a, b ) {
181                                                             if (a[0] < b[0]) return -1;
182                                                             if (a[0] > b[0]) return 1;
183                                                             return 0;
184                                                         }
185                                                                         )
186                                                                 );
187                                                                 obj.error.sdump('D_TRACE','items = ' + js2JSON(items));
188                                                                 util.widgets.remove_children( e );
189                                                                 var ml = util.widgets.make_menulist(
190                                                                         items
191                                                                 );
192                                                                 e.appendChild( ml );
193                                                                 ml.setAttribute('id','bucket_menulist');
194                                                                 ml.setAttribute('accesskey','');
195
196                                                                 function change_bucket(ev) {
197                                                                         var bucket_id = ev.target.value;
198                                                                         if (bucket_id < 0 ) {
199                                                                                 bucket_id = window.prompt('Enter bucket number:');
200                                                                                 ev.target.value = bucket_id;
201                                                                                 ev.target.setAttribute('value',bucket_id);
202                                                                         }
203                                                                         if (!bucket_id) return;
204                                                                         var bucket = obj.network.simple_request(
205                                                                                 'BUCKET_FLESH',
206                                                                                 [ ses(), 'copy', bucket_id ]
207                                                                         );
208                                                                         if (typeof bucket.ilsevent != 'undefined') {
209                                                                                 if (bucket.ilsevent == 1506 /* CONTAINER_NOT_FOUND */) {
210                                                                                         alert('Could not find a bucket with ID = ' + bucket_id);
211                                                                                 } else {
212                                                                                         obj.error.standard_unexpected_error_alert('Error retrieving bucket.  Did you use a valid bucket id?',bucket);
213                                                                                 }
214                                                                                 return;
215                                                                         }
216                                                                         try {
217                                                                                 var x = document.getElementById('info_box');
218                                                                                 x.setAttribute('hidden','false');
219                                                                                 x = document.getElementById('bucket_number');
220                                                                                 x.setAttribute('value',bucket.id());
221                                                                                 x = document.getElementById('bucket_name');
222                                                                                 x.setAttribute('value',bucket.name());
223                                                                                 x = document.getElementById('bucket_owner');
224                                                                                 var s = bucket.owner(); JSAN.use('patron.util');
225                                                                                 if (s && typeof s != "object") s = patron.util.retrieve_fleshed_au_via_id(ses(),s); 
226                                                                                 x.setAttribute('value',s.card().barcode() + " @ " + obj.data.hash.aou[ s.home_ou() ].shortname());
227
228                                                                         } catch(E) {
229                                                                                 alert(E);
230                                                                         }
231                                                                         var items = bucket.items() || [];
232                                                                         obj.list2.clear();
233                                                                         for (var i = 0; i < items.length; i++) {
234                                                                                 var item = obj.prep_item_for_list( 
235                                                                                         items[i].target_copy(),
236                                                                                         items[i].id()
237                                                                                 );
238                                                                                 if (item) obj.list2.append( item );
239                                                                         }
240                                                                 }
241
242                                                                 ml.addEventListener( 'change_bucket', change_bucket , false);
243                                                                 ml.addEventListener( 'command', function() {
244                                                                         JSAN.use('util.widgets'); util.widgets.dispatch('change_bucket',ml);
245                                                                 }, false);
246                                                                 obj.controller.view.bucket_menulist = ml;
247                                                                 JSAN.use('util.widgets'); util.widgets.dispatch('change_bucket',ml);
248                                                                 document.getElementById('refresh').addEventListener( 'command', function() {
249                                                                         JSAN.use('util.widgets'); util.widgets.dispatch('change_bucket',ml);
250                                                                 }, false);
251                                                         };
252                                                 },
253                                         ],
254
255                                         'copy_buckets_add' : [
256                                                 ['command'],
257                                                 function() {
258                                                         var bucket_id = obj.controller.view.bucket_menulist.value;
259                                                         if (!bucket_id) return;
260                                                         for (var i = 0; i < obj.copy_ids.length; i++) {
261                                                                 var bucket_item = new ccbi();
262                                                                 bucket_item.isnew('1');
263                                                                 bucket_item.bucket(bucket_id);
264                                                                 bucket_item.target_copy( obj.copy_ids[i] );
265                                                                 try {
266                                                                         var robj = obj.network.simple_request('BUCKET_ITEM_CREATE',
267                                                                                 [ ses(), 'copy', bucket_item ]);
268
269                                                                         if (typeof robj == 'object') throw robj;
270
271                                                                         var item = obj.prep_item_for_list( obj.copy_ids[i], robj );
272                                                                         if (!item) continue;
273
274                                                                         obj.list2.append( item );
275                                                                 } catch(E) {
276                                                                         obj.error.standard_unexpected_error_alert('Addition likely failed.',E);
277                                                                 }
278                                                         }
279                                                 }
280                                         ],
281                                         'copy_buckets_sel_add' : [
282                                                 ['command'],
283                                                 function() {                                                        
284                                                         var bucket_id = obj.controller.view.bucket_menulist.value;
285                                                         if (!bucket_id) return;
286                                                         for (var i = 0; i < obj.selection_list1.length; i++) {
287                                 var acp_id = obj.selection_list1[i][0];
288                                                                 //var barcode = obj.selection_list1[i][1];
289                                                                 var bucket_item = new ccbi();
290                                                                 bucket_item.isnew('1');
291                                                                 bucket_item.bucket(bucket_id);
292                                                                 bucket_item.target_copy( acp_id );
293                                                                 try {
294                                                                         var robj = obj.network.simple_request('BUCKET_ITEM_CREATE',
295                                                                                 [ ses(), 'copy', bucket_item ]);
296
297                                                                         if (typeof robj == 'object') throw robj;
298
299                                                                         var item = obj.prep_item_for_list( acp_id, robj );
300                                                                         if (!item) continue;
301
302                                                                         obj.list2.append( item );
303                                                                 } catch(E) {
304                                                                         obj.error.standard_unexpected_error_alert('Deletion likely failed.',E);
305                                                                 }
306                                                         }
307
308                                                 }
309                                         ],
310                                         'copy_buckets_export' : [
311                                                 ['command'],
312                                                 function() {                                                        
313                                                         for (var i = 0; i < obj.selection_list2.length; i++) {
314                                                                 var acp_id = obj.selection_list2[i][0];
315                                                                 //var barcode = obj.selection_list1[i][1];
316                                                                 //var bucket_item_id = obj.selection_list1[i][2];
317                                                                 var item = obj.prep_item_for_list( acp_id );
318                                                                 if (item) {
319                                                                         obj.list1.append( item );
320                                                                         obj.copy_ids.push( acp_id );
321                                                                 }
322                                                         }
323                                                 }
324                                         ],
325
326                                         'copy_buckets_delete_item' : [
327                                                 ['command'],
328                                                 function() {
329                                                         for (var i = 0; i < obj.selection_list2.length; i++) {
330                                                                 try {
331                                                                         //var acp_id = obj.selection_list2[i][0];
332                                                                         //var barcode = obj.selection_list2[i][1];
333                                                                         var bucket_item_id = obj.selection_list2[i][2];
334                                                                         var robj = obj.network.simple_request('BUCKET_ITEM_DELETE',
335                                                                                 [ ses(), 'copy', bucket_item_id ]);
336                                                                         if (typeof robj == 'object') throw robj;
337                                                                 } catch(E) {
338                                                                         obj.error.standard_unexpected_error_alert('Deletion likely failed.',E);
339                                                                 }
340                                                         }
341                                                         alert("Action completed.");
342                                                         setTimeout(
343                                                                 function() {
344                                                                         JSAN.use('util.widgets'); 
345                                                                         util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
346                                                                 }, 0
347                                                         );
348                                                 }
349                                         ],
350                                         'copy_buckets_delete_bucket' : [
351                                                 ['command'],
352                                                 function() {
353                                                         try {
354                                                                 var bucket = obj.controller.view.bucket_menulist.value;
355                                                                 var name = obj.bucket_id_name_map[ bucket ];
356                                                                 var conf = window.confirm('Delete the bucket named ' + name + '?');
357                                                                 if (!conf) return;
358                                                                 obj.list2.clear();
359                                                                 var robj = obj.network.simple_request('BUCKET_DELETE',[ses(),'copy',bucket]);
360                                                                 if (typeof robj == 'object') throw robj;
361                                                                 alert("Action completed.");
362                                                                 obj.controller.render('copy_buckets_menulist_placeholder');
363                                                         } catch(E) {
364                                                                 obj.error.standard_unexpected_error_alert('Bucket deletion likely failed.',E);
365                                                         }
366                                                 }
367                                         ],
368                                         'copy_buckets_new_bucket' : [
369                                                 ['command'],
370                                                 function() {
371                                                         try {
372                                                                 var name = prompt('What would you like to name the bucket?','','Bucket Creation');
373
374                                                                 if (name) {
375                                                                         var bucket = new ccb();
376                                                                         bucket.btype('staff_client');
377                                                                         bucket.owner( obj.data.list.au[0].id() );
378                                                                         bucket.name( name );
379
380                                                                         var robj = obj.network.simple_request('BUCKET_CREATE',[ses(),'copy',bucket]);
381
382                                                                         if (typeof robj == 'object') {
383                                                                                 if (robj.ilsevent == 1710 /* CONTAINER_EXISTS */) {
384                                                                                         alert('You already have a bucket with that name.');
385                                                                                         return;
386                                                                                 }
387                                                                                 throw robj;
388                                                                         }
389
390                                                                         alert('Bucket "' + name + '" created.');
391
392                                                                         obj.controller.render('copy_buckets_menulist_placeholder');
393                                                                         obj.controller.view.bucket_menulist.value = robj;
394                                                                         setTimeout(
395                                                                                 function() {
396                                                                                         JSAN.use('util.widgets'); 
397                                                                                         util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
398                                                                                 }, 0
399                                                                         );
400                                                                 }
401                                                         } catch(E) {
402                                                                 obj.error.standard_unexpected_error_alert('Bucket creation failed.',E);
403                                                         }
404                                                 }
405                                         ],
406                                         'copy_buckets_batch_copy_edit' : [
407                                                 ['command'],
408                                                 function() {
409                                                         try {
410
411                                                                 obj.list2.select_all();
412                                                         
413                                                                 JSAN.use('util.widgets'); JSAN.use('util.functional');
414
415                                                                 var list = util.functional.map_list(
416                                                                         obj.list2.dump_retrieve_ids(),
417                                                                         function (o) {
418                                                                                 return JSON2js(o)[0]; // acp_id
419                                                                         }
420                                                                 );
421
422                                                                 JSAN.use('cat.util'); cat.util.spawn_copy_editor( { 'copy_ids' : list, 'edit' : 1 } );
423
424                                                                 obj.render_pending_copies(); // FIXME -- need a generic refresh for lists
425                                                                 setTimeout(
426                                                                         function() {
427                                                                                 util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
428                                                                         }, 0
429                                                                 );
430                                                         } catch(E) {
431                                                                 alert( js2JSON(E) );
432                                                         }
433                                                 }
434                                         ],
435                                         'copy_buckets_batch_copy_delete' : [
436                                                 ['command'],
437                                                 function() {
438                                                         try {
439                                                         
440                                                                 obj.list2.select_all();
441
442                                                                 JSAN.use('util.widgets'); JSAN.use('util.functional');
443
444                                                                 var list = util.functional.map_list(
445                                                                         obj.list2.dump_retrieve_ids(),
446                                                                         function (o) {
447                                                                                 return JSON2js(o)[0]; // acp_id
448                                                                         }
449                                                                 );
450
451                                                                 var copies = util.functional.map_list(
452                                                                         list,
453                                                                         function (acp_id) {
454                                                                                 return obj.network.simple_request('FM_ACP_RETRIEVE',[acp_id]);
455                                                                         }
456                                                                 );
457
458                                                                 for (var i = 0; i < copies.length; i++) {
459                                                                         copies[i].ischanged(1);
460                                                                         copies[i].isdeleted(1);
461                                                                 }
462
463                                                                 var robj = obj.network.simple_request('FM_ACP_FLESHED_BATCH_UPDATE',[ ses(), copies, true]);
464                                                                 if (typeof robj.ilsevent != 'undefined') {
465                                                                         switch(Number(robj.ilsevent)) {
466                                                                                 case 1227 /* COPY_DELETE_WARNING */ : 
467                                                                                         var copy;
468                                                                                         for (var i = 0; i < copies.length; i++) { if (copies[i].id()==robj.payload) copy = function(a){return a;}(copies[i]); }
469                                                                                         /* The copy in question is not in an ideal status for deleting */
470                                                                                         var err = '*** ' + robj.desc + ' ***\n';
471                                                                                         /* The barcode for the item is {1} */
472                                                                                         err += $('catStrings').getFormattedString('cat.barcode_for_item',[ copy.barcode() ]) + '\n';
473                                                                                         /* The whole batch operation failed */
474                                                                                         err += $('catStrings').getString('cat.batch_operation_failed') + '\n';
475                                                                                         alert(err);
476                                                                                 break;
477                                                                                 default: obj.error.standard_unexpected_error_alert('Batch Item Deletion',robj);
478                                                                         }
479                                                                 }
480
481                                                                 obj.render_pending_copies(); // FIXME -- need a generic refresh for lists
482                                                                 setTimeout(
483                                                                         function() {
484                                                                                 JSAN.use('util.widgets'); 
485                                                                                 util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
486                                                                         }, 0
487                                                                 );
488                                                         } catch(E) {
489                                                                 alert( js2JSON(E) );
490                                                         }
491                                                 }
492                                         ],
493
494                                         'copy_buckets_transfer_to_volume' : [
495                                                 ['command'],
496                                                 function() {
497                                                         try {
498                                                                 obj.list2.select_all();
499
500                                                                 obj.data.stash_retrieve();
501                                                                 if (!obj.data.marked_volume) {
502                                                                         alert('Please mark a volume as the destination from within the copy browser and then try this again.');
503                                                                         return;
504                                                                 }
505
506                                                                 var copy_ids = util.functional.map_list(
507                                                                         obj.list2.dump_retrieve_ids(),
508                                                                         function (o) {
509                                                                                 return JSON2js(o)[0]; // acp_id
510                                                                         }
511                                                                 )
512
513                                                                 var volume = obj.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ obj.data.marked_volume ]);
514
515                                                                 var msg = 'Transfer the items in bucket "';
516                                                                 msg += obj.controller.view.bucket_menulist.getAttribute('label') + '" ';
517                                                                 msg += 'from their original volumes to ';
518                                                                 msg += obj.data.hash.aou[ volume.owning_lib() ].shortname() + "'s volume labelled ";
519                                                                 msg += '"' + volume.label() + '" on the following record?';
520
521                                                                 JSAN.use('cat.util'); cat.util.transfer_copies( { 
522                                                                         'copy_ids' : copy_ids, 
523                                                                         'message' : msg, 
524                                                                         'docid' : volume.record(),
525                                                                         'volume_label' : volume.label(),
526                                                                         'owning_lib' : volume.owning_lib(),
527                                                                 } );
528
529                                                                 obj.render_pending_copies(); // FIXME -- need a generic refresh for lists
530                                                                 setTimeout(
531                                                                         function() {
532                                                                                 JSAN.use('util.widgets'); 
533                                                                                 util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
534                                                                         }, 0
535                                                                 );
536                                                                 
537                                                         } catch(E) {
538                                                                 obj.error.standard_unexpected_error_alert('Items not likely transferred.',E);
539                                                         }
540                                                 }
541                                         ],
542                                         'cmd_broken' : [
543                                                 ['command'],
544                                                 function() { alert('Not Yet Implemented'); }
545                                         ],
546                                         'cmd_copy_buckets_print' : [
547                                                 ['command'],
548                                                 function() {
549                                                         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
550                                                         obj.list2.on_all_fleshed = function() {
551                                                                 try {
552                                                                         dump( js2JSON( obj.list2.dump_with_keys() ) + '\n' );
553                                                                         data.stash_retrieve();
554                                                                         var lib = data.hash.aou[ data.list.au[0].ws_ou() ];
555                                                                         lib.children(null);
556                                                                         var p = { 
557                                                                                 'lib' : lib,
558                                                                                 'staff' : data.list.au[0],
559                                                                                 'header' : data.print_list_templates.item_status.header,
560                                                                                 'line_item' : data.print_list_templates.item_status.line_item,
561                                                                                 'footer' : data.print_list_templates.item_status.footer,
562                                                                                 'type' : data.print_list_templates.item_status.type,
563                                                                                 'list' : obj.list2.dump_with_keys(),
564                                                                         };
565                                                                         JSAN.use('util.print'); var print = new util.print();
566                                                                         print.tree_list( p );
567                                                                         setTimeout(function(){obj.list2.on_all_fleshed = null;},0);
568                                                                 } catch(E) {
569                                                                         alert(E); 
570                                                                 }
571                                                         }
572                                                         obj.list2.full_retrieve();
573                                                 }
574                                         ],
575                                         'cmd_copy_buckets_export' : [
576                                                 ['command'],
577                                                 function() {
578                                                         obj.list2.dump_csv_to_clipboard();
579                                                 }
580                                         ],
581                                         'cmd_export1' : [
582                                                 ['command'],
583                                                 function() {
584                                                         obj.list1.dump_csv_to_clipboard();
585                                                 }
586                                         ],
587
588                     'cmd_print_export1' : [
589                         ['command'],
590                         function() {
591                             try {
592                                 obj.list1.on_all_fleshed =
593                                     function() {
594                                         try {
595                                             dump( obj.list1.dump_csv() + '\n' );
596                                             //copy_to_clipboard(obj.list.dump_csv());
597                                             JSAN.use('util.print'); var print = new util.print();
598                                             print.simple(obj.list1.dump_csv(),{'content_type':'text/plain'});
599                                             setTimeout(function(){ obj.list1.on_all_fleshed = null; },0);
600                                         } catch(E) {
601                                             obj.error.standard_unexpected_error_alert('print export',E);
602                                         }
603                                     }
604                                 obj.list1.full_retrieve();
605                             } catch(E) {
606                                 obj.error.standard_unexpected_error_alert('print export',E);
607                             }
608                         }
609                     ],
610
611
612                     'cmd_print_export2' : [
613                         ['command'],
614                         function() {
615                             try {
616                                 obj.list2.on_all_fleshed =
617                                     function() {
618                                         try {
619                                             dump( obj.list2.dump_csv() + '\n' );
620                                             //copy_to_clipboard(obj.list.dump_csv());
621                                             JSAN.use('util.print'); var print = new util.print();
622                                             print.simple(obj.list2.dump_csv(),{'content_type':'text/plain'});
623                                             setTimeout(function(){ obj.list2.on_all_fleshed = null; },0);
624                                         } catch(E) {
625                                             obj.error.standard_unexpected_error_alert('print export',E);
626                                         }
627                                     }
628                                 obj.list2.full_retrieve();
629                             } catch(E) {
630                                 obj.error.standard_unexpected_error_alert('print export',E);
631                             }
632                         }
633                     ],
634
635                                         'cmd_copy_buckets_reprint' : [
636                                                 ['command'],
637                                                 function() {
638                                                 }
639                                         ],
640                                         'cmd_copy_buckets_done' : [
641                                                 ['command'],
642                                                 function() {
643                                                         window.close();
644                                                 }
645                                         ],
646                                         'cmd_export_to_copy_status' : [
647                                                 ['command'],
648                                                 function() {
649                                                         try {
650                                 obj.list2.on_all_fleshed =
651                                     function() {
652                                         try {
653                                             obj.list2.select_all();
654                                             JSAN.use('util.functional');
655                                             var barcodes = util.functional.map_list(
656                                                 obj.list2.dump_retrieve_ids(),
657                                                 function(o) { return JSON2js(o)[1]; }
658                                             );
659                                             var url = urls.XUL_COPY_STATUS;
660                                             xulG.new_tab( url, {}, { 'barcodes' : barcodes });
661                                         } catch(E) {
662                                             obj.error.standard_unexpected_error_alert('export to copy status',E);
663                                         }
664                                     }
665                                 obj.list2.full_retrieve();
666                                                         } catch(E) {
667                                                                 obj.error.standard_unexpected_error_alert('Copy Status from Copy Buckets',E);
668                                                         }
669                                                 }
670                                         ],
671                                 }
672                         }
673                 );
674                 this.controller.render();
675
676                 if (typeof xulG == 'undefined') {
677                         obj.controller.view.cmd_export_to_copy_status.disabled = true;
678                         obj.controller.view.cmd_export_to_copy_status.setAttribute('disabled',true);
679                 } else {
680                         obj.controller.view.cmd_copy_buckets_done.disabled = true;
681                         obj.controller.view.cmd_copy_buckets_done.setAttribute('disabled',true);
682                 }
683         
684         },
685
686         'prep_item_for_list' : function(acp_id,bucket_item_id) {
687                 var obj = this;
688                 try {
689             var item = {
690                 'retrieve_id' : js2JSON( [ acp_id, null, bucket_item_id ] ),
691                 'row' : {
692                     'my' : {
693                         'acn' : -2,
694                         'copy_id' : acp_id,
695                         'bucket_item_id' : bucket_item_id
696                     }
697                 }
698             };
699             return item;
700                 } catch(E) {
701                         obj.error.standard_unexpected_error_alert('List building failed.',E);
702                         return null;
703                 }
704
705         },
706         
707 }
708
709 dump('exiting cat.copy_buckets.js\n');