From b95db4cb62d6cef54a99e92cf4187b2938b8cbb4 Mon Sep 17 00:00:00 2001 From: phasefx Date: Thu, 13 Dec 2007 17:39:51 +0000 Subject: [PATCH] changed on_retrieve callback for list.full_retrieve so that it can handle an array of callbacks. dump_csv_to_clipboard function for refactoring elsewhere git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_2@8211 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../xul/staff_client/chrome/content/util/list.js | 39 ++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/util/list.js b/Open-ILS/xul/staff_client/chrome/content/util/list.js index 41bc97a972..d20c46cdb6 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/list.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/list.js @@ -771,8 +771,24 @@ util.list.prototype = { if (obj.row_count.fleshed >= obj.row_count.total) { dump('Full retrieve... tree seems to be in sync\n' + js2JSON(obj.row_count) + '\n'); if (typeof obj.on_all_fleshed == 'function') { - setTimeout( function() { obj.on_all_fleshed(); }, 0 ); - } else { + setTimeout( + function() { + try { obj.on_all_fleshed(); } catch(E) { obj.error.standard_unexpected_error_alert('_full_retrieve_tree callback',obj.on_all_fleshed); } + }, 0 + ); + } else if (typeof obj.on_all_fleshed.length != 'undefined') { + setTimeout( + function() { + var f = obj.on_all_fleshed.pop(); + if (typeof f == 'function') { + try { f(); } catch(E) { obj.error.standard_unexpected_error_alert('_full_retrieve_tree callback',f); } + } else { + obj.error.standard_unexpected_error_alert('_full_retrieve_tree callback: expected a function',f); + } + if (obj.on_all_fleshed.length > 0) arguments.callee(); + }, 0 + ); + } else { dump('.full_retrieve called with no callback?' + '\n'); } } else { @@ -1055,6 +1071,15 @@ util.list.prototype = { return dump; }, + 'dump_csv_to_clipboard' : function(params) { + var obj = this; + if (params && params.no_full_retrieve) { + copy_to_clipboard( obj.dump_csv( params ) ); + } else { + obj.wrap_in_full_retrieve( function() { copy_to_clipboard( obj.dump_csv( params ) ); } ); + } + }, + 'dump_selected_with_keys' : function(params) { var obj = this; switch(this.node.nodeName) { @@ -1114,6 +1139,16 @@ util.list.prototype = { return dump; }, + 'wrap_in_full_retrieve' : function(f) { + var obj = this; + if (typeof obj.on_all_fleshed == 'function') { // legacy + obj.on_all_fleshed = [ obj.on_all_fleshed ]; + } + if (! obj.on_all_fleshed) obj.on_all_fleshed = []; + obj.on_all_fleshed.push(f); + obj.full_retrieve(); + }, + '_sort_tree' : function(col,sortDir) { var obj = this; try { -- 2.11.0