[open-ils-commits] r16687 - trunk/Open-ILS/xul/staff_client/chrome/content/util (phasefx)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Jun 11 16:32:49 EDT 2010
Author: phasefx
Date: 2010-06-11 16:32:43 -0400 (Fri, 11 Jun 2010)
New Revision: 16687
Modified:
trunk/Open-ILS/xul/staff_client/chrome/content/util/list.js
Log:
troubleshooting DOM issue where too many columns in a treerow
some refactoring and comment cleanup. toward having the need for treecell creation be determined on a column by column basis rather than examining the contents of a treerow in one go
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/util/list.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/util/list.js 2010-06-11 18:39:13 UTC (rev 16686)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/util/list.js 2010-06-11 20:32:43 UTC (rev 16687)
@@ -461,9 +461,9 @@
s += ('tree = ' + this.node + ' treechildren = ' + treechildren_node + '\n');
s += ('treeitem = ' + treeitem + ' treerow = ' + treerow + '\n');
+ obj.put_retrieving_label(treerow);
+
if (typeof params.retrieve_row == 'function' || typeof this.retrieve_row == 'function') {
-
- obj.put_retrieving_label(treerow);
treerow.addEventListener(
'flesh',
function() {
@@ -527,7 +527,6 @@
}
}
} else {
- obj.put_retrieving_label(treerow);
treerow.addEventListener(
'flesh',
function() {
@@ -619,11 +618,12 @@
s += ('tree = ' + this.node.nodeName + '\n');
s += ('treeitem = ' + treeitem.nodeName + ' treerow = ' + treerow.nodeName + '\n');
+ obj.put_retrieving_label(treerow);
+
if (typeof params.retrieve_row == 'function' || typeof this.retrieve_row == 'function') {
s += 'found a retrieve_row function\n';
- obj.put_retrieving_label(treerow);
treerow.addEventListener(
'flesh',
function() {
@@ -691,7 +691,6 @@
s += 'did not find a retrieve_row function\n';
- obj.put_retrieving_label(treerow);
treerow.addEventListener(
'flesh',
function() {
@@ -745,29 +744,16 @@
'put_retrieving_label' : function(treerow) {
var obj = this;
try {
- /*
- var cols_idx = 0;
- dump('put_retrieving_label. columns = ' + js2JSON(obj.columns) + '\n');
- while( obj.columns[cols_idx] && obj.columns[cols_idx].hidden && obj.columns[cols_idx].hidden == 'true') {
- dump('\t' + cols_idx);
- var treecell = document.createElement('treecell');
- treerow.appendChild(treecell);
- cols_idx++;
- }
- */
- var create_treecells = treerow.childNodes.length == 0;
for (var i = 0; i < obj.columns.length; i++) {
- var treecell = create_treecells ? document.createElement('treecell') : treerow.childNodes[i];
- if (treecell) {
- if (create_treecells) {
- treecell.setAttribute('label',document.getElementById('offlineStrings').getString('list.row_retrieving'));
- treerow.appendChild(treecell);
- }
+ var treecell;
+ if (typeof treerow.childNodes[i] == 'undefined') {
+ treecell = document.createElement('treecell');
+ treerow.appendChild(treecell);
+ } else {
+ treecell = treerow.childNodes[i];
}
+ treecell.setAttribute('label',document.getElementById('offlineStrings').getString('list.row_retrieving'));
}
- /*
- dump('\t' + cols_idx + '\n');
- */
} catch(E) {
alert('Error in list.js, put_retrieving_label(): ' + E);
}
@@ -976,24 +962,29 @@
'_map_row_to_treecell' : function(params,treerow) {
var obj = this;
var s = '';
- //util.widgets.remove_children(treerow);
- var create_treecells = treerow.childNodes.length == 0;
if (typeof params.map_row_to_column == 'function' || typeof this.map_row_to_column == 'function') {
for (var i = 0; i < this.columns.length; i++) {
- var treecell = create_treecells ? document.createElement('treecell') : treerow.childNodes[i];
+ var treecell;
+ if (typeof treerow.childNodes[i] == 'undefined') {
+ treecell = document.createElement('treecell');
+ treerow.appendChild( treecell );
+ } else {
+ treecell = treerow.childNodes[i];
+ }
+
if ( this.columns[i].editable == false ) { treecell.setAttribute('editable','false'); }
var label = '';
+
+ // What skip columns is doing is rendering the treecells as blank/empty
if (params.skip_columns && (params.skip_columns.indexOf(i) != -1)) {
treecell.setAttribute('label',label);
- treerow.appendChild( treecell );
s += ('treecell = ' + treecell + ' with label = ' + label + '\n');
continue;
}
if (params.skip_all_columns_except && (params.skip_all_columns_except.indexOf(i) == -1)) {
treecell.setAttribute('label',label);
- treerow.appendChild( treecell );
s += ('treecell = ' + treecell + ' with label = ' + label + '\n');
continue;
}
@@ -1008,7 +999,6 @@
}
if (this.columns[i].type == 'checkbox') { treecell.setAttribute('value',label); } else { treecell.setAttribute('label',label ? label : ''); }
- if (create_treecells) { treerow.appendChild( treecell ); }
s += ('treecell = ' + treecell + ' with label = ' + label + '\n');
}
} else if (typeof params.map_row_to_columns == 'function' || typeof this.map_row_to_columns == 'function') {
@@ -1025,14 +1015,19 @@
}
for (var i = 0; i < labels.length; i++) {
- var treecell = create_treecells ? document.createElement('treecell') : treerow.childNodes[i];
+ var treecell;
+ if (typeof treerow.childNodes[i] == 'undefined') {
+ treecell = document.createElement('treecell');
+ treerow.appendChild(treecell);
+ } else {
+ treecell = treerow.childNodes[i];
+ }
if ( this.columns[i].editable == false ) { treecell.setAttribute('editable','false'); }
if ( this.columns[i].type == 'checkbox') {
treecell.setAttribute('value', labels[i]);
} else {
treecell.setAttribute('label',typeof labels[i] == 'string' || typeof labels[i] == 'number' ? labels[i] : '');
}
- if (create_treecells) { treerow.appendChild( treecell ); }
s += ('treecell = ' + treecell + ' with label = ' + labels[i] + '\n');
}
@@ -1149,7 +1144,14 @@
var treeitem = this.treechildren.childNodes[i];
var treerow = treeitem.firstChild;
for (var j = 0; j < treerow.childNodes.length; j++) {
- row[ obj.columns[j].id ] = treerow.childNodes[j].getAttribute('label');
+ if (typeof obj.columns[j] == 'undefined') {
+ dump('=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n');
+ dump('_dump_tree_with_keys @ ' + location.href + '\n');
+ dump('\ttreerow.childNodes.length='+treerow.childNodes.length+' j='+j+' obj.columns.length='+obj.columns.length+'\n');
+ debugger;
+ } else {
+ row[ obj.columns[j].id ] = treerow.childNodes[j].getAttribute('label');
+ }
}
dump.push( row );
}
@@ -1358,8 +1360,15 @@
for (var j = 0; j < treerow.childNodes.length; j++) {
var value = treerow.childNodes[j].getAttribute('label');
if (params.skip_hidden_columns) if (obj.node.treeBoxObject.columns.getColumnAt(j).element.getAttribute('hidden') == 'true') continue;
- var id = obj.columns[j].id; if (params.labels_instead_of_ids) id = obj.columns[j].label;
- row[ id ] = value;
+ if (typeof obj.columns[j] == 'undefined') {
+ dump('=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n');
+ dump('_dump_tree_selection_with_keys @ ' + location.href + '\n');
+ dump('\ttreerow.childNodes.length='+treerow.childNodes.length+' j='+j+' obj.columns.length='+obj.columns.length+'\n');
+ debugger;
+ } else {
+ var id = obj.columns[j].id; if (params.labels_instead_of_ids) id = obj.columns[j].label;
+ row[ id ] = value;
+ }
}
dump.push( row );
}
More information about the open-ils-commits
mailing list