From 1a8a39642cf589d089507af5fcd3b4048111fb81 Mon Sep 17 00:00:00 2001 From: phasefx Date: Sun, 26 Aug 2007 05:33:11 +0000 Subject: [PATCH] Bug fix for list class, where refresh-row functionality broke the on_all_fleshed callback handler. Since rows in a list can flesh themselves out asynchonously, and some actions want to act on all rows in a list, we have a function that asks the whole list to flesh itself (because unseen rows normally don't), and a way to pass a callback function for when the list has been completely fleshed. Internally, it keeps a count of total rows and total fleshed rows, and if the two are equal, then the list is considered fleshed. However, the recent refresh-a-single-row functionality was effectively increasing the total fleshed rows tally without first adjusting it, and you would get fleshed rows > total rows, and the callback would never fire. So this fixes all of that. git-svn-id: svn://svn.open-ils.org/ILS/trunk@7717 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/xul/staff_client/chrome/content/util/list.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 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 4271a41bd3..42106be912 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/list.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/list.js @@ -327,6 +327,7 @@ util.list.prototype = { rparams.my_node.setAttribute(i,params.attributes[i]); } } + this.row_count.fleshed--; return rparams; }, @@ -410,7 +411,7 @@ util.list.prototype = { if (treerow.getAttribute('fleshed') == 'true') return; /* already fleshed */ treerow.setAttribute('fleshed','true'); obj.row_count.fleshed++; - if (obj.row_count.fleshed == obj.row_count.total) { + if (obj.row_count.fleshed >= obj.row_count.total) { if (typeof obj.on_all_fleshed == 'function') { setTimeout( function() { obj.on_all_fleshed(); }, 0 ); } @@ -468,7 +469,7 @@ util.list.prototype = { treerow.setAttribute('retrieved','true'); treerow.setAttribute('fleshed','true'); obj.row_count.fleshed++; - if (obj.row_count.fleshed == obj.row_count.total) { + if (obj.row_count.fleshed >= obj.row_count.total) { if (typeof obj.on_all_fleshed == 'function') { setTimeout( function() { obj.on_all_fleshed(); }, 0 ); } @@ -560,7 +561,7 @@ util.list.prototype = { if (treerow.getAttribute('fleshed') == 'true') return; /* already fleshed */ treerow.setAttribute('fleshed','true'); obj.row_count.fleshed++; - if (obj.row_count.fleshed == obj.row_count.total) { + if (obj.row_count.fleshed >= obj.row_count.total) { if (typeof obj.on_all_fleshed == 'function') { setTimeout( function() { obj.on_all_fleshed(); }, 0 ); } @@ -618,7 +619,7 @@ util.list.prototype = { treerow.setAttribute('retrieved','true'); treerow.setAttribute('fleshed','true'); obj.row_count.fleshed++; - if (obj.row_count.fleshed == obj.row_count.total) { + if (obj.row_count.fleshed >= obj.row_count.total) { if (typeof obj.on_all_fleshed == 'function') { setTimeout( function() { obj.on_all_fleshed(); }, 0 ); } @@ -765,15 +766,15 @@ util.list.prototype = { '_full_retrieve_tree' : function(params) { var obj = this; try { - if (obj.row_count.total == obj.row_count.fleshed) { - //alert('Full retrieve... tree seems to be in sync\n' + js2JSON(obj.row_count)); + 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 { - alert('.full_retrieve called with no callback?'); + dump('.full_retrieve called with no callback?' + '\n'); } } else { - //alert('Full retrieve... syncing tree' + js2JSON(obj.row_count)); + dump('Full retrieve... syncing tree' + js2JSON(obj.row_count) + '\n'); JSAN.use('util.widgets'); var nodes = obj.treechildren.childNodes; for (var i = 0; i < nodes.length; i++) { -- 2.11.0