]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/cat/copy_browser.js
add copies and add volumes
[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) return; // no read-only view for this interface
186
187                                                                         var title = 'Add Volume/Copy';
188
189                                                                         JSAN.use('util.window'); var win = new util.window();
190                                                                         var w = win.open(
191                                                                                 window.xulG.url_prefix(urls.XUL_VOLUME_COPY_CREATOR)
192                                                                                         +'?doc_id=' + window.escape(obj.docid)
193                                                                                         +'&ou_ids=' + window.escape( js2JSON(list) ),
194                                                                                 title,
195                                                                                 'chrome,modal,resizable'
196                                                                         );
197
198                                                                         obj.refresh_list();
199                                                                 } catch(E) {
200                                                                         obj.error.standard_unexpected_error_alert('copy browser -> add volumes',E);
201                                                                 }
202                                                         }
203                                                 ],
204                                                 'cmd_edit_volumes' : [
205                                                         ['command'],
206                                                         function() {
207                                                         }
208                                                 ],
209                                                 'cmd_delete_volumes' : [
210                                                         ['command'],
211                                                         function() {
212                                                         }
213                                                 ],
214                                                 'cmd_mark_volume' : [
215                                                         ['command'],
216                                                         function() {
217                                                         }
218                                                 ],
219                                                 'cmd_refresh_list' : [
220                                                         ['command'],
221                                                         function() {
222                                                         }
223                                                 ],
224                                         }
225                                 }
226                         );
227
228                         obj.list_init(params);
229
230                         obj.org_ids = obj.network.simple_request('FM_AOU_IDS_RETRIEVE_VIA_RECORD_ID',[ obj.docid ]);
231
232                         var org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
233                         obj.show_libs( org );
234
235                 } catch(E) {
236                         this.error.sdump('D_ERROR','cat.copy_browser.init: ' + E + '\n');
237                 }
238         },
239
240         'show_my_libs' : function() {
241                 var obj = this;
242                 try {
243                         var org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
244                         obj.show_libs( org, true );
245                 
246                         var p_org = obj.data.hash.aou[ org.parent_ou() ];
247                         if (p_org) {
248                                 JSAN.use('util.exec'); var exec = new util.exec();
249                                 var funcs = [];
250                                 for (var i = 0; i < p_org.children().length; i++) {
251                                         funcs.push(
252                                                 function(o) {
253                                                         return function() {
254                                                                 obj.show_libs( o, true );
255                                                         }
256                                                 }( p_org.children()[i] )
257                                         );
258                                 }
259                                 exec.chain( funcs );
260                         }
261                 } catch(E) {
262                         alert(E);
263                 }
264         },
265
266         'show_all_libs' : function() {
267                 var obj = this;
268                 try {
269                         obj.show_my_libs();
270
271                         obj.show_libs( obj.data.tree.aou );
272
273                         JSAN.use('util.exec'); var exec = new util.exec();
274                         var funcs = [];
275                         for (var i = 0; i < obj.data.tree.aou.children().length; i++) {
276                                 funcs.push(
277                                         function(o) {
278                                                 return function() {
279                                                         obj.show_libs( o );
280                                                 }
281                                         }( obj.data.tree.aou.children()[i] )
282                                 );
283                         }
284                         exec.chain( funcs );
285                 } catch(E) {
286                         alert(E);
287                 }
288         },
289
290         'show_libs_with_copies' : function() {
291                 var obj = this;
292                 try {
293                         JSAN.use('util.exec'); var exec = new util.exec();
294                         JSAN.use('util.functional');
295
296                         var orgs = util.functional.map_list(
297                                 obj.org_ids,
298                                 function(id) { return obj.data.hash.aou[id]; }
299                         ).sort(
300                                 function( a, b ) {
301                                         if (a.shortname() < b.shortname()) return -1;
302                                         if (a.shortname() > b.shortname()) return 1;
303                                         return 0;
304                                 }
305                         );
306                         var funcs = [];
307                         for (var i = 0; i < orgs.length; i++) {
308                                 funcs.push(
309                                         function(o) {
310                                                 return function() {
311                                                         obj.show_libs(o,true);
312                                                 }
313                                         }( orgs[i] )
314                                 );
315                         }
316                         exec.chain( funcs );
317                 } catch(E) {
318                         alert(E);
319                 }
320         },
321
322         'show_libs' : function(start_aou,show_open) {
323                 var obj = this;
324                 try {
325                         if (!start_aou) throw('show_libs: Need a start_aou');
326                         JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
327                         JSAN.use('util.functional'); JSAN.use('util.exec'); var exec = new util.exec();
328
329                         var funcs = [];
330
331                         var parents = [];
332                         var temp_aou = start_aou;
333                         while ( temp_aou.parent_ou() ) {
334                                 temp_aou = obj.data.hash.aou[ temp_aou.parent_ou() ];
335                                 parents.push( temp_aou );
336                         }
337                         parents.reverse();
338
339                         for (var i = 0; i < parents.length; i++) {
340                                 funcs.push(
341                                         function(o,p) {
342                                                 return function() { 
343                                                         if (show_open) {
344                                                                 obj.append_org(o,p,{'container':'true','open':'true'}); 
345                                                         } else {
346                                                                 obj.append_org(o,p,{'container':'true'}); 
347                                                         }
348                                                 };
349                                         }(parents[i], obj.data.hash.aou[ parents[i].parent_ou() ])
350                                 );
351                         }
352
353                         funcs.push(
354                                 function(o,p) {
355                                         return function() { obj.append_org(o,p); };
356                                 }(start_aou,obj.data.hash.aou[ start_aou.parent_ou() ])
357                         );
358
359                         funcs.push(
360                                 function() {
361                                         if (start_aou.children()) {
362                                                 var x = obj.map_tree[ 'aou_' + start_aou.id() ];
363                                                 x.setAttribute('container','true');
364                                                 if (show_open) x.setAttribute('open','true');
365                                                 for (var i = 0; i < start_aou.children().length; i++) {
366                                                         funcs.push(
367                                                                 function(o,p) {
368                                                                         return function() { obj.append_org(o,p); };
369                                                                 }( start_aou.children()[i], start_aou )
370                                                         );
371                                                 }
372                                         }
373                                 }
374                         );
375
376                         exec.chain( funcs );
377
378                 } catch(E) {
379                         alert(E);
380                 }
381         },
382
383         'on_select' : function(list,twisty) {
384                 var obj = this;
385                 for (var i = 0; i < list.length; i++) {
386                         var node = obj.map_tree[ list[i] ];
387                         //if (node.lastChild.nodeName == 'treechildren') { continue; } else { alert(node.lastChild.nodeName); }
388                         var row_type = list[i].split('_')[0];
389                         var id = list[i].split('_')[1];
390                         switch(row_type) {
391                                 case 'aou' : obj.on_select_org(id,twisty); break;
392                                 case 'acn' : obj.on_select_acn(id,twisty); break;
393                                 default: break;
394                         }
395                 }
396         },
397
398         'on_select_acn' : function(acn_id,twisty) {
399                 var obj = this;
400                 try {
401                         var acn_tree = obj.map_acp[ 'acn_' + acn_id ];
402                         var funcs = [];
403                         if (acn_tree.copies()) {
404                                 for (var i = 0; i < acn_tree.copies().length; i++) {
405                                         funcs.push(
406                                                 function(c,a) {
407                                                         return function() {
408                                                                 obj.append_acp(c,a);
409                                                         }
410                                                 }( acn_tree.copies()[i], acn_tree )
411                                         )
412                                 }
413                         }
414                         JSAN.use('util.exec'); var exec = new util.exec();
415                         exec.chain( funcs );
416                 } catch(E) {
417                         alert(E);
418                 }
419         },
420
421         'on_select_org' : function(org_id,twisty) {
422                 var obj = this;
423                 var org = obj.data.hash.aou[ org_id ];
424                 var funcs = [];
425                 if (org.children()) {
426                         for (var i = 0; i < org.children().length; i++) {
427                                 funcs.push(
428                                         function(o,p) {
429                                                 return function() {
430                                                         obj.append_org(o,p)
431                                                 }
432                                         }(org.children()[i],org)
433                                 );
434                         }
435                 } 
436                 if (obj.map_acn[ 'aou_' + org_id ]) {
437                         for (var i = 0; i < obj.map_acn[ 'aou_' + org_id ].length; i++) {
438                                 funcs.push(
439                                         function(o,a) {
440                                                 return function() {
441                                                         obj.append_acn(o,a);
442                                                 }
443                                         }( org, obj.map_acn[ 'aou_' + org_id ][i] )
444                                 );
445                         }
446                 }
447                 JSAN.use('util.exec'); var exec = new util.exec();
448                 exec.chain( funcs );
449         },
450
451         'append_org' : function (org,parent_org,params) {
452                 var obj = this;
453                 try {
454                         if (obj.map_tree[ 'aou_' + org.id() ]) {
455                                 var x = obj.map_tree[ 'aou_' + org.id() ];
456                                 if (params) {
457                                         for (var i in params) {
458                                                 x.setAttribute(i,params[i]);
459                                         }
460                                 }
461                                 return x;
462                         }
463
464                         var data = {
465                                 'row' : {
466                                         'my' : {
467                                                 'aou' : org,
468                                         }
469                                 },
470                                 'skip_all_columns_except' : [0,1,2],
471                                 'retrieve_id' : 'aou_' + org.id(),
472                         };
473                 
474                         var acn_tree_list;
475                         if ( obj.org_ids.indexOf( org.id() ) == -1 ) {
476                                 if ( obj.data.hash.aout[ org.ou_type() ].can_have_vols() ) {
477                                         data.row.my.volume_count = '0';
478                                         data.row.my.copy_count = '<0>';
479                                 } else {
480                                         data.row.my.volume_count = '';
481                                         data.row.my.copy_count = '';
482                                 }
483                         } else {
484                                 var v_count = 0; var c_count = 0;
485                                 acn_tree_list = obj.network.simple_request(
486                                         'FM_ACN_TREE_LIST_RETRIEVE_VIA_RECORD_ID_AND_ORG_IDS',
487                                         [ ses(), obj.docid, [ org.id() ] ]
488                                 );
489                                 for (var i = 0; i < acn_tree_list.length; i++) {
490                                         v_count++;
491                                         obj.map_acn[ 'acn_' + acn_tree_list[i].id() ] = function(r){return r;}(acn_tree_list[i]);
492                                         var copies = acn_tree_list[i].copies(); if (copies) c_count += copies.length;
493                                         for (var j = 0; j < copies.length; j++) {
494                                                 obj.map_acp[ 'acp_' + copies[j].id() ] = function(r){return r;}(copies[j]);
495                                         }
496                                 }
497                                 data.row.my.volume_count = v_count;
498                                 data.row.my.copy_count = '<' + c_count + '>';
499                         }
500                         if (parent_org) {
501                                 data.node = obj.map_tree[ 'aou_' + parent_org.id() ];
502                         }
503
504                         var node = obj.list.append(data);
505                         if (params) {
506                                 for (var i in params) {
507                                         node.setAttribute(i,params[i]);
508                                 }
509                         }
510                         obj.map_tree[ 'aou_' + org.id() ] = node;
511
512                         if (org.children()) {
513                                 node.setAttribute('container','true');
514                         }
515
516                         if (parent_org) {
517                                 if ( obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].parent_ou() == parent_org.id() ) {
518                                         data.node.setAttribute('open','true');
519                                 }
520                         } else {
521                                 obj.map_tree[ 'aou_' + org.id() ].setAttribute('open','true');
522                         }
523
524                         if (acn_tree_list) {
525                                 obj.map_acn[ 'aou_' + org.id() ] = acn_tree_list;
526                                 node.setAttribute('container','true');
527                         }
528
529                 } catch(E) {
530                         dump(E+'\n');
531                         alert(E);
532                 }
533         },
534
535         'append_acn' : function( org, acn_tree, params ) {
536                 var obj = this;
537                 try {
538                         if (obj.map_tree[ 'acn_' + acn_tree.id() ]) {
539                                 var x = obj.map_tree[ 'acn_' + acn_tree.id() ];
540                                 if (params) {
541                                         for (var i in params) {
542                                                 x.setAttribute(i,params[i]);
543                                         }
544                                 }
545                                 return x;
546                         }
547
548                         var parent_node = obj.map_tree[ 'aou_' + org.id() ];
549                         var data = {
550                                 'row' : {
551                                         'my' : {
552                                                 'aou' : org,
553                                                 'acn' : acn_tree,
554                                                 'volume_count' : '',
555                                                 'copy_count' : acn_tree.copies() ? acn_tree.copies().length : '0',
556                                         }
557                                 },
558                                 'skip_all_columns_except' : [0,1,2],
559                                 'retrieve_id' : 'acn_' + acn_tree.id(),
560                                 'node' : parent_node,
561                         };
562                         var node = obj.list.append(data);
563                         obj.map_tree[ 'acn_' + acn_tree.id() ] =  node;
564                         if (params) {
565                                 for (var i in params) {
566                                         node.setAttribute(i,params[i]);
567                                 }
568                         }
569                         if (acn_tree.copies()) {
570                                 obj.map_acp[ 'acn_' + acn_tree.id() ] = acn_tree;
571                                 node.setAttribute('container','true');
572                         }
573
574                 } catch(E) {
575                         dump(E+'\n');
576                         alert(E);
577                 }
578         },
579
580         'append_acp' : function( acp_item, acn_tree, params ) {
581                 var obj = this;
582                 try {
583                         if (obj.map_tree[ 'acp_' + acp_item.id() ]) {
584                                 var x = obj.map_tree[ 'acp_' + acp_item.id() ];
585                                 if (params) {
586                                         for (var i in params) {
587                                                 x.setAttribute(i,params[i]);
588                                         }
589                                 }
590                                 return x;
591                         }
592
593                         var parent_node = obj.map_tree[ 'acn_' + acn_tree.id() ];
594                         var data = {
595                                 'row' : {
596                                         'my' : {
597                                                 'aou' : obj.data.hash.aou[ acn_tree.owning_lib() ],
598                                                 'acn' : acn_tree,
599                                                 'acp' : acp_item,
600                                                 'volume_count' : '',
601                                                 'copy_count' : '',
602                                         }
603                                 },
604                                 'retrieve_id' : 'acp_' + acp_item.id(),
605                                 'node' : parent_node,
606                         };
607                         var node = obj.list.append(data);
608                         obj.map_tree[ 'acp_' + acp_item.id() ] =  node;
609                         if (params) {
610                                 for (var i in params) {
611                                         node.setAttribute(i,params[i]);
612                                 }
613                         }
614
615                 } catch(E) {
616                         dump(E+'\n');
617                         alert(E);
618                 }
619         },
620
621         'list_init' : function( params ) {
622
623                 try {
624                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
625                         var obj = this;
626                         
627                         JSAN.use('circ.util');
628                         var columns = [
629                                 {
630                                         'id' : 'tree_location', 'label' : 'Location/Barcode', 'flex' : 1,
631                                         'primary' : true, 'hidden' : false, 
632                                         'render' : 'my.acp ? my.acp.barcode() : my.acn ? my.acn.label() : my.aou ? my.aou.shortname() + " : " + my.aou.name() : "???"'
633                                 },
634                                 {
635                                         'id' : 'volume_count', 'label' : 'Volumes', 'flex' : 0,
636                                         'primary' : false, 'hidden' : false, 
637                                         'render' : 'my.volume_count'
638                                 },
639                                 {
640                                         'id' : 'copy_count', 'label' : 'Copies', 'flex' : 0,
641                                         'primary' : false, 'hidden' : false, 
642                                         'render' : 'my.copy_count'
643                                 },
644                         ].concat(
645                                 circ.util.columns( 
646                                         { 
647                                                 'location' : { 'hidden' : false },
648                                                 'circ_lib' : { 'hidden' : false },
649                                                 'owning_lib' : { 'hidden' : false },
650                                                 'call_number' : { 'hidden' : false },
651                                                 'status' : { 'hidden' : false },
652                                         },
653                                         {
654                                                 'just_these' : [
655                                                         'owning_lib',
656                                                         'circ_lib',
657                                                         'call_number',
658                                                         'copy_number',
659                                                         'location',
660                                                         'barcode',
661                                                         'loan_duration',
662                                                         'fine_level',
663                                                         'circulate',
664                                                         'holdable',
665                                                         'opac_visible',
666                                                         'ref',
667                                                         'deposit',
668                                                         'deposit_amount',
669                                                         'price',
670                                                         'circ_as_type',
671                                                         'circ_modifier',
672                                                         'status',
673                                                         'alert_message',
674                                                         'acp_id',
675                                                 ]
676                                         }
677                                 )
678                         );
679                         JSAN.use('util.list'); obj.list = new util.list('copy_tree');
680                         obj.list.init(
681                                 {
682                                         'columns' : columns,
683                                         'map_row_to_column' : circ.util.std_map_row_to_column(' '),
684                                         'retrieve_row' : function(params) {
685
686                                                 var row = params.row;
687
688                                                 var funcs = [];
689                                         /*      
690                                                 if (!row.my.mvr) funcs.push(
691                                                         function() {
692
693                                                                 row.my.mvr = obj.network.request(
694                                                                         api.MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.app,
695                                                                         api.MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.method,
696                                                                         [ row.my.circ.target_copy() ]
697                                                                 );
698
699                                                         }
700                                                 );
701                                                 if (!row.my.acp) {
702                                                         funcs.push(     
703                                                                 function() {
704
705                                                                         row.my.acp = obj.network.request(
706                                                                                 api.FM_ACP_RETRIEVE.app,
707                                                                                 api.FM_ACP_RETRIEVE.method,
708                                                                                 [ row.my.circ.target_copy() ]
709                                                                         );
710
711                                                                         params.row_node.setAttribute( 'retrieve_id',row.my.acp.barcode() );
712
713                                                                 }
714                                                         );
715                                                 } else {
716                                                         params.row_node.setAttribute( 'retrieve_id',row.my.acp.barcode() );
717                                                 }
718                                         */
719                                                 funcs.push(
720                                                         function() {
721
722                                                                 if (typeof params.on_retrieve == 'function') {
723                                                                         params.on_retrieve(row);
724                                                                 }
725
726                                                         }
727                                                 );
728
729                                                 JSAN.use('util.exec'); var exec = new util.exec();
730                                                 exec.on_error = function(E) {
731                                                         var err = 'items chain: ' + js2JSON(E);
732                                                         obj.error.sdump('D_ERROR',err);
733                                                         return true; /* keep going */
734                                                 }
735                                                 exec.chain( funcs );
736
737                                                 return row;
738                                         },
739                                         'on_click' : function(ev) {
740                                                 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserRead');
741                                                 var row = {}; var col = {}; var nobj = {};
742                                                 obj.list.node.treeBoxObject.getCellAt(ev.clientX,ev.clientY,row,col,nobj);
743                                                 if ((row.value == -1)||(nobj.value != 'twisty')) { return; }
744                                                 var node = obj.list.node.contentView.getItemAtIndex(row.value);
745                                                 var list = [ node.getAttribute('retrieve_id') ];
746                                                 if (typeof obj.on_select == 'function') {
747                                                         obj.on_select(list,true);
748                                                 }
749                                                 if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
750                                                         window.xulG.on_select(list);
751                                                 }
752                                         },
753                                         'on_select' : function(ev) {
754                                                 JSAN.use('util.functional');
755                                                 var sel = obj.list.retrieve_selection();
756                                                 obj.sel_list = util.functional.map_list(
757                                                         sel,
758                                                         function(o) { return o.getAttribute('retrieve_id'); }
759                                                 );
760                                                 if (typeof obj.on_select == 'function') {
761                                                         obj.on_select(obj.sel_list);
762                                                 }
763                                                 if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
764                                                         window.xulG.on_select(obj.sel_list);
765                                                 }
766                                         },
767                                 }
768                         );
769         
770
771                 } catch(E) {
772                         this.error.sdump('D_ERROR','cat.copy_browser.list_init: ' + E + '\n');
773                         alert(E);
774                 }
775         },
776
777         'refresh_list' : function() { alert('FIXME: refresh the list now'); },
778 }
779
780 dump('exiting cat.copy_browser.js\n');