]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/cat/copy_browser.js
disable/enable copy browser actions
[Evergreen.git] / Open-ILS / xul / staff_client / server / cat / copy_browser.js
1 dump('entering cat.copy_browser.js\n');
2
3 if (typeof cat == 'undefined') cat = {};
4 cat.copy_browser = function (params) {
5         try {
6                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
7                 JSAN.use('util.error'); this.error = new util.error();
8         } catch(E) {
9                 dump('cat.copy_browser: ' + E + '\n');
10         }
11 }
12
13 cat.copy_browser.prototype = {
14
15         'map_tree' : {},
16         'map_acn' : {},
17         'map_acp' : {},
18         'sel_list' : [],
19
20         'init' : function( params ) {
21
22                 try {
23                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
24                         var obj = this;
25
26                         obj.docid = params.docid;
27
28                         JSAN.use('util.network'); obj.network = new util.network();
29                         JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
30                         JSAN.use('util.controller'); obj.controller = new util.controller();
31                         obj.controller.init(
32                                 {
33                                         control_map : {
34                                                 'cmd_broken' : [
35                                                         ['command'],
36                                                         function() { alert('Not Yet Implemented'); }
37                                                 ],
38                                                 'cmd_show_my_libs' : [
39                                                         ['command'],
40                                                         function() { 
41                                                                 obj.show_my_libs(); 
42                                                         }
43                                                 ],
44                                                 'cmd_show_all_libs' : [
45                                                         ['command'],
46                                                         function() {
47                                                                 obj.show_all_libs();
48                                                         }
49                                                 ],
50                                                 'cmd_show_libs_with_copies' : [
51                                                         ['command'],
52                                                         function() {
53                                                                 obj.show_libs_with_copies();
54                                                         }
55                                                 ],
56                                                 'cmd_clear' : [
57                                                         ['command'],
58                                                         function() {
59                                                                 obj.map_tree = {};
60                                                                 obj.list.clear();
61                                                         }
62                                                 ],
63                                                 'cmd_add_items' : [
64                                                         ['command'],
65                                                         function() {
66                                                                 try {
67                                                                         JSAN.use('util.widgets'); JSAN.use('util.functional');
68                                                                         var list = util.functional.map_list(
69                                                                                 util.functional.filter_list(
70                                                                                         obj.sel_list,
71                                                                                         function (o) {
72                                                                                                 return o.split(/_/)[0] == 'acn';
73                                                                                         }
74                                                                                 ),
75                                                                                 function (o) {
76                                                                                         return o.split(/_/)[1];
77                                                                                 }
78                                                                         );
79                                                                         if (list.length == 0) return;
80
81                                                                         var copy_shortcut = {};
82                                                                         list = util.functional.map_list(
83                                                                                 list,
84                                                                                 function (o) {
85                                                                                         var ou_id = obj.map_acn['acn_' + o].owning_lib();
86                                                                                         var volume_id = o;
87                                                                                         var label = obj.map_acn['acn_' + o].label();
88                                                                                         if (!copy_shortcut[ou_id]) copy_shortcut[ou_id] = {};
89                                                                                         copy_shortcut[ou_id][ label ] = volume_id;
90
91                                                                                         return ou_id;
92                                                                                 }
93                                                                         );
94                                                                         /* quick fix */  /* what was this fixing? */
95                                                                         list = []; for (var i in copy_shortcut) { list.push( i ); }
96
97                                                                         var edit = 0;
98                                                                         try {
99                                                                                 edit = obj.network.request(
100                                                                                         api.PERM_MULTI_ORG_CHECK.app,
101                                                                                         api.PERM_MULTI_ORG_CHECK.method,
102                                                                                         [ 
103                                                                                                 ses(), 
104                                                                                                 obj.data.list.au[0].id(), 
105                                                                                                 list,
106                                                                                                 [ 'CREATE_COPY' ]
107                                                                                         ]
108                                                                                 ).length == 0 ? 1 : 0;
109                                                                         } catch(E) {
110                                                                                 obj.error.sdump('batch permission check: ' + E);
111                                                                         }
112
113                                                                         if (edit==0) return; // no read-only view for this interface
114
115                                                                         var title = 'Add Copy';
116
117                                                                         JSAN.use('util.window'); var win = new util.window();
118                                                                         var w = win.open(
119                                                                                 window.xulG.url_prefix(urls.XUL_VOLUME_COPY_CREATOR)
120                                                                                         +'?doc_id=' + window.escape(obj.docid)
121                                                                                         +'&ou_ids=' + window.escape( js2JSON(list) )
122                                                                                         +'&copy_shortcut=' + window.escape( js2JSON(copy_shortcut) ),
123                                                                                 title,
124                                                                                 'chrome,modal,resizable'
125                                                                         );
126                                                                         obj.refresh_list();
127                                                                 } catch(E) {
128                                                                         obj.error.standard_unexpected_error_alert('copy browser -> add copies',E);
129                                                                 }
130                                                         }
131                                                 ],
132                                                 'cmd_add_items_to_buckets' : [
133                                                         ['command'],
134                                                         function() {
135                                                         }
136                                                 ],
137                                                 'cmd_edit_items' : [
138                                                         ['command'],
139                                                         function() {
140                                                         }
141                                                 ],
142                                                 'cmd_delete_items' : [
143                                                         ['command'],
144                                                         function() {
145                                                         }
146                                                 ],
147                                                 'cmd_print_spine_labels' : [
148                                                         ['command'],
149                                                         function() {
150                                                         }
151                                                 ],
152                                                 'cmd_add_volumes' : [
153                                                         ['command'],
154                                                         function() {
155                                                                 try {
156                                                                         JSAN.use('util.widgets'); JSAN.use('util.functional');
157                                                                         var list = util.functional.filter_list(
158                                                                                 obj.sel_list,
159                                                                                 function (o) {
160                                                                                         return o.split(/_/)[0] == 'aou';
161                                                                                 }
162                                                                         );
163                                                                         list = util.functional.map_list(
164                                                                                 list,
165                                                                                 function (o) {
166                                                                                         return o.split(/_/)[1];
167                                                                                 }
168                                                                         );              
169                                                                         var edit = 0;
170                                                                         try {
171                                                                                 edit = obj.network.request(
172                                                                                         api.PERM_MULTI_ORG_CHECK.app,
173                                                                                         api.PERM_MULTI_ORG_CHECK.method,
174                                                                                         [ 
175                                                                                                 ses(), 
176                                                                                                 obj.data.list.au[0].id(), 
177                                                                                                 list,
178                                                                                                 [ 'CREATE_VOLUME', 'CREATE_COPY' ]
179                                                                                         ]
180                                                                                 ).length == 0 ? 1 : 0;
181                                                                         } catch(E) {
182                                                                                 obj.error.sdump('batch permission check: ' + E);
183                                                                         }
184
185                                                                         if (edit==0) {
186                                                                                 alert("You don't have permission to add volumes to that library.");
187                                                                                 return; // no read-only view for this interface
188                                                                         }
189
190                                                                         var title = 'Add Volume/Copy';
191
192                                                                         JSAN.use('util.window'); var win = new util.window();
193                                                                         var w = win.open(
194                                                                                 window.xulG.url_prefix(urls.XUL_VOLUME_COPY_CREATOR)
195                                                                                         +'?doc_id=' + window.escape(obj.docid)
196                                                                                         +'&ou_ids=' + window.escape( js2JSON(list) ),
197                                                                                 title,
198                                                                                 'chrome,modal,resizable'
199                                                                         );
200
201                                                                         obj.refresh_list();
202                                                                 } catch(E) {
203                                                                         obj.error.standard_unexpected_error_alert('copy browser -> add volumes',E);
204                                                                 }
205                                                         }
206                                                 ],
207                                                 'cmd_edit_volumes' : [
208                                                         ['command'],
209                                                         function() {
210                                                         }
211                                                 ],
212                                                 'cmd_delete_volumes' : [
213                                                         ['command'],
214                                                         function() {
215                                                         }
216                                                 ],
217                                                 'cmd_mark_volume' : [
218                                                         ['command'],
219                                                         function() {
220                                                         }
221                                                 ],
222                                                 'cmd_refresh_list' : [
223                                                         ['command'],
224                                                         function() {
225                                                         }
226                                                 ],
227                                         }
228                                 }
229                         );
230
231                         obj.list_init(params);
232
233                         obj.org_ids = obj.network.simple_request('FM_AOU_IDS_RETRIEVE_VIA_RECORD_ID',[ obj.docid ]);
234
235                         var org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
236                         obj.show_libs( org );
237
238                 } catch(E) {
239                         this.error.sdump('D_ERROR','cat.copy_browser.init: ' + E + '\n');
240                 }
241         },
242
243         'show_my_libs' : function() {
244                 var obj = this;
245                 try {
246                         var org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
247                         obj.show_libs( org, true );
248                 
249                         var p_org = obj.data.hash.aou[ org.parent_ou() ];
250                         if (p_org) {
251                                 JSAN.use('util.exec'); var exec = new util.exec();
252                                 var funcs = [];
253                                 for (var i = 0; i < p_org.children().length; i++) {
254                                         funcs.push(
255                                                 function(o) {
256                                                         return function() {
257                                                                 obj.show_libs( o, true );
258                                                         }
259                                                 }( p_org.children()[i] )
260                                         );
261                                 }
262                                 exec.chain( funcs );
263                         }
264                 } catch(E) {
265                         alert(E);
266                 }
267         },
268
269         'show_all_libs' : function() {
270                 var obj = this;
271                 try {
272                         obj.show_my_libs();
273
274                         obj.show_libs( obj.data.tree.aou );
275
276                         JSAN.use('util.exec'); var exec = new util.exec();
277                         var funcs = [];
278                         for (var i = 0; i < obj.data.tree.aou.children().length; i++) {
279                                 funcs.push(
280                                         function(o) {
281                                                 return function() {
282                                                         obj.show_libs( o );
283                                                 }
284                                         }( obj.data.tree.aou.children()[i] )
285                                 );
286                         }
287                         exec.chain( funcs );
288                 } catch(E) {
289                         alert(E);
290                 }
291         },
292
293         'show_libs_with_copies' : function() {
294                 var obj = this;
295                 try {
296                         JSAN.use('util.exec'); var exec = new util.exec();
297                         JSAN.use('util.functional');
298
299                         var orgs = util.functional.map_list(
300                                 obj.org_ids,
301                                 function(id) { return obj.data.hash.aou[id]; }
302                         ).sort(
303                                 function( a, b ) {
304                                         if (a.shortname() < b.shortname()) return -1;
305                                         if (a.shortname() > b.shortname()) return 1;
306                                         return 0;
307                                 }
308                         );
309                         var funcs = [];
310                         for (var i = 0; i < orgs.length; i++) {
311                                 funcs.push(
312                                         function(o) {
313                                                 return function() {
314                                                         obj.show_libs(o,true);
315                                                 }
316                                         }( orgs[i] )
317                                 );
318                         }
319                         exec.chain( funcs );
320                 } catch(E) {
321                         alert(E);
322                 }
323         },
324
325         'show_libs' : function(start_aou,show_open) {
326                 var obj = this;
327                 try {
328                         if (!start_aou) throw('show_libs: Need a start_aou');
329                         JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
330                         JSAN.use('util.functional'); JSAN.use('util.exec'); var exec = new util.exec();
331
332                         var funcs = [];
333
334                         var parents = [];
335                         var temp_aou = start_aou;
336                         while ( temp_aou.parent_ou() ) {
337                                 temp_aou = obj.data.hash.aou[ temp_aou.parent_ou() ];
338                                 parents.push( temp_aou );
339                         }
340                         parents.reverse();
341
342                         for (var i = 0; i < parents.length; i++) {
343                                 funcs.push(
344                                         function(o,p) {
345                                                 return function() { 
346                                                         if (show_open) {
347                                                                 obj.append_org(o,p,{'container':'true','open':'true'}); 
348                                                         } else {
349                                                                 obj.append_org(o,p,{'container':'true'}); 
350                                                         }
351                                                 };
352                                         }(parents[i], obj.data.hash.aou[ parents[i].parent_ou() ])
353                                 );
354                         }
355
356                         funcs.push(
357                                 function(o,p) {
358                                         return function() { obj.append_org(o,p); };
359                                 }(start_aou,obj.data.hash.aou[ start_aou.parent_ou() ])
360                         );
361
362                         funcs.push(
363                                 function() {
364                                         if (start_aou.children()) {
365                                                 var x = obj.map_tree[ 'aou_' + start_aou.id() ];
366                                                 x.setAttribute('container','true');
367                                                 if (show_open) x.setAttribute('open','true');
368                                                 for (var i = 0; i < start_aou.children().length; i++) {
369                                                         funcs.push(
370                                                                 function(o,p) {
371                                                                         return function() { obj.append_org(o,p); };
372                                                                 }( start_aou.children()[i], start_aou )
373                                                         );
374                                                 }
375                                         }
376                                 }
377                         );
378
379                         exec.chain( funcs );
380
381                 } catch(E) {
382                         alert(E);
383                 }
384         },
385
386         'on_select' : function(list,twisty) {
387                 var obj = this;
388                 for (var i = 0; i < list.length; i++) {
389                         var node = obj.map_tree[ list[i] ];
390                         //if (node.lastChild.nodeName == 'treechildren') { continue; } else { alert(node.lastChild.nodeName); }
391                         var row_type = list[i].split('_')[0];
392                         var id = list[i].split('_')[1];
393                         switch(row_type) {
394                                 case 'aou' : obj.on_select_org(id,twisty); break;
395                                 case 'acn' : obj.on_select_acn(id,twisty); break;
396                                 default: break;
397                         }
398                 }
399         },
400
401         'on_select_acn' : function(acn_id,twisty) {
402                 var obj = this;
403                 try {
404                         var acn_tree = obj.map_acp[ 'acn_' + acn_id ];
405                         var funcs = [];
406                         if (acn_tree.copies()) {
407                                 for (var i = 0; i < acn_tree.copies().length; i++) {
408                                         funcs.push(
409                                                 function(c,a) {
410                                                         return function() {
411                                                                 obj.append_acp(c,a);
412                                                         }
413                                                 }( acn_tree.copies()[i], acn_tree )
414                                         )
415                                 }
416                         }
417                         JSAN.use('util.exec'); var exec = new util.exec();
418                         exec.chain( funcs );
419                 } catch(E) {
420                         alert(E);
421                 }
422         },
423
424         'on_select_org' : function(org_id,twisty) {
425                 var obj = this;
426                 var org = obj.data.hash.aou[ org_id ];
427                 var funcs = [];
428                 if (org.children()) {
429                         for (var i = 0; i < org.children().length; i++) {
430                                 funcs.push(
431                                         function(o,p) {
432                                                 return function() {
433                                                         obj.append_org(o,p)
434                                                 }
435                                         }(org.children()[i],org)
436                                 );
437                         }
438                 } 
439                 if (obj.map_acn[ 'aou_' + org_id ]) {
440                         for (var i = 0; i < obj.map_acn[ 'aou_' + org_id ].length; i++) {
441                                 funcs.push(
442                                         function(o,a) {
443                                                 return function() {
444                                                         obj.append_acn(o,a);
445                                                 }
446                                         }( org, obj.map_acn[ 'aou_' + org_id ][i] )
447                                 );
448                         }
449                 }
450                 JSAN.use('util.exec'); var exec = new util.exec();
451                 exec.chain( funcs );
452         },
453
454         'append_org' : function (org,parent_org,params) {
455                 var obj = this;
456                 try {
457                         if (obj.map_tree[ 'aou_' + org.id() ]) {
458                                 var x = obj.map_tree[ 'aou_' + org.id() ];
459                                 if (params) {
460                                         for (var i in params) {
461                                                 x.setAttribute(i,params[i]);
462                                         }
463                                 }
464                                 return x;
465                         }
466
467                         var data = {
468                                 'row' : {
469                                         'my' : {
470                                                 'aou' : org,
471                                         }
472                                 },
473                                 'skip_all_columns_except' : [0,1,2],
474                                 'retrieve_id' : 'aou_' + org.id(),
475                         };
476                 
477                         var acn_tree_list;
478                         if ( obj.org_ids.indexOf( org.id() ) == -1 ) {
479                                 if ( obj.data.hash.aout[ org.ou_type() ].can_have_vols() ) {
480                                         data.row.my.volume_count = '0';
481                                         data.row.my.copy_count = '<0>';
482                                 } else {
483                                         data.row.my.volume_count = '';
484                                         data.row.my.copy_count = '';
485                                 }
486                         } else {
487                                 var v_count = 0; var c_count = 0;
488                                 acn_tree_list = obj.network.simple_request(
489                                         'FM_ACN_TREE_LIST_RETRIEVE_VIA_RECORD_ID_AND_ORG_IDS',
490                                         [ ses(), obj.docid, [ org.id() ] ]
491                                 );
492                                 for (var i = 0; i < acn_tree_list.length; i++) {
493                                         v_count++;
494                                         obj.map_acn[ 'acn_' + acn_tree_list[i].id() ] = function(r){return r;}(acn_tree_list[i]);
495                                         var copies = acn_tree_list[i].copies(); if (copies) c_count += copies.length;
496                                         for (var j = 0; j < copies.length; j++) {
497                                                 obj.map_acp[ 'acp_' + copies[j].id() ] = function(r){return r;}(copies[j]);
498                                         }
499                                 }
500                                 data.row.my.volume_count = v_count;
501                                 data.row.my.copy_count = '<' + c_count + '>';
502                         }
503                         if (parent_org) {
504                                 data.node = obj.map_tree[ 'aou_' + parent_org.id() ];
505                         }
506
507                         var node = obj.list.append(data);
508                         if (params) {
509                                 for (var i in params) {
510                                         node.setAttribute(i,params[i]);
511                                 }
512                         }
513                         obj.map_tree[ 'aou_' + org.id() ] = node;
514
515                         if (org.children()) {
516                                 node.setAttribute('container','true');
517                         }
518
519                         if (parent_org) {
520                                 if ( obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].parent_ou() == parent_org.id() ) {
521                                         data.node.setAttribute('open','true');
522                                 }
523                         } else {
524                                 obj.map_tree[ 'aou_' + org.id() ].setAttribute('open','true');
525                         }
526
527                         if (acn_tree_list) {
528                                 obj.map_acn[ 'aou_' + org.id() ] = acn_tree_list;
529                                 node.setAttribute('container','true');
530                         }
531
532                 } catch(E) {
533                         dump(E+'\n');
534                         alert(E);
535                 }
536         },
537
538         'append_acn' : function( org, acn_tree, params ) {
539                 var obj = this;
540                 try {
541                         if (obj.map_tree[ 'acn_' + acn_tree.id() ]) {
542                                 var x = obj.map_tree[ 'acn_' + acn_tree.id() ];
543                                 if (params) {
544                                         for (var i in params) {
545                                                 x.setAttribute(i,params[i]);
546                                         }
547                                 }
548                                 return x;
549                         }
550
551                         var parent_node = obj.map_tree[ 'aou_' + org.id() ];
552                         var data = {
553                                 'row' : {
554                                         'my' : {
555                                                 'aou' : org,
556                                                 'acn' : acn_tree,
557                                                 'volume_count' : '',
558                                                 'copy_count' : acn_tree.copies() ? acn_tree.copies().length : '0',
559                                         }
560                                 },
561                                 'skip_all_columns_except' : [0,1,2],
562                                 'retrieve_id' : 'acn_' + acn_tree.id(),
563                                 'node' : parent_node,
564                         };
565                         var node = obj.list.append(data);
566                         obj.map_tree[ 'acn_' + acn_tree.id() ] =  node;
567                         if (params) {
568                                 for (var i in params) {
569                                         node.setAttribute(i,params[i]);
570                                 }
571                         }
572                         if (acn_tree.copies()) {
573                                 obj.map_acp[ 'acn_' + acn_tree.id() ] = acn_tree;
574                                 node.setAttribute('container','true');
575                         }
576
577                 } catch(E) {
578                         dump(E+'\n');
579                         alert(E);
580                 }
581         },
582
583         'append_acp' : function( acp_item, acn_tree, params ) {
584                 var obj = this;
585                 try {
586                         if (obj.map_tree[ 'acp_' + acp_item.id() ]) {
587                                 var x = obj.map_tree[ 'acp_' + acp_item.id() ];
588                                 if (params) {
589                                         for (var i in params) {
590                                                 x.setAttribute(i,params[i]);
591                                         }
592                                 }
593                                 return x;
594                         }
595
596                         var parent_node = obj.map_tree[ 'acn_' + acn_tree.id() ];
597                         var data = {
598                                 'row' : {
599                                         'my' : {
600                                                 'aou' : obj.data.hash.aou[ acn_tree.owning_lib() ],
601                                                 'acn' : acn_tree,
602                                                 'acp' : acp_item,
603                                                 'volume_count' : '',
604                                                 'copy_count' : '',
605                                         }
606                                 },
607                                 'retrieve_id' : 'acp_' + acp_item.id(),
608                                 'node' : parent_node,
609                         };
610                         var node = obj.list.append(data);
611                         obj.map_tree[ 'acp_' + acp_item.id() ] =  node;
612                         if (params) {
613                                 for (var i in params) {
614                                         node.setAttribute(i,params[i]);
615                                 }
616                         }
617
618                 } catch(E) {
619                         dump(E+'\n');
620                         alert(E);
621                 }
622         },
623
624         'list_init' : function( params ) {
625
626                 try {
627                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
628                         var obj = this;
629                         
630                         JSAN.use('circ.util');
631                         var columns = [
632                                 {
633                                         'id' : 'tree_location', 'label' : 'Location/Barcode', 'flex' : 1,
634                                         'primary' : true, 'hidden' : false, 
635                                         'render' : 'my.acp ? my.acp.barcode() : my.acn ? my.acn.label() : my.aou ? my.aou.shortname() + " : " + my.aou.name() : "???"'
636                                 },
637                                 {
638                                         'id' : 'volume_count', 'label' : 'Volumes', 'flex' : 0,
639                                         'primary' : false, 'hidden' : false, 
640                                         'render' : 'my.volume_count'
641                                 },
642                                 {
643                                         'id' : 'copy_count', 'label' : 'Copies', 'flex' : 0,
644                                         'primary' : false, 'hidden' : false, 
645                                         'render' : 'my.copy_count'
646                                 },
647                         ].concat(
648                                 circ.util.columns( 
649                                         { 
650                                                 'location' : { 'hidden' : false },
651                                                 'circ_lib' : { 'hidden' : false },
652                                                 'owning_lib' : { 'hidden' : false },
653                                                 'call_number' : { 'hidden' : false },
654                                                 'status' : { 'hidden' : false },
655                                         },
656                                         {
657                                                 'just_these' : [
658                                                         'owning_lib',
659                                                         'circ_lib',
660                                                         'call_number',
661                                                         'copy_number',
662                                                         'location',
663                                                         'barcode',
664                                                         'loan_duration',
665                                                         'fine_level',
666                                                         'circulate',
667                                                         'holdable',
668                                                         'opac_visible',
669                                                         'ref',
670                                                         'deposit',
671                                                         'deposit_amount',
672                                                         'price',
673                                                         'circ_as_type',
674                                                         'circ_modifier',
675                                                         'status',
676                                                         'alert_message',
677                                                         'acp_id',
678                                                 ]
679                                         }
680                                 )
681                         );
682                         JSAN.use('util.list'); obj.list = new util.list('copy_tree');
683                         obj.list.init(
684                                 {
685                                         'columns' : columns,
686                                         'map_row_to_column' : circ.util.std_map_row_to_column(' '),
687                                         'retrieve_row' : function(params) {
688
689                                                 var row = params.row;
690
691                                                 var funcs = [];
692                                         /*      
693                                                 if (!row.my.mvr) funcs.push(
694                                                         function() {
695
696                                                                 row.my.mvr = obj.network.request(
697                                                                         api.MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.app,
698                                                                         api.MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.method,
699                                                                         [ row.my.circ.target_copy() ]
700                                                                 );
701
702                                                         }
703                                                 );
704                                                 if (!row.my.acp) {
705                                                         funcs.push(     
706                                                                 function() {
707
708                                                                         row.my.acp = obj.network.request(
709                                                                                 api.FM_ACP_RETRIEVE.app,
710                                                                                 api.FM_ACP_RETRIEVE.method,
711                                                                                 [ row.my.circ.target_copy() ]
712                                                                         );
713
714                                                                         params.row_node.setAttribute( 'retrieve_id',row.my.acp.barcode() );
715
716                                                                 }
717                                                         );
718                                                 } else {
719                                                         params.row_node.setAttribute( 'retrieve_id',row.my.acp.barcode() );
720                                                 }
721                                         */
722                                                 funcs.push(
723                                                         function() {
724
725                                                                 if (typeof params.on_retrieve == 'function') {
726                                                                         params.on_retrieve(row);
727                                                                 }
728
729                                                         }
730                                                 );
731
732                                                 JSAN.use('util.exec'); var exec = new util.exec();
733                                                 exec.on_error = function(E) {
734                                                         var err = 'items chain: ' + js2JSON(E);
735                                                         obj.error.sdump('D_ERROR',err);
736                                                         return true; /* keep going */
737                                                 }
738                                                 exec.chain( funcs );
739
740                                                 return row;
741                                         },
742                                         'on_click' : function(ev) {
743                                                 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserRead');
744                                                 var row = {}; var col = {}; var nobj = {};
745                                                 obj.list.node.treeBoxObject.getCellAt(ev.clientX,ev.clientY,row,col,nobj);
746                                                 if ((row.value == -1)||(nobj.value != 'twisty')) { return; }
747                                                 var node = obj.list.node.contentView.getItemAtIndex(row.value);
748                                                 var list = [ node.getAttribute('retrieve_id') ];
749                                                 if (typeof obj.on_select == 'function') {
750                                                         obj.on_select(list,true);
751                                                 }
752                                                 if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
753                                                         window.xulG.on_select(list);
754                                                 }
755                                         },
756                                         'on_select' : function(ev) {
757                                                 JSAN.use('util.functional');
758                                                 var sel = obj.list.retrieve_selection();
759                                                 obj.sel_list = util.functional.map_list(
760                                                         sel,
761                                                         function(o) { return o.getAttribute('retrieve_id'); }
762                                                 );
763                                                 obj.toggle_actions();
764                                                 if (typeof obj.on_select == 'function') {
765                                                         obj.on_select(obj.sel_list);
766                                                 }
767                                                 if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
768                                                         window.xulG.on_select(obj.sel_list);
769                                                 }
770                                         },
771                                 }
772                         );
773
774                         obj.controller.render();
775
776                 } catch(E) {
777                         this.error.sdump('D_ERROR','cat.copy_browser.list_init: ' + E + '\n');
778                         alert(E);
779                 }
780         },
781
782         'toggle_actions' : function() {
783                 var obj = this;
784                 try {
785                         var found_aou = false; var found_acn = false; var found_acp = false;
786                         for (var i = 0; i < obj.sel_list.length; i++) {
787                                 var type = obj.sel_list[i].split(/_/)[0];
788                                 switch(type) {
789                                         case 'aou' : found_aou = true; break;
790                                         case 'acn' : found_acn = true; break;
791                                         case 'acp' : found_acp = true; break;
792                                 }
793                         }
794                         obj.controller.view.cmd_add_items.setAttribute('disabled','true');
795                         obj.controller.view.cmd_add_items_to_buckets.setAttribute('disabled','true');
796                         obj.controller.view.cmd_edit_items.setAttribute('disabled','true');
797                         obj.controller.view.cmd_delete_items.setAttribute('disabled','true');
798                         obj.controller.view.cmd_print_spine_labels.setAttribute('disabled','true');
799                         obj.controller.view.cmd_add_volumes.setAttribute('disabled','true');
800                         obj.controller.view.cmd_edit_volumes.setAttribute('disabled','true');
801                         obj.controller.view.cmd_delete_volumes.setAttribute('disabled','true');
802                         obj.controller.view.cmd_mark_volume.setAttribute('disabled','true');
803                         if (found_aou) {
804                                 obj.controller.view.cmd_add_volumes.setAttribute('disabled','false');
805                         }
806                         if (found_acn) {
807                                 obj.controller.view.cmd_edit_volumes.setAttribute('disabled','false');
808                                 obj.controller.view.cmd_delete_volumes.setAttribute('disabled','false');
809                                 obj.controller.view.cmd_mark_volume.setAttribute('disabled','false');
810                                 obj.controller.view.cmd_add_items.setAttribute('disabled','false');
811                         }
812                         if (found_acp) {
813                                 obj.controller.view.cmd_add_items_to_buckets.setAttribute('disabled','false');
814                                 obj.controller.view.cmd_edit_items.setAttribute('disabled','false');
815                                 obj.controller.view.cmd_delete_items.setAttribute('disabled','false');
816                                 obj.controller.view.cmd_print_spine_labels.setAttribute('disabled','false');
817                         }
818                 } catch(E) {
819                         obj.error.standard_unexpected_error_alert('Copy Browser Actions',E);
820                 }
821         },
822
823         'refresh_list' : function() { alert('FIXME: refresh the list now'); },
824 }
825
826 dump('exiting cat.copy_browser.js\n');