1 dump('entering cat.copy_browser.js\n');
3 if (typeof cat == 'undefined') cat = {};
4 cat.copy_browser = function (params) {
6 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
7 JSAN.use('util.error'); this.error = new util.error();
10 dump('cat.copy_browser: ' + E + '\n');
14 cat.copy_browser.prototype = {
20 'init' : function( params ) {
23 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
26 JSAN.use('util.network'); obj.network = new util.network();
27 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
28 JSAN.use('util.controller'); obj.controller = new util.controller();
34 function() { alert('Not Yet Implemented'); }
36 'cmd_show_my_libs' : [
42 'cmd_show_all_libs' : [
48 'cmd_show_libs_with_copies' : [
51 obj.show_libs_with_copies();
65 obj.list_init(params);
67 obj.org_ids = obj.network.simple_request('FM_AOU_IDS_RETRIEVE_VIA_RECORD_ID',[ obj.docid ]);
69 var org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
73 this.error.sdump('D_ERROR','cat.copy_browser.init: ' + E + '\n');
77 'show_my_libs' : function() {
80 var org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
83 var p_org = obj.data.hash.aou[ org.parent_ou() ];
85 JSAN.use('util.exec'); var exec = new util.exec();
87 for (var i = 0; i < p_org.children().length; i++) {
93 }( p_org.children()[i] )
103 'show_all_libs' : function() {
106 obj.show_libs( obj.data.tree.aou );
108 JSAN.use('util.exec'); var exec = new util.exec();
110 for (var i = 0; i < obj.data.tree.aou.children().length; i++) {
116 }( obj.data.tree.aou.children()[i] )
125 'show_libs_with_copies' : function() {
128 JSAN.use('util.exec'); var exec = new util.exec();
129 JSAN.use('util.functional');
131 var orgs = util.functional.map_list(
133 function(id) { return obj.data.hash.aou[id]; }
136 if (a.shortname() < b.shortname()) return -1;
137 if (a.shortname() > b.shortname()) return 1;
142 for (var i = 0; i < orgs.length; i++) {
157 'show_libs' : function(start_aou) {
160 if (!start_aou) throw('show_libs: Need a start_aou');
161 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
162 JSAN.use('util.functional'); JSAN.use('util.exec'); var exec = new util.exec();
167 var temp_aou = start_aou;
168 while ( temp_aou.parent_ou() ) {
169 temp_aou = obj.data.hash.aou[ temp_aou.parent_ou() ];
170 parents.push( temp_aou );
174 for (var i = 0; i < parents.length; i++) {
178 obj.append_org(o,p,{'container':'true'});
180 }(parents[i], obj.data.hash.aou[ parents[i].parent_ou() ])
186 return function() { obj.append_org(o,p); };
187 }(start_aou,obj.data.hash.aou[ start_aou.parent_ou() ])
192 if (start_aou.children()) {
193 var x = obj.map_tree[ 'aou_' + start_aou.id() ];
194 x.setAttribute('container','true');
195 //x.setAttribute('open','true');
196 for (var i = 0; i < start_aou.children().length; i++) {
199 return function() { obj.append_org(o,p); };
200 }( start_aou.children()[i], start_aou )
214 'on_select' : function(list) {
216 for (var i = 0; i < list.length; i++) {
217 var node = obj.map_tree[ list[i] ];
218 //if (node.lastChild.nodeName == 'treechildren') { continue; } else { alert(node.lastChild.nodeName); }
219 var row_type = list[i].split('_')[0];
220 var id = list[i].split('_')[1];
222 case 'aou' : obj.on_select_org(id); break;
223 case 'acn' : obj.on_select_acn(id); break;
229 'on_select_acn' : function(acn_id) {
232 var acn_tree = obj.map_acp[ 'acn_' + acn_id ];
234 if (acn_tree.copies()) {
235 for (var i = 0; i < acn_tree.copies().length; i++) {
241 }( acn_tree.copies()[i], acn_tree )
245 JSAN.use('util.exec'); var exec = new util.exec();
252 'on_select_org' : function(org_id) {
254 var org = obj.data.hash.aou[ org_id ];
256 if (org.children()) {
257 for (var i = 0; i < org.children().length; i++) {
263 }(org.children()[i],org)
267 if (obj.map_acn[ 'aou_' + org_id ]) {
268 for (var i = 0; i < obj.map_acn[ 'aou_' + org_id ].length; i++) {
274 }( org, obj.map_acn[ 'aou_' + org_id ][i] )
278 JSAN.use('util.exec'); var exec = new util.exec();
282 'append_org' : function (org,parent_org,params) {
285 if (obj.map_tree[ 'aou_' + org.id() ]) {
286 var x = obj.map_tree[ 'aou_' + org.id() ];
288 for (var i in params) {
289 x.setAttribute(i,params[i]);
301 'skip_all_columns_except' : [0,1,2],
302 'retrieve_id' : 'aou_' + org.id(),
306 if ( obj.org_ids.indexOf( org.id() ) == -1 ) {
307 if ( obj.data.hash.aout[ org.ou_type() ].can_have_vols() ) {
308 data.row.my.volume_count = '0';
309 data.row.my.copy_count = '<0>';
311 data.row.my.volume_count = '';
312 data.row.my.copy_count = '';
315 var v_count = 0; var c_count = 0;
316 acn_tree_list = obj.network.simple_request(
317 'FM_ACN_TREE_LIST_RETRIEVE_VIA_RECORD_ID_AND_ORG_IDS',
318 [ obj.data.session, obj.docid, [ org.id() ] ]
320 for (var i = 0; i < acn_tree_list.length; i++) {
322 if (acn_tree_list[i].copies()) c_count += acn_tree_list[i].copies().length;
324 data.row.my.volume_count = v_count;
325 data.row.my.copy_count = '<' + c_count + '>';
328 data.node = obj.map_tree[ 'aou_' + parent_org.id() ];
331 var node = obj.list.append(data);
333 for (var i in params) {
334 node.setAttribute(i,params[i]);
337 obj.map_tree[ 'aou_' + org.id() ] = node;
339 if (org.children()) {
340 node.setAttribute('container','true');
344 if ( obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].parent_ou() == parent_org.id() ) {
345 data.node.setAttribute('open','true');
348 obj.map_tree[ 'aou_' + org.id() ].setAttribute('open','true');
352 obj.map_acn[ 'aou_' + org.id() ] = acn_tree_list;
353 node.setAttribute('container','true');
362 'append_acn' : function( org, acn_tree, params ) {
365 if (obj.map_tree[ 'acn_' + acn_tree.id() ]) {
366 var x = obj.map_tree[ 'acn_' + acn_tree.id() ];
368 for (var i in params) {
369 x.setAttribute(i,params[i]);
375 var parent_node = obj.map_tree[ 'aou_' + org.id() ];
382 'copy_count' : acn_tree.copies() ? acn_tree.copies().length : '0',
385 'skip_all_columns_except' : [0,1,2],
386 'retrieve_id' : 'acn_' + acn_tree.id(),
387 'node' : parent_node,
389 var node = obj.list.append(data);
390 obj.map_tree[ 'acn_' + acn_tree.id() ] = node;
392 for (var i in params) {
393 node.setAttribute(i,params[i]);
396 if (acn_tree.copies()) {
397 obj.map_acp[ 'acn_' + acn_tree.id() ] = acn_tree;
398 node.setAttribute('container','true');
407 'append_acp' : function( acp_item, acn_tree, params ) {
410 if (obj.map_tree[ 'acp_' + acp_item.id() ]) {
411 var x = obj.map_tree[ 'acp_' + acp_item.id() ];
413 for (var i in params) {
414 x.setAttribute(i,params[i]);
420 var parent_node = obj.map_tree[ 'acn_' + acn_tree.id() ];
424 'aou' : obj.data.hash.aou[ acn_tree.owning_lib() ],
431 'retrieve_id' : 'acp_' + acp_item.id(),
432 'node' : parent_node,
434 var node = obj.list.append(data);
435 obj.map_tree[ 'acp_' + acp_item.id() ] = node;
437 for (var i in params) {
438 node.setAttribute(i,params[i]);
448 'list_init' : function( params ) {
451 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
454 JSAN.use('circ.util');
457 'id' : 'tree_location', 'label' : 'Location/Barcode', 'flex' : 1,
458 'primary' : true, 'hidden' : false,
459 'render' : 'my.acp ? my.acp.barcode() : my.acn ? my.acn.label() : my.aou ? my.aou.shortname() + " : " + my.aou.name() : "???"'
462 'id' : 'volume_count', 'label' : 'Volumes', 'flex' : 0,
463 'primary' : false, 'hidden' : false,
464 'render' : 'my.volume_count'
467 'id' : 'copy_count', 'label' : 'Copies', 'flex' : 0,
468 'primary' : false, 'hidden' : false,
469 'render' : 'my.copy_count'
474 'barcode' : { 'hidden' : false },
475 'location' : { 'hidden' : false },
476 'circ_lib' : { 'hidden' : false },
477 'owning_lib' : { 'hidden' : false },
478 'call_number' : { 'hidden' : false },
506 JSAN.use('util.list'); obj.list = new util.list('copy_tree');
510 'map_row_to_column' : circ.util.std_map_row_to_column(' '),
511 'retrieve_row' : function(params) {
513 var row = params.row;
517 if (!row.my.mvr) funcs.push(
520 row.my.mvr = obj.network.request(
521 api.MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.app,
522 api.MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.method,
523 [ row.my.circ.target_copy() ]
532 row.my.acp = obj.network.request(
533 api.FM_ACP_RETRIEVE.app,
534 api.FM_ACP_RETRIEVE.method,
535 [ row.my.circ.target_copy() ]
538 params.row_node.setAttribute( 'retrieve_id',row.my.acp.barcode() );
543 params.row_node.setAttribute( 'retrieve_id',row.my.acp.barcode() );
549 if (typeof params.on_retrieve == 'function') {
550 params.on_retrieve(row);
556 JSAN.use('util.exec'); var exec = new util.exec();
557 exec.on_error = function(E) {
558 //var err = 'items chain: ' + js2JSON(E);
559 //obj.error.sdump('D_ERROR',err);
560 return true; /* keep going */
566 'on_click' : function(ev) {
567 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserRead');
568 var row = {}; var col = {}; var nobj = {};
569 obj.list.node.treeBoxObject.getCellAt(ev.clientX,ev.clientY,row,col,nobj);
570 if ((row.value == -1)||(nobj.value != 'twisty')) { return; }
571 var node = obj.list.node.contentView.getItemAtIndex(row.value);
572 var list = [ node.getAttribute('retrieve_id') ];
573 if (typeof obj.on_select == 'function') {
576 if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
577 window.xulG.on_select(list);
580 'on_select' : function(ev) {
581 JSAN.use('util.functional');
582 var sel = obj.list.retrieve_selection();
583 var list = util.functional.map_list(
585 function(o) { return o.getAttribute('retrieve_id'); }
587 if (typeof obj.on_select == 'function') {
590 if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
591 window.xulG.on_select(list);
599 this.error.sdump('D_ERROR','cat.copy_browser.list_init: ' + E + '\n');
605 dump('exiting cat.copy_browser.js\n');