Replace a few hardcoded strings in the serials JavaScript
[working/Evergreen.git] / Open-ILS / xul / staff_client / server / serial / manage_dists.js
1 dump('entering serial/manage_dists.js\n');
2 // vim:et:sw=4:ts=4:
3
4 if (typeof serial == 'undefined') serial = {};
5 serial.manage_dists = function (params) {
6     try {
7         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
8         JSAN.use('util.error'); this.error = new util.error();
9     } catch(E) {
10         dump('serial/manage_dists: ' + E + '\n');
11     }
12 };
13
14 serial.manage_dists.prototype = {
15
16     'map_tree' : {},
17     'map_sdist' : {},
18     //'map_sstr' : {},
19     'sel_list' : [],
20     'funcs' : [],
21     'editor_indexes' : { 'sdist' : 1, 'sstr' : 2, 'sbsum' : 3, 'sssum' : 4, 'sisum' : 5 },
22
23     'ids_from_sel_list' : function(type) {
24         var obj = this;
25         JSAN.use('util.functional');
26
27         var list = util.functional.map_list(
28             util.functional.filter_list(
29                 obj.sel_list,
30                 function (o) {
31                     return o.split(/_/)[0] == type;
32                 }
33             ),
34             function (o) {
35                 return o.split(/_/)[1];
36             }
37         );
38
39         return list;
40     },
41
42     'editor_init' : function(type, mode, params) {
43         var obj = this;
44         try {
45             $('serial_manage_dists_editor_deck').selectedIndex = obj.editor_indexes[type];
46             var editor_type = type + '_editor';
47             if (typeof obj[editor_type] == 'undefined') {
48                 JSAN.use('serial.' + editor_type);
49                 obj[editor_type] = new serial[editor_type](); 
50             }
51
52             params.do_edit = true;
53             params.handle_update = true;
54             if (mode == 'add') {
55                 params.trigger_refresh = true;
56                 params.refresh_command = function () {obj.refresh_list();};
57             }
58             obj[editor_type].init(params);
59         } catch(E) {
60             obj.error.standard_unexpected_error_alert('editor_init() error',E);
61         }
62     },
63
64     'do_delete' : function(type, method, overridable_events) {
65         var obj = this;
66         try {
67             JSAN.use('util.functional');
68
69             var list = util.functional.filter_list(
70                 obj.sel_list,
71                 function (o) {
72                     return o.split(/_/)[0] == type;
73                 }
74             );
75
76             list = util.functional.map_list(
77                 list,
78                 function (o) {
79                     return JSON2js( js2JSON( obj['map_' + type][ type + '_' + o.split(/_/)[1] ] ) );
80                 }
81             );
82
83             //TODO: proper messages
84             var delete_msg;
85             if (list.length != 1) {
86                 delete_msg = document.getElementById('serialStrings').getFormattedString('staff.serial.manage_subs.delete_' + type + '.confirm.plural', [list.length]);
87             } else {
88                 delete_msg = document.getElementById('serialStrings').getString('staff.serial.manage_subs.delete_' + type + '.confirm');
89             }
90             var r = obj.error.yns_alert(
91                     delete_msg,
92                     document.getElementById('serialStrings').getString('staff.serial.manage_subs.delete_' + type + '.title'),
93                     document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.delete'),
94                     document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.cancel'),
95                     null,
96                     document.getElementById('commonStrings').getString('common.confirm')
97             );
98
99             if (r == 0) {
100                 for (var i = 0; i < list.length; i++) {
101                     list[i].isdeleted('1');
102                 }
103                 var robj = obj.network.request(
104                     'open-ils.serial', 
105                     method, 
106                     [ ses(), list, true ],
107                     null,
108                     {
109                         'title' : document.getElementById('serialStrings').getString('staff.serial.manage_subs.delete_' + type + '.override'),
110                         'overridable_events' : overridable_events
111                     }
112                 );
113                 if (robj == null) throw(robj);
114                 if (typeof robj.ilsevent != 'undefined') {
115                     if (robj.ilsevent != 0) {
116                         var overridable = false;
117                         for (i = 0; i < overridable_events.length; i++) {
118                             if (overridable_events[i] == robj.ilsevent) {
119                                 overridable = true;
120                                 break;
121                             }
122                         }
123                         if (!overridable) throw(robj);
124                     }
125                 }
126                 obj.refresh_list();
127             }
128         } catch(E) {
129             obj.error.standard_unexpected_error_alert(document.getElementById('serialStrings').getString('staff.serial.manage_subs.delete.error'),E);
130             obj.refresh_list();
131         }
132     },
133
134     'init' : function( params ) {
135
136         try {
137             netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
138             var obj = this;
139
140             obj.docid = params.docid;
141
142             JSAN.use('util.network'); obj.network = new util.network();
143             JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
144             JSAN.use('util.controller'); obj.controller = new util.controller();
145             obj.controller.init(
146                 {
147                     control_map : {
148                         'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
149                         'sel_clip' : [
150                             ['command'],
151                             function() { obj.list.clipboard(); }
152                         ],
153                         'cmd_broken' : [
154                             ['command'],
155                             function() { 
156                                 alert(document.getElementById('commonStrings').getString('common.unimplemented'));
157                             }
158                         ],
159                         'cmd_show_my_libs' : [
160                             ['command'],
161                             function() { 
162                                 obj.show_my_libs(); 
163                             }
164                         ],
165                         'cmd_clear' : [
166                             ['command'],
167                             function() {
168                                 obj.map_tree = {};
169                                 obj.list.clear();
170                             }
171                         ],
172                         'cmd_add_siss' : [
173                             ['command'],
174                             function() {
175                                 try {
176                                     var list = obj.ids_from_sel_list('sdist');
177                                     if (list.length == 0) list = obj.ids_from_sel_list('siss-group');
178                                     if (list.length == 0) return;
179
180                                     /*TODO: permission check?
181                                     //populate 'list' with owning_libs of subs, TODO
182                                     var edit = 0;
183                                     try {
184                                         edit = obj.network.request(
185                                             api.PERM_MULTI_ORG_CHECK.app,
186                                             api.PERM_MULTI_ORG_CHECK.method,
187                                             [ 
188                                                 ses(), 
189                                                 obj.data.list.au[0].id(), 
190                                                 list,
191                                                 [ 'CREATE_COPY' ]
192                                             ]
193                                         ).length == 0 ? 1 : 0;
194                                     } catch(E) {
195                                         obj.error.sdump('D_ERROR','batch permission check: ' + E);
196                                     }
197
198                                     if (edit==0) return; // no read-only view for this interface */
199                                     var new_siss = new siss();
200                                     new_siss.subscription(list[0]);//TODO: add multiple at once support?
201                                     new_siss.isnew(1);
202                                     var params = {};
203                                     params.sisses = [new_siss];
204                                     obj.editor_init('siss', 'add', params);
205                                 } catch(E) {
206                                     obj.error.standard_unexpected_error_alert(document.getElementById('serialStrings').getString('staff.serial.manage_subs.add.error'),E);
207                                 }
208                             }
209                         ],
210                         'cmd_add_sstr' : [
211                             ['command'],
212                             function() {
213                                 try {
214                                     var list = obj.ids_from_sel_list('sdist');
215                                     if (list.length == 0) list = obj.ids_from_sel_list('sstr-group');
216                                     if (list.length == 0) return;
217
218                                     /*TODO: permission check?
219                                     //populate 'list' with owning_libs of subs, TODO
220                                     var edit = 0;
221                                     try {
222                                         edit = obj.network.request(
223                                             api.PERM_MULTI_ORG_CHECK.app,
224                                             api.PERM_MULTI_ORG_CHECK.method,
225                                             [ 
226                                                 ses(), 
227                                                 obj.data.list.au[0].id(), 
228                                                 list,
229                                                 [ 'CREATE_COPY' ]
230                                             ]
231                                         ).length == 0 ? 1 : 0;
232                                     } catch(E) {
233                                         obj.error.sdump('D_ERROR','batch permission check: ' + E);
234                                     }
235
236                                     if (edit==0) return; // no read-only view for this interface */
237                                     var new_sstr = new sstr();
238                                     new_sstr.subscription(list[0]);//TODO: add multiple at once support?
239                                     new_sstr.holding_lib(obj.map_sdist['sdist_' + list[0]].owning_lib());//default to sub owning lib
240                                     new_sstr.label('Default');
241                                     new_sstr.isnew(1);
242                                     var params = {};
243                                     params.sstrs = [new_sstr];
244                                     obj.editor_init('sstr', 'add', params);
245                                 } catch(E) {
246                                     obj.error.standard_unexpected_error_alert(document.getElementById('serialStrings').getString('staff.serial.manage_subs.add.error'),E);
247                                 }
248                             }
249                         ],
250                         'cmd_delete_sstr' : [
251                             ['command'],
252                             function() {
253                                 var overridable_events = [ //TODO: proper overrides
254                                 ];
255                                 obj.do_delete('sstr', 'open-ils.serial.distribution.fleshed.batch.update', overridable_events);
256                             }
257                         ],
258                         'cmd_delete_siss' : [
259                             ['command'],
260                             function() {
261                                 var overridable_events = [ //TODO: proper overrides
262                                 ];
263                                 obj.do_delete('siss', 'open-ils.serial.issuance.fleshed.batch.update', overridable_events);
264                             }
265                         ],
266                         'cmd_delete_sdist' : [
267                             ['command'],
268                             function() {
269                                 var overridable_events = [
270                                     11000 // SERIAL_SUBSCRIPTION_NOT_EMPTY
271                                 ];
272                                 obj.do_delete('sdist', 'open-ils.serial.subscription.fleshed.batch.update', overridable_events);
273                             }
274                         ],
275                         'cmd_mark_library' : [
276                             ['command'],
277                             function() {
278                                 try {
279                                     var list = obj.ids_from_sel_list('aou');
280                                     if (list.length == 1) {
281                                         obj.data.marked_library = { 'lib' : list[0], 'docid' : obj.docid };
282                                         obj.data.stash('marked_library');
283                                         alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_library.alert'));
284                                     } else {
285                                         obj.error.yns_alert(
286                                                 document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_library.prompt'),
287                                                 document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_library.title'),
288                                                 document.getElementById('commonStrings').getString('common.ok'),
289                                                 null,
290                                                 null,
291                                                 document.getElementById('commonStrings').getString('common.confirm')
292                                                 );
293                                     }
294                                 } catch(E) {
295                                     obj.error.standard_unexpected_error_alert('manage_dists.js -> mark library',E);
296                                 }
297                             }
298                         ],
299
300                         'cmd_mark_distribution' : [
301                             ['command'],
302                             function() {
303                                 try {
304                                     var list = obj.ids_from_sel_list('sdist');
305                                     if (list.length == 1) {
306                                         obj.data.marked_distribution = list[0];
307                                         obj.data.stash('marked_distribution');
308                                         alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_volume.alert'));
309                                     } else {
310                                         obj.error.yns_alert(
311                                                 document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_volume.prompt'),
312                                                 document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_volume.title'),
313                                                 document.getElementById('commonStrings').getString('common.ok'),
314                                                 null,
315                                                 null,
316                                                 document.getElementById('commonStrings').getString('common.confirm')
317                                                 );
318                                     }
319                                 } catch(E) {
320                                     obj.error.standard_unexpected_error_alert('manage_dists.js -> mark distribution',E);
321                                 }
322                             }
323                         ],
324                         'cmd_add_distributions' : [
325                             ['command'],
326                             function() {
327                                 try {
328                                     var list = obj.ids_from_sel_list('aou');
329                                     if (list.length == 0) return;
330                                     //TODO: permission check?
331                                     /*var edit = 0;
332                                     try {
333                                         edit = obj.network.request(
334                                             api.PERM_MULTI_ORG_CHECK.app,
335                                             api.PERM_MULTI_ORG_CHECK.method,
336                                             [ 
337                                                 ses(), 
338                                                 obj.data.list.au[0].id(), 
339                                                 list,
340                                                 [ 'CREATE_VOLUME', 'CREATE_COPY' ]
341                                             ]
342                                         ).length == 0 ? 1 : 0;
343                                     } catch(E) {
344                                         obj.error.sdump('D_ERROR','batch permission check: ' + E);
345                                     }
346
347                                     if (edit==0) {
348                                         alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.add_volume.permission_error'));
349                                         return; // no read-only view for this interface
350                                     } */
351                                     var new_sdist = new sdist();
352                                     new_sdist.owning_lib(list[0]);//TODO: add multiple at once support?
353                                     new_sdist.isnew(1);
354                                     new_sdist.record_entry(obj.docid);
355                                     var params = {};
356                                     params.sdists = [new_sdist];
357                                     obj.editor_init('sdist', 'add', params);
358                                 } catch(E) {
359                                     obj.error.standard_unexpected_error_alert(document.getElementById('serialStrings').getString('staff.serial.manage_subs.add.error'),E);
360                                 }
361                             }
362                         ],
363                         'cmd_transfer_distribution' : [
364                             ['command'],
365                             function() {
366                                 try {
367                                     obj.data.stash_retrieve();
368                                     if (!obj.data.marked_library) {
369                                         alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer_volume.alert'));
370                                         return;
371                                     }
372                                     
373                                     var list = obj.ids_from_sel_list('sdist');
374
375                                     netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
376
377                                     JSAN.use('util.functional');
378
379                                     var sdist_list = util.functional.map_list(
380                                         list,
381                                         function (o) {
382                                             return obj.map_sdist[ 'sdist_' + o ].start_date();
383                                         }
384                                     ).join(document.getElementById('commonStrings').getString('common.grouping_string'));
385
386                                     var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: auto">';
387                                     xml += '<description>';
388                                     xml += document.getElementById('catStrings').getFormattedString('staff.cat.copy_browser.transfer.prompt', [sdist_list, obj.data.hash.aou[ obj.data.marked_library.lib ].shortname()]);
389                                     xml += '</description>';
390                                     xml += '<hbox><button label="' + document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.submit.label') + '" name="fancy_submit"/>';
391                                     xml += '<button label="' 
392                                         + document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.cancel.label') 
393                                         + '" accesskey="' 
394                                         + document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.cancel.accesskey') 
395                                         + '" name="fancy_cancel"/></hbox>';
396                                     xml += '<iframe style="overflow: scroll" flex="1" src="' + urls.XUL_BIB_BRIEF + '?docid=' + obj.data.marked_library.docid + '"/>';
397                                     xml += '</vbox>';
398                                     JSAN.use('OpenILS.data');
399                                     var data = new OpenILS.data(); data.init({'via':'stash'});
400                                     //data.temp_transfer = xml; data.stash('temp_transfer');
401                                     JSAN.use('util.window'); var win = new util.window();
402                                     var fancy_prompt_data = win.open(
403                                         urls.XUL_FANCY_PROMPT,
404                                         //+ '?xml_in_stash=temp_transfer'
405                                         //+ '&title=' + window.escape('Volume Transfer'),
406                                         'fancy_prompt', 'chrome,resizable,modal,width=500,height=300',
407                                         {
408                                             'xml' : xml,
409                                             'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.title')
410                                         }
411                                     );
412
413                                     if (fancy_prompt_data.fancy_status == 'incomplete') {
414                                         alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.incomplete'));
415                                         return;
416                                     }
417
418                                     var robj = obj.network.simple_request(
419                                         'FM_ACN_TRANSFER', 
420                                         [ ses(), { 'docid' : obj.data.marked_library.docid, 'lib' : obj.data.marked_library.lib, 'distributions' : list } ],
421                                         null,
422                                         {
423                                             'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.override.failure'),
424                                             'overridable_events' : [
425                                                 1208, // TITLE_LAST_COPY
426                                                 1219, // COPY_REMOTE_CIRC_LIB
427                                             ],
428                                         }
429                                     );
430
431                                     if (typeof robj.ilsevent != 'undefined') {
432                                         if (robj.ilsevent == 1221) { // ORG_CANNOT_HAVE_VOLS
433                                             alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.ineligible_destination'));
434                                         } else {
435                                             throw(robj);
436                                         }
437                                     } else {
438                                         alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.success'));
439                                     }
440
441                                 } catch(E) {
442                                     obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.unexpected_error'),E);
443                                 }
444                                 obj.refresh_list();
445                             }
446                         ],
447
448                         'cmd_transfer_sstrs' : [
449                             ['command'],
450                             function() {
451                                 try {
452                                     obj.data.stash_retrieve();
453                                     if (!obj.data.marked_distribution) {
454                                         alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer_items.missing_volume'));
455                                         return;
456                                     }
457                                     
458                                     JSAN.use('util.functional');
459
460                                     var list = obj.ids_from_sel_list('sstr');
461                                     var distribution = obj.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ obj.data.marked_distribution ]);
462
463                                     JSAN.use('cat.util'); cat.util.transfer_copies( { 
464                                         'distribution_ids' : list, 
465                                         'docid' : distribution.record(),
466                                         'distribution_label' : distribution.start_date(),
467                                         'owning_lib' : distribution.owning_lib(),
468                                     } );
469
470                                 } catch(E) {
471                                     obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer_items.unexpected_error'),E);
472                                 }
473                                 obj.refresh_list();
474                             }
475                         ],
476                         'cmd_refresh_list' : [
477                             ['command'],
478                             function() {
479                                 obj.refresh_list();
480                             }
481                         ],
482 /*dbw2                      'sel_distribution_details' : [
483                             ['command'],
484                             function() {
485                                 JSAN.use('util.functional');
486
487                                 var list = util.functional.filter_list(
488                                     obj.sel_list,
489                                     function (o) {
490                                         return o.split(/_/)[0] == 'sstr';
491                                     }
492                                 );
493
494                                 list = util.functional.map_list(
495                                     list,
496                                     function (o) {
497                                         return o.split(/_/)[1];
498                                     }
499                                 );
500     
501                                 JSAN.use('circ.util');
502                                 for (var i = 0; i < list.length; i++) {
503                                     circ.util.show_copy_details( list[i] );
504                                 }
505                             }
506                         ],
507                         'cmd_edit_sstrs' : [
508                             ['command'],
509                             function() {
510                                 try {
511                                     JSAN.use('util.functional');
512
513                                     var list = util.functional.filter_list(
514                                         obj.sel_list,
515                                         function (o) {
516                                             return o.split(/_/)[0] == 'sstr';
517                                         }
518                                     );
519
520                                     list = util.functional.map_list(
521                                         list,
522                                         function (o) {
523                                             return o.split(/_/)[1];
524                                         }
525                                     );
526
527                                     JSAN.use('cat.util'); cat.util.spawn_copy_editor( { 'copy_ids' : list, 'edit' : 1 } );
528                                     obj.refresh_list();
529
530                                 } catch(E) {
531                                     obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_items.error'),E);
532                                 }
533                             }
534                         ], dbw2*/
535
536 /*dbw2                      'cmd_print_spine_labels' : [
537                             ['command'],
538                             function() {
539                                 try {
540                                     JSAN.use('util.functional');
541                                     
542                                     var list = util.functional.filter_list(
543                                         obj.sel_list,
544                                         function (o) {
545                                             return o.split(/_/)[0] == 'sstr';
546                                         }
547                                     );
548
549                                     list = util.functional.map_list(
550                                         list,
551                                         function (o) {
552                                             return obj.map_sstr[ o ];
553                                         }
554                                     );
555
556                                     obj.data.temp_barcodes_for_labels = util.functional.map_list( list, function(o){return o.barcode();}) ; 
557                                     obj.data.stash('temp_barcodes_for_labels');
558                                     xulG.new_tab(
559                                         xulG.url_prefix( urls.XUL_SPINE_LABEL ),
560                                         { 'tab_name' : document.getElementById('catStrings').getString('staff.cat.copy_browser.print_spine.tab') },
561                                         {}
562                                     );
563                                 } catch(E) {
564                                     obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.print_spine.error'),E);
565                                 }
566                             }
567                         ]
568                         dbw2*/
569                     }
570                 }
571             );
572
573             obj.list_init(params);
574
575             obj.org_ids = obj.network.simple_request('FM_SDIST_AOU_IDS_RETRIEVE_VIA_RECORD_ID.authoritative',[ obj.docid ]);
576             if (typeof obj.org_ids.ilsevent != 'undefined') throw(obj.org_ids);
577             JSAN.use('util.functional'); 
578             obj.org_ids = util.functional.map_list( obj.org_ids, function (o) { return Number(o); });
579
580             var org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
581             //obj.show_libs( org );
582
583             //obj.show_my_libs();
584
585             JSAN.use('util.file'); JSAN.use('util.widgets');
586
587             var file; var list_data; var ml; 
588
589             file = new util.file('offline_ou_list'); 
590             if (file._file.exists()) {
591                 list_data = file.get_object(); file.close();
592                 for (var i = 0; i < list_data[0].length; i++) { // make sure all entries are enabled
593                     list_data[0][i][2] = false;
594                 }
595                 ml = util.widgets.make_menulist( list_data[0], list_data[1] );
596                 ml.setAttribute('id','sdist_lib_menu'); document.getElementById('serial_dist_lib_menu').appendChild(ml);
597                 //TODO: class this menu properly
598                 for (var i = 0; i < obj.org_ids.length; i++) {
599                     ml.getElementsByAttribute('value',obj.org_ids[i])[0].setAttribute('class','has_distributions');
600                 }
601                 ml.firstChild.addEventListener(
602                     'popupshown',
603                     function(ev) {
604                         document.getElementById('legend').setAttribute('hidden','false');
605                     },
606                     false
607                 );
608                 ml.firstChild.addEventListener(
609                     'popuphidden',
610                     function(ev) {
611                         document.getElementById('legend').setAttribute('hidden','true');
612                     },
613                     false
614                 );
615                 ml.addEventListener(
616                     'command',
617                     function(ev) {
618                         if (document.getElementById('refresh_button')) document.getElementById('refresh_button').focus(); 
619                         JSAN.use('util.file'); var file = new util.file('manage_dists_prefs.'+obj.data.server_unadorned);
620                         util.widgets.save_attributes(file, { 'sdist_lib_menu' : [ 'value' ], 'show_sdists' : [ 'checked' ], 'show_groups' : [ 'checked' ] });
621                         obj.refresh_list();
622                     },
623                     false
624                 );
625             } else {
626                 throw(document.getElementById('catStrings').getString('staff.cat.copy_browser.missing_library') + '\n');
627             }
628
629             file = new util.file('manage_dists_prefs.'+obj.data.server_unadorned);
630             util.widgets.load_attributes(file);
631             obj.default_lib = ml.getAttribute('value');
632             ml.value = obj.default_lib;
633             if (! obj.default_lib) {
634                 obj.default_lib = org.id();
635                 ml.setAttribute('value',obj.default_lib);
636                 ml.value = obj.default_lib;
637             }
638
639             document.getElementById('show_sdists').addEventListener(
640                 'command',
641                 function(ev) {
642                     JSAN.use('util.file'); var file = new util.file('manage_dists_prefs.'+obj.data.server_unadorned);
643                     util.widgets.save_attributes(file, { 'sdist_lib_menu' : [ 'value' ], 'show_sdists' : [ 'checked' ], 'show_groups' : [ 'checked' ] });
644                 },
645                 false
646             );
647
648             document.getElementById('show_groups').addEventListener(
649                 'command',
650                 function(ev) {
651                     JSAN.use('util.file'); var file = new util.file('manage_dists_prefs.'+obj.data.server_unadorned);
652                     util.widgets.save_attributes(file, { 'sdist_lib_menu' : [ 'value' ], 'show_sdists' : [ 'checked' ], 'show_groups' : [ 'checked' ] });
653                 },
654                 false
655             );
656
657             obj.show_my_libs( obj.default_lib );
658
659             JSAN.use('util.exec'); var exec = new util.exec(20); exec.timer(obj.funcs,100);
660
661             obj.toggle_actions(); // disable menus initially
662
663         } catch(E) {
664             this.error.standard_unexpected_error_alert('serial/manage_dists.init: ',E);
665         }
666     },
667
668     'show_my_libs' : function(org) {
669         var obj = this;
670         try {
671             if (!org) {
672                 org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
673             } else {
674                 if (typeof org != 'object') org = obj.data.hash.aou[ org ];
675             }
676             obj.show_libs( org, false );
677         } catch(E) {
678             alert(E);
679         }
680     },
681
682     'show_libs' : function(start_aou,show_open) {
683         var obj = this;
684         try {
685             if (!start_aou) throw('show_libs: Need a start_aou');
686             JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
687             JSAN.use('util.functional'); 
688
689             var parents = [];
690             var temp_aou = start_aou;
691             while ( temp_aou.parent_ou() ) {
692                 temp_aou = obj.data.hash.aou[ temp_aou.parent_ou() ];
693                 parents.push( temp_aou );
694             }
695             parents.reverse();
696
697             for (var i = 0; i < parents.length; i++) {
698                 obj.funcs.push(
699                     function(o,p) {
700                         return function() { 
701                             obj.append_org(o,p,{'container':'true','open':'true'}); 
702                         };
703                     }(parents[i], obj.data.hash.aou[ parents[i].parent_ou() ])
704                 );
705             }
706
707             obj.funcs.push(
708                 function(o,p) {
709                     return function() { obj.append_org(o,p); };
710                 }(start_aou,obj.data.hash.aou[ start_aou.parent_ou() ])
711             );
712
713             obj.funcs.push(
714                 function() {
715                     if (start_aou.children()) {
716                         var x = obj.map_tree[ 'aou_' + start_aou.id() ];
717                         x.setAttribute('container','true');
718                         if (show_open) x.setAttribute('open','true');
719                         for (var i = 0; i < start_aou.children().length; i++) {
720                             obj.funcs.push(
721                                 function(o,p) {
722                                     return function() { obj.append_org(o,p); };
723                                 }( start_aou.children()[i], start_aou )
724                             );
725                         }
726                     }
727                 }
728             );
729
730         } catch(E) {
731             alert(E);
732         }
733     },
734
735     'on_select' : function(list,twisty) {
736         var obj = this;
737         var sel_lists = {};
738
739         for (var i = 0; i < list.length; i++) {
740             var row_type = list[i].split('_')[0];
741             var id = list[i].split('_')[1];
742
743             if (!sel_lists[row_type]) sel_lists[row_type] = [];
744             sel_lists[row_type].push(id);
745
746             if (twisty) {
747                 switch(row_type) {
748                     case 'aou' : obj.on_click_aou(id,twisty); break;
749                     case 'sdist' : obj.on_select_sdist(id,twisty); break;
750                     default: break;
751                 }
752             }
753         }
754
755         if (!obj.focused_node_retrieve_id) return;
756
757         var row_type = obj.focused_node_retrieve_id.split('_')[0];
758         var id = obj.focused_node_retrieve_id.split('_')[1];
759
760         if (sel_lists[row_type]) { // the type focused is in the selection (usually the case)
761             switch(row_type) {
762                 case 'aou' : obj.on_click_aou(id,twisty); break;
763                 default: if (obj['on_click_' + row_type]) obj['on_click_' + row_type](sel_lists[row_type],twisty);
764             }
765         }
766     },
767
768     'on_select_sdist' : function(sdist_id,twisty) {
769         var obj = this;
770         try {
771             var sdist_tree = obj.map_sdist[ 'sdist_' + sdist_id ];
772             obj.funcs.push( function() { 
773                 document.getElementById('cmd_refresh_list').setAttribute('disabled','true'); 
774                 document.getElementById('sdist_lib_menu').setAttribute('disabled','true'); 
775             } );
776             if (sdist_tree.basic_summary()) {
777                 obj.funcs.push(
778                     function(c,a) {
779                         return function() {
780                             obj.append_member(c,a,[],'sbsum', false);
781                         }
782                     }( sdist_tree.basic_summary(), sdist_tree )
783                 );
784             }
785             if (sdist_tree.supplement_summary()) {
786                 obj.funcs.push(
787                     function(c,a) {
788                         return function() {
789                             obj.append_member(c,a,[],'sssum', false);
790                         }
791                     }( sdist_tree.supplement_summary(), sdist_tree )
792                 );
793             }
794             if (sdist_tree.index_summary()) {
795                 obj.funcs.push(
796                     function(c,a) {
797                         return function() {
798                             obj.append_member(c,a,[],'sisum', false);
799                         }
800                     }( sdist_tree.index_summary(), sdist_tree )
801                 );
802             }
803             if (sdist_tree.streams()) {
804                 for (var i = 0; i < sdist_tree.streams().length; i++) {
805                     obj.funcs.push(
806                         function(c,a) {
807                             return function() {
808                                 obj.append_member(c,a,[],'sstr', true);
809                             }
810                         }( sdist_tree.streams()[i], sdist_tree )
811                     )
812                 }
813             }
814             /* TODO: template editing would be convenient here, but a little too confusing
815             // add template nodes
816             var same_templates;
817             var has_bind_template;
818             if (sdist_tree.receive_unit_template()) {
819                 if (sdist_tree.bind_unit_template()) {
820                     has_bind_template = true;                    
821                     if (sdist_tree.receive_unit_template().id() == sdist_tree.bind_unit_template().id()) {
822                         same_templates = true;
823                         obj.funcs.push(
824                             function(c,a) {
825                                 return function() {
826                                     obj.append_member(c,a,[],'act', false, 'Receive/Bind Unit Template');
827                                 }
828                             }( sdist_tree.receive_unit_template(), sdist_tree )
829                         )
830                     }
831                 }
832
833                 if (!same_templates) {
834                     obj.funcs.push(
835                         function(c,a) {
836                             return function() {
837                                 obj.append_member(c,a,[],'act', false, 'Receive Unit Template');
838                             }
839                         }( sdist_tree.receive_unit_template(), sdist_tree )
840                     )
841                 }
842             }
843             if (has_bind_template && !same_templates) {
844                 obj.funcs.push(
845                     function(c,a) {
846                         return function() {
847                             obj.append_member(c,a,[],'act', false, 'Bind Unit Template');
848                         }
849                     }( sdist_tree.bind_unit_template(), sdist_tree )
850                 )
851             }
852             */
853             obj.funcs.push( function() { 
854                 document.getElementById('cmd_refresh_list').setAttribute('disabled','false'); 
855                 document.getElementById('sdist_lib_menu').setAttribute('disabled','false'); 
856             } );
857         } catch(E) {
858             alert(E);
859         }
860     },
861
862     'on_click_sdist' : function(sdist_ids,twisty) {
863         var obj = this;
864         try {
865             // draw sdist editor
866             if (typeof twisty == 'undefined') {
867                 var params = {};
868                 params.sdist_ids = sdist_ids;
869                 params.xul_id_prefix = 'sdist2';
870                 obj.editor_init('sdist', 'edit', params);
871             }
872         } catch(E) {
873             alert(E);
874         }
875     },
876
877     'on_click_sstr' : function(sstr_ids,twisty) {
878         var obj = this;
879         try {
880             // draw sstr editor
881             if (typeof twisty == 'undefined') {
882                 var params = {};
883                 params.sstr_ids = sstr_ids;
884                 obj.editor_init('sstr', 'edit', params);
885             }
886         } catch(E) {
887             alert(E);
888         }
889     },
890
891     'on_click_sbsum' : function(sbsum_ids,twisty) {
892         var obj = this;
893         try {
894             // draw sbsum editor
895             if (typeof twisty == 'undefined') {
896                 var params = {};
897                 params.sbsum_ids = sbsum_ids;
898                 obj.editor_init('sbsum', 'edit', params);
899             }
900         } catch(E) {
901             alert(E);
902         }
903     },
904
905     'on_click_sssum' : function(sssum_ids,twisty) {
906         var obj = this;
907         try {
908             // draw sssum editor
909             if (typeof twisty == 'undefined') {
910                 var params = {};
911                 params.sssum_ids = sssum_ids;
912                 obj.editor_init('sssum', 'edit', params);
913             }
914         } catch(E) {
915             alert(E);
916         }
917     },
918
919     'on_click_sisum' : function(sisum_ids,twisty) {
920         var obj = this;
921         try {
922             // draw sisum editor
923             if (typeof twisty == 'undefined') {
924                 var params = {};
925                 params.sisum_ids = sisum_ids;
926                 obj.editor_init('sisum', 'edit', params);
927             }
928         } catch(E) {
929             alert(E);
930         }
931     },
932
933     'on_click_aou' : function(org_id,twisty) {
934         var obj = this;
935         var org = obj.data.hash.aou[ org_id ];
936         var default_aou = obj.data.hash.aou[obj.default_lib];
937         obj.funcs.push( function() { 
938             document.getElementById('cmd_refresh_list').setAttribute('disabled','true'); 
939             document.getElementById('sdist_lib_menu').setAttribute('disabled','true'); 
940         } );
941         if (org.children()) {
942             for (var i = 0; i < org.children().length; i++) {
943                 var child = org.children()[i];
944                 if (orgIsMine(default_aou,child)) {
945                     obj.funcs.push(
946                         function(o,p) {
947                             return function() {
948                                 obj.append_org(o,p)
949                             }
950                         }(child,org)
951                     );
952                 }
953             }
954         } 
955         if (obj.map_sdist[ 'aou_' + org_id ]) {
956             for (var i = 0; i < obj.map_sdist[ 'aou_' + org_id ].length; i++) {
957                 obj.funcs.push(
958                     function(o,a) {
959                         return function() {
960                             obj.append_sdist(o,a);
961                         }
962                     }( org, obj.map_sdist[ 'aou_' + org_id ][i] )
963                 );
964             }
965         }
966         obj.funcs.push( function() { 
967             document.getElementById('cmd_refresh_list').setAttribute('disabled','false'); 
968             document.getElementById('sdist_lib_menu').setAttribute('disabled','false'); 
969         } );
970
971         // remove current editor
972         if (typeof twisty == 'undefined') {
973             document.getElementById('serial_manage_dists_editor_deck').selectedIndex = 0;
974         }
975     },
976
977     'append_org' : function (org,parent_org,params) {
978         var obj = this;
979         try {
980             if (obj.map_tree[ 'aou_' + org.id() ]) {
981                 var x = obj.map_tree[ 'aou_' + org.id() ];
982                 if (params) {
983                     for (var i in params) {
984                         x.setAttribute(i,params[i]);
985                     }
986                 }
987                 return x;
988             }
989
990             var data = {
991                 'row' : {
992                     'my' : {
993                         'aou' : org,
994                     }
995                 },
996                 'skip_all_columns_except' : [0,1,2],
997                 'retrieve_id' : 'aou_' + org.id(),
998                 'to_bottom' : true,
999                 'no_auto_select' : true,
1000             };
1001         
1002             var sdist_tree_list;
1003             if ( obj.org_ids.indexOf( Number( org.id() ) ) == -1 ) {
1004                 if ( get_bool( obj.data.hash.aout[ org.ou_type() ].can_have_vols() ) ) {
1005                     data.row.my.distribution_count = '0';
1006                 } else {
1007                     data.row.my.distribution_count = '';
1008                 }
1009             } else {
1010                 var d_count = 0;
1011                 sdist_tree_list = obj.network.simple_request(
1012                     'FM_SDIST_TREE_LIST_RETRIEVE_VIA_RECORD_ID_AND_ORG_IDS.authoritative',
1013                     [ ses(), obj.docid, [ org.id() ] ]
1014                 );
1015                 for (var i = 0; i < sdist_tree_list.length; i++) {
1016                     d_count++;
1017                     obj.map_sdist[ 'sdist_' + sdist_tree_list[i].id() ] = function(r){return r;}(sdist_tree_list[i]);
1018                     /*var streams = sdist_tree_list[i].streams();
1019                     for (var j = 0; j < streams.length; j++) {
1020                         obj.map_sstr[ 'sstr_' + streams[j].id() ] = function(r){return r;}(streams[j]);
1021                     }*/
1022                 }
1023                 data.row.my.distribution_count = d_count;
1024             }
1025             if (parent_org) {
1026                 data.node = obj.map_tree[ 'aou_' + parent_org.id() ];
1027             }
1028             var nparams = obj.list.append(data);
1029             var node = nparams.my_node;
1030             if (params) {
1031                 for (var i in params) {
1032                     node.setAttribute(i,params[i]);
1033                 }
1034             }
1035             obj.map_tree[ 'aou_' + org.id() ] = node;
1036
1037             if (org.children()) {
1038                 node.setAttribute('container','true');
1039             }
1040
1041             if (parent_org) {
1042                 if ( obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].parent_ou() == parent_org.id() ) {
1043                     data.node.setAttribute('open','true');
1044                 }
1045             } else {
1046                 obj.map_tree[ 'aou_' + org.id() ].setAttribute('open','true');
1047             }
1048
1049             if (sdist_tree_list) {
1050                 obj.map_sdist[ 'aou_' + org.id() ] = sdist_tree_list;
1051                 node.setAttribute('container','true');
1052             }
1053
1054             if (document.getElementById('show_sdists').checked) {
1055                 obj.funcs.push( function() { obj.on_click_aou( org.id() ); } );
1056                 node.setAttribute('open','true');
1057             }
1058
1059         } catch(E) {
1060             dump(E+'\n');
1061             alert(E);
1062         }
1063     },
1064
1065     'append_sdist' : function( org, sdist_tree, params ) {
1066         var obj = this;
1067         try {
1068             if (obj.map_tree[ 'sdist_' + sdist_tree.id() ]) {
1069                 var x = obj.map_tree[ 'sdist_' + sdist_tree.id() ];
1070                 if (params) {
1071                     for (var i in params) {
1072                         x.setAttribute(i,params[i]);
1073                     }
1074                 }
1075                 return x;
1076             }
1077
1078             var parent_node = obj.map_tree[ 'aou_' + org.id() ];
1079             var data = {
1080                 'row' : {
1081                     'my' : {
1082                         'aou' : org,
1083                         'sdist' : sdist_tree,
1084                         'distribution_count' : ''
1085                     }
1086                 },
1087                 'skip_all_columns_except' : [0,1,2],
1088                 'retrieve_id' : 'sdist_' + sdist_tree.id(),
1089                 'node' : parent_node,
1090                 'to_bottom' : true,
1091                 'no_auto_select' : true,
1092             };
1093             var nparams = obj.list.append(data);
1094             var node = nparams.my_node;
1095             obj.map_tree[ 'sdist_' + sdist_tree.id() ] =  node;
1096             if (params) {
1097                 for (var i in params) {
1098                     node.setAttribute(i,params[i]);
1099                 }
1100             }
1101             node.setAttribute('container','true');
1102             if (document.getElementById('show_groups').checked) {
1103                 node.setAttribute('open','true');
1104                 obj.funcs.push( function() { obj.on_select_sdist( sdist_tree.id(), true ); } );
1105             }
1106             var sstr_group_node_data = {
1107                 'row' : {
1108                     'my' : {
1109                         'label' : dojo.byId('serialStrings').getString('serial.manage_dists.streams'),
1110                     }
1111                 },
1112                 'retrieve_id' : 'sstr-group_' + sdist_tree.id(),
1113                 'node' : node,
1114                 'to_bottom' : true,
1115                 'no_auto_select' : true,
1116             };
1117             nparams = obj.list.append(sstr_group_node_data);
1118             obj.map_tree[ 'sdist_sstr_group_' + sdist_tree.id() ] =  nparams.my_node;
1119         } catch(E) {
1120             dump(E+'\n');
1121             alert(E);
1122         }
1123     },
1124
1125     'append_member' : function( item, sdist_tree, attributes, type, group, label ) {
1126         var obj = this;
1127         try {
1128             if (obj.map_tree[ type + '_' + sdist_tree.id() + '_' + item.id() ]) {
1129                 var x = obj.map_tree[ type + '_' + item.id() ];
1130                 if (attributes) {
1131                     for (var i in attributes) {
1132                         x.setAttribute(i,attributes[i]);
1133                     }
1134                 }
1135                 return x;
1136             }
1137
1138             var parent_node;
1139             if (group) {
1140                 parent_node = obj.map_tree[ 'sdist_' + type + '_group_' + sdist_tree.id() ];
1141             } else {
1142                 parent_node = obj.map_tree[ 'sdist_' + sdist_tree.id() ];
1143             }
1144             var data = {
1145                 'row' : {
1146                     'my' : {
1147                         'aou' : obj.data.hash.aou[ sdist_tree.holding_lib() ],
1148                         'sdist' : sdist_tree,
1149                         'distribution_count' : ''
1150                     }
1151                 },
1152                 'retrieve_id' : type + '_' + item.id(),
1153                 'node' : parent_node,
1154                 'to_bottom' : true,
1155                 'no_auto_select' : true,
1156             };
1157             data['row']['my'][type] = item; // TODO: future optimization: get only the IDs of these leaves, then fetch the full row in 'retrieve_row'
1158             var nparams = obj.list.append(data);
1159             var node = nparams.my_node;
1160             obj.map_tree[ type + '_' + sdist_tree.id() + '_' + item.id() ] =  node;
1161             if (label) {
1162                 data['row']['my']['label'] = label;
1163             }
1164             if (attributes) {
1165                 for (var i in attributes) {
1166                     node.setAttribute(i,attributes[i]);
1167                 }
1168             }
1169
1170         } catch(E) {
1171             dump(E+'\n');
1172             alert(E);
1173         }
1174     },
1175
1176     'list_init' : function( params ) {
1177
1178         try {
1179             netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
1180             var obj = this;
1181             
1182             JSAN.use('circ.util');
1183             var columns = [
1184                 {
1185                     'id' : 'tree_location',
1186                     'label' : 'Location',
1187                     'flex' : 1, 'primary' : true, 'hidden' : false, 
1188                     'render' : function(my) { 
1189                         if (my.label) { return my.label; }
1190                         if (my.sstr) { return $('serialStrings').getFormattedString('serial.manage_dists.stream_num', [my.sstr.id()]); }
1191                         if (my.sbsum) { return $('serialStrings').getString('serial.manage_dists.sbsum'); }
1192                         if (my.sssum) { return $('serialStrings').getString('serial.manage_dists.sssum'); }
1193                         if (my.sisum) { return $('serialStrings').getString('serial.manage_dists.sisum'); }
1194                         if (my.sdist) { return my.sdist.label(); }
1195                         if (my.aou) { return $('serialStrings').getFormattedString('serial.manage_dists.stream_num', [my.aou.shortname(), my.aou.name()]); }
1196                         return "???";
1197                     },
1198                 },
1199                 {
1200                     'id' : 'distribution_count',
1201                     'label' : $('serialStrings').getString('serial.manage_dists.distributions'),
1202                     'flex' : 0, 'primary' : false, 'hidden' : false, 
1203                     'render' : function(my) { return my.distribution_count; },
1204                 }
1205             ];
1206             JSAN.use('util.list'); obj.list = new util.list('sdists_tree');
1207             obj.list.init(
1208                 {
1209                     'no_auto_select' : true,
1210                     'columns' : columns,
1211                     'map_row_to_columns' : circ.util.std_map_row_to_columns(' '),
1212                     'retrieve_row' : function(params) {
1213
1214                         var row = params.row;
1215                         obj.funcs.push(
1216                             function() {
1217
1218                                 if (typeof params.on_retrieve == 'function') {
1219                                     params.on_retrieve(row);
1220                                 }
1221
1222                             }
1223                         );
1224
1225                         return row;
1226                     },
1227                     'on_click' : function(ev) {
1228                         netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserRead');
1229                         var row = {}; var col = {}; var nobj = {};
1230                         obj.list.node.treeBoxObject.getCellAt(ev.clientX,ev.clientY,row,col,nobj); 
1231                         if ((row.value == -1)||(nobj.value != 'twisty')) { return; } // on_click runs for twistys only
1232
1233                         var node = obj.list.node.contentView.getItemAtIndex(row.value);
1234                         var list = [ node.getAttribute('retrieve_id') ];
1235                         if (typeof obj.on_select == 'function') {
1236                             obj.on_select(list,true);
1237                         }
1238                         if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
1239                             window.xulG.on_select(list);
1240                         }
1241                     },
1242                     'on_select' : function(ev) {
1243                         JSAN.use('util.functional');
1244                         
1245                         // get the actual node clicked to determine which editor to use
1246                         if (obj.list.node.view.selection.currentIndex > -1) {
1247                             var node = obj.list.node.contentView.getItemAtIndex(obj.list.node.view.selection.currentIndex);
1248                             obj.focused_node_retrieve_id = node.getAttribute('retrieve_id');
1249                         }
1250
1251                         var sel = obj.list.retrieve_selection();
1252                         obj.controller.view.sel_clip.disabled = sel.length < 1;
1253                         obj.sel_list = util.functional.map_list(
1254                             sel,
1255                             function(o) { return o.getAttribute('retrieve_id'); }
1256                         );
1257                         obj.toggle_actions();
1258                         if (typeof obj.on_select == 'function') {
1259                             obj.on_select(obj.sel_list);
1260                         }
1261                         if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
1262                             window.xulG.on_select(obj.sel_list);
1263                         }
1264                     },
1265                 }
1266             );
1267
1268             obj.controller.render();
1269
1270         } catch(E) {
1271             this.error.sdump('D_ERROR','serial/manage_dists.list_init: ' + E + '\n');
1272             alert(E);
1273         }
1274     },
1275
1276     'toggle_actions' : function() {
1277         var obj = this;
1278         try {
1279             var found_aou = false; var found_sdist = false; var found_sstr = false; var found_sbsum = false; var found_sssum = false; var found_sisum = false; var found_sstr_group = false;
1280             for (var i = 0; i < obj.sel_list.length; i++) {
1281                 var type = obj.sel_list[i].split(/_/)[0];
1282                 switch(type) {
1283                     case 'aou' : 
1284                         found_aou = true; 
1285                     break;
1286                     case 'sdist' : found_sdist = true; break;
1287                     case 'sstr' : found_sstr = true; break;
1288                     case 'sbsum' : found_sbsum = true; break;
1289                     case 'sssum' : found_sssum = true; break;
1290                     case 'sisum' : found_sisum = true; break;
1291                     case 'sstr-group' : found_sstr_group = true; break;
1292                 }
1293             }
1294             obj.controller.view.cmd_add_sstr.setAttribute('disabled','true');
1295             obj.controller.view.cmd_delete_sstr.setAttribute('disabled','true');
1296             obj.controller.view.cmd_mark_library.setAttribute('disabled','true');
1297             obj.controller.view.cmd_delete_sdist.setAttribute('disabled','true');
1298             if (found_aou) {
1299                 obj.controller.view.cmd_mark_library.setAttribute('disabled','false');
1300             }
1301             if (found_sdist) {
1302                 obj.controller.view.cmd_delete_sdist.setAttribute('disabled','false');
1303                 obj.controller.view.cmd_add_sstr.setAttribute('disabled','false');
1304             }
1305             if (found_sstr_group) {
1306                 obj.controller.view.cmd_add_sstr.setAttribute('disabled','false');
1307             }
1308             if (found_sstr) {
1309                 obj.controller.view.cmd_delete_sstr.setAttribute('disabled','false');
1310                 obj.controller.view.cmd_transfer_sstrs.setAttribute('disabled','false');
1311             }
1312             if (found_sbsum) {
1313             }
1314             if (found_sssum) {
1315             }
1316             if (found_sisum) {
1317             }
1318         } catch(E) {
1319             obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.actions.error'),E);
1320         }
1321     },
1322
1323     'refresh_list' : function() { 
1324         try {
1325             var obj = this;
1326             obj.list.clear();
1327             obj.map_tree = {};
1328             obj.map_sdist = {};
1329             //obj.map_sstr = {};
1330             obj.org_ids = obj.network.simple_request('FM_SDIST_AOU_IDS_RETRIEVE_VIA_RECORD_ID.authoritative',[ obj.docid ]);
1331             if (typeof obj.org_ids.ilsevent != 'undefined') throw(obj.org_ids);
1332             JSAN.use('util.functional'); 
1333             obj.org_ids = util.functional.map_list( obj.org_ids, function (o) { return Number(o); });
1334             /*
1335             var org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
1336             obj.show_libs( org );
1337             */
1338             obj.default_lib = document.getElementById('sdist_lib_menu').value;
1339             obj.show_my_libs( obj.default_lib );
1340         } catch(E) {
1341             this.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.refresh_list.error'),E);
1342         }
1343     },
1344 };
1345
1346 dump('exiting serial/manage_dists.js\n');