[open-ils-commits] r12690 - in branches/rel_1_4/Open-ILS/xul/staff_client: chrome/content/util server/cat (dbs)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Mar 26 13:42:49 EDT 2009
Author: dbs
Date: 2009-03-26 13:42:46 -0400 (Thu, 26 Mar 2009)
New Revision: 12690
Modified:
branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/util/exec.js
branches/rel_1_4/Open-ILS/xul/staff_client/server/cat/copy_browser.js
branches/rel_1_4/Open-ILS/xul/staff_client/server/cat/copy_browser.xul
Log:
Backport r12482 from trunk: phasefx fix for staff client holdings maintenance defaulting to the correct org_unit in a deep hierarchy
Modified: branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/util/exec.js
===================================================================
--- branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/util/exec.js 2009-03-26 17:25:22 UTC (rev 12689)
+++ branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/util/exec.js 2009-03-26 17:42:46 UTC (rev 12690)
@@ -10,6 +10,20 @@
};
util.exec.prototype = {
+ // This will create a timer that polls the specified array and shifts off functions to execute
+ 'timer' : function(funcs,interval) {
+ var obj = this;
+ var intervalId = window.setInterval(
+ function() {
+ var i = obj.chunk_size;
+ while (funcs.length > 0 && i > 0) {
+ funcs.shift()();
+ }
+ },
+ interval
+ );
+ window.addEventListener('unload',function() { window.clearInterval(intervalId); },false);
+ },
// This executes a series of functions, but tries to give other events/functions a chance to
// execute between each one.
'chain' : function () {
Modified: branches/rel_1_4/Open-ILS/xul/staff_client/server/cat/copy_browser.js
===================================================================
--- branches/rel_1_4/Open-ILS/xul/staff_client/server/cat/copy_browser.js 2009-03-26 17:25:22 UTC (rev 12689)
+++ branches/rel_1_4/Open-ILS/xul/staff_client/server/cat/copy_browser.js 2009-03-26 17:42:46 UTC (rev 12690)
@@ -17,6 +17,7 @@
'map_acn' : {},
'map_acp' : {},
'sel_list' : [],
+ 'funcs' : [],
'init' : function( params ) {
@@ -963,6 +964,8 @@
obj.show_my_libs( ml.value );
+ JSAN.use('util.exec'); var exec = new util.exec(20); exec.timer(obj.funcs,100);
+
obj.show_consortial_count();
} catch(E) {
@@ -1001,15 +1004,13 @@
var p_org = obj.data.hash.aou[ org.parent_ou() ];
if (p_org) {
- JSAN.use('util.exec'); var exec = new util.exec();
- var funcs = [];
- funcs.push( function() {
+ obj.funcs.push( function() {
document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
document.getElementById('lib_menu').setAttribute('disabled','true');
} );
for (var i = 0; i < p_org.children().length; i++) {
- funcs.push(
+ obj.funcs.push(
function(o) {
return function() {
obj.show_libs( o, false );
@@ -1017,12 +1018,11 @@
}( p_org.children()[i] )
);
}
- funcs.push( function() {
+ obj.funcs.push( function() {
document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
document.getElementById('lib_menu').setAttribute('disabled','false');
} );
- exec.chain( funcs );
}
} catch(E) {
alert(E);
@@ -1036,16 +1036,14 @@
obj.show_libs( obj.data.tree.aou );
- JSAN.use('util.exec'); var exec = new util.exec();
- var funcs = [];
- funcs.push( function() {
+ obj.funcs.push( function() {
document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
document.getElementById('lib_menu').setAttribute('disabled','true');
} );
for (var i = 0; i < obj.data.tree.aou.children().length; i++) {
- funcs.push(
+ obj.funcs.push(
function(o) {
return function() {
obj.show_libs( o );
@@ -1053,13 +1051,12 @@
}( obj.data.tree.aou.children()[i] )
);
}
- funcs.push( function() {
+ obj.funcs.push( function() {
document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
document.getElementById('lib_menu').setAttribute('disabled','false');
} );
- exec.chain( funcs );
} catch(E) {
alert(E);
}
@@ -1068,7 +1065,6 @@
'show_libs_with_copies' : function() {
var obj = this;
try {
- JSAN.use('util.exec'); var exec = new util.exec();
JSAN.use('util.functional');
var orgs = util.functional.map_list(
@@ -1081,15 +1077,14 @@
return 0;
}
);
- var funcs = [];
- funcs.push( function() {
+ obj.funcs.push( function() {
document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
document.getElementById('lib_menu').setAttribute('disabled','true');
} );
for (var i = 0; i < orgs.length; i++) {
- funcs.push(
+ obj.funcs.push(
function(o) {
return function() {
obj.show_libs(o,false);
@@ -1097,13 +1092,12 @@
}( orgs[i] )
);
}
- funcs.push( function() {
+ obj.funcs.push( function() {
document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
document.getElementById('lib_menu').setAttribute('disabled','false');
} );
- exec.chain( funcs );
} catch(E) {
alert(E);
}
@@ -1114,10 +1108,8 @@
try {
if (!start_aou) throw('show_libs: Need a start_aou');
JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
- JSAN.use('util.functional'); JSAN.use('util.exec'); var exec = new util.exec();
+ JSAN.use('util.functional');
- var funcs = [];
-
var parents = [];
var temp_aou = start_aou;
while ( temp_aou.parent_ou() ) {
@@ -1127,33 +1119,29 @@
parents.reverse();
for (var i = 0; i < parents.length; i++) {
- funcs.push(
+ obj.funcs.push(
function(o,p) {
return function() {
- if (show_open) {
- obj.append_org(o,p,{'container':'true','open':'true'});
- } else {
- obj.append_org(o,p,{'container':'true'});
- }
+ obj.append_org(o,p,{'container':'true','open':'true'});
};
}(parents[i], obj.data.hash.aou[ parents[i].parent_ou() ])
);
}
- funcs.push(
+ obj.funcs.push(
function(o,p) {
return function() { obj.append_org(o,p); };
}(start_aou,obj.data.hash.aou[ start_aou.parent_ou() ])
);
- funcs.push(
+ obj.funcs.push(
function() {
if (start_aou.children()) {
var x = obj.map_tree[ 'aou_' + start_aou.id() ];
x.setAttribute('container','true');
if (show_open) x.setAttribute('open','true');
for (var i = 0; i < start_aou.children().length; i++) {
- funcs.push(
+ obj.funcs.push(
function(o,p) {
return function() { obj.append_org(o,p); };
}( start_aou.children()[i], start_aou )
@@ -1163,8 +1151,6 @@
}
);
- exec.chain( funcs );
-
} catch(E) {
alert(E);
}
@@ -1189,15 +1175,14 @@
var obj = this;
try {
var acn_tree = obj.map_acp[ 'acn_' + acn_id ];
- var funcs = [];
- funcs.push( function() {
+ obj.funcs.push( function() {
document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
document.getElementById('lib_menu').setAttribute('disabled','true');
} );
if (acn_tree.copies()) {
for (var i = 0; i < acn_tree.copies().length; i++) {
- funcs.push(
+ obj.funcs.push(
function(c,a) {
return function() {
obj.append_acp(c,a);
@@ -1206,13 +1191,11 @@
)
}
}
- funcs.push( function() {
+ obj.funcs.push( function() {
document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
document.getElementById('lib_menu').setAttribute('disabled','false');
} );
- JSAN.use('util.exec'); var exec = new util.exec();
- exec.chain( funcs );
} catch(E) {
alert(E);
}
@@ -1222,15 +1205,14 @@
var obj = this;
var org = obj.data.hash.aou[ org_id ];
if (obj.data.hash.aout[ org.ou_type() ].depth() == 0 && ! get_bool( obj.data.hash.aout[ org.ou_type() ].can_have_vols() ) ) return;
- var funcs = [];
- funcs.push( function() {
+ obj.funcs.push( function() {
document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
document.getElementById('lib_menu').setAttribute('disabled','true');
} );
if (org.children()) {
for (var i = 0; i < org.children().length; i++) {
- funcs.push(
+ obj.funcs.push(
function(o,p) {
return function() {
obj.append_org(o,p)
@@ -1241,7 +1223,7 @@
}
if (obj.map_acn[ 'aou_' + org_id ]) {
for (var i = 0; i < obj.map_acn[ 'aou_' + org_id ].length; i++) {
- funcs.push(
+ obj.funcs.push(
function(o,a) {
return function() {
obj.append_acn(o,a);
@@ -1250,13 +1232,11 @@
);
}
}
- funcs.push( function() {
+ obj.funcs.push( function() {
document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
document.getElementById('lib_menu').setAttribute('disabled','false');
} );
- JSAN.use('util.exec'); var exec = new util.exec();
- exec.chain( funcs );
},
'append_org' : function (org,parent_org,params) {
@@ -1342,7 +1322,7 @@
if (document.getElementById('show_acns').checked) {
if (! ( obj.data.hash.aout[ org.ou_type() ].depth() == 0 && ! get_bool( obj.data.hash.aout[ org.ou_type() ].can_have_vols() ) )) {
node.setAttribute('open','true');
- setTimeout( function() { obj.on_select_org( org.id() ); }, 0 );
+ obj.funcs.push( function() { obj.on_select_org( org.id() ); } );
}
}
@@ -1395,7 +1375,7 @@
}
if (document.getElementById('show_acps').checked) {
node.setAttribute('open','true');
- setTimeout( function() { obj.on_select_acn( acn_tree.id() ); }, 0 );
+ obj.funcs.push( function() { obj.on_select_acn( acn_tree.id() ); } );
}
} catch(E) {
@@ -1522,9 +1502,8 @@
var row = params.row;
- var funcs = [];
/*
- if (!row.my.mvr) funcs.push(
+ if (!row.my.mvr) obj.funcs.push(
function() {
row.my.mvr = obj.network.request(
@@ -1536,7 +1515,7 @@
}
);
if (!row.my.acp) {
- funcs.push(
+ obj.funcs.push(
function() {
row.my.acp = obj.network.request(
@@ -1553,7 +1532,7 @@
params.row_node.setAttribute( 'retrieve_id',row.my.acp.barcode() );
}
*/
- funcs.push(
+ obj.funcs.push(
function() {
if (typeof params.on_retrieve == 'function') {
@@ -1563,14 +1542,6 @@
}
);
- JSAN.use('util.exec'); var exec = new util.exec();
- exec.on_error = function(E) {
- var err = 'items chain: ' + js2JSON(E);
- obj.error.sdump('D_ERROR',err);
- return true; /* keep going */
- }
- exec.chain( funcs );
-
return row;
},
'on_click' : function(ev) {
Modified: branches/rel_1_4/Open-ILS/xul/staff_client/server/cat/copy_browser.xul
===================================================================
--- branches/rel_1_4/Open-ILS/xul/staff_client/server/cat/copy_browser.xul 2009-03-26 17:25:22 UTC (rev 12689)
+++ branches/rel_1_4/Open-ILS/xul/staff_client/server/cat/copy_browser.xul 2009-03-26 17:42:46 UTC (rev 12690)
@@ -34,6 +34,7 @@
<scripts id="openils_util_scripts"/>
<script type="text/javascript" src="/xul/server/main/JSAN.js"/>
+ <script type="text/javascript" src="/xul/server/cat/copy_browser.js"/>
<script>
<![CDATA[
function my_init() {
More information about the open-ils-commits
mailing list