[open-ils-commits] r17119 - branches/rel_1_6_0/Open-ILS/xul/staff_client/chrome/content/util (phasefx)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Aug 6 13:53:37 EDT 2010
Author: phasefx
Date: 2010-08-06 13:53:33 -0400 (Fri, 06 Aug 2010)
New Revision: 17119
Modified:
branches/rel_1_6_0/Open-ILS/xul/staff_client/chrome/content/util/list.js
Log:
backporting changeset 16688 for more robust printing (addresses some "inner print_tree" errors). See https://bugs.launchpad.net/evergreen/+bug/567505/
Modified: branches/rel_1_6_0/Open-ILS/xul/staff_client/chrome/content/util/list.js
===================================================================
--- branches/rel_1_6_0/Open-ILS/xul/staff_client/chrome/content/util/list.js 2010-08-06 15:33:11 UTC (rev 17118)
+++ branches/rel_1_6_0/Open-ILS/xul/staff_client/chrome/content/util/list.js 2010-08-06 17:53:33 UTC (rev 17119)
@@ -393,12 +393,12 @@
s += ('tree = ' + this.node + ' treechildren = ' + treechildren_node + '\n');
s += ('treeitem = ' + treeitem + ' treerow = ' + treerow + '\n');
- if (typeof params.retrieve_row == 'function' || typeof this.retrieve_row == 'function') {
+ obj.put_retrieving_label(treerow);
- obj.put_retrieving_label(treerow);
- treerow.addEventListener(
- 'flesh',
- function() {
+ if (typeof params.retrieve_row == 'function' || typeof this.retrieve_row == 'function') {
+ treerow.addEventListener(
+ 'flesh',
+ function() {
if (treerow.getAttribute('retrieved') == 'true') return; /* already running */
@@ -442,46 +442,45 @@
obj.retrieve_row( params );
- } else {
-
- inc_fleshed();
- }
- },
- false
- );
- /*
- setTimeout(
- function() {
- util.widgets.dispatch('flesh',treerow);
- }, 0
- );
- */
- } else {
- obj.put_retrieving_label(treerow);
- treerow.addEventListener(
- 'flesh',
- function() {
- //dump('fleshing anon\n');
- if (treerow.getAttribute('fleshed') == 'true') return; /* already fleshed */
- obj._map_row_to_treecell(params,treerow);
- treerow.setAttribute('retrieved','true');
- treerow.setAttribute('fleshed','true');
- obj.row_count.fleshed++;
- if (obj.row_count.fleshed >= obj.row_count.total) {
- setTimeout( function() { obj.exec_on_all_fleshed(); }, 0 );
- }
- },
- false
- );
- /*
- setTimeout(
- function() {
- util.widgets.dispatch('flesh',treerow);
- }, 0
- );
- */
- }
- this.error.sdump('D_LIST',s);
+ } else {
+
+ inc_fleshed();
+ }
+ },
+ false
+ );
+ /*
+ setTimeout(
+ function() {
+ util.widgets.dispatch('flesh',treerow);
+ }, 0
+ );
+ */
+ } else {
+ treerow.addEventListener(
+ 'flesh',
+ function() {
+ //dump('fleshing anon\n');
+ if (treerow.getAttribute('fleshed') == 'true') return; /* already fleshed */
+ obj._map_row_to_treecell(params,treerow);
+ treerow.setAttribute('retrieved','true');
+ treerow.setAttribute('fleshed','true');
+ obj.row_count.fleshed++;
+ if (obj.row_count.fleshed >= obj.row_count.total) {
+ setTimeout( function() { obj.exec_on_all_fleshed(); }, 0 );
+ }
+ },
+ false
+ );
+ /*
+ setTimeout(
+ function() {
+ util.widgets.dispatch('flesh',treerow);
+ }, 0
+ );
+ */
+ }
+ this.error.sdump('D_LIST',s);
try {
@@ -540,13 +539,14 @@
s += ('tree = ' + this.node + '\n');
s += ('treeitem = ' + treeitem + ' treerow = ' + treerow + '\n');
- if (typeof params.retrieve_row == 'function' || typeof this.retrieve_row == 'function') {
+ obj.put_retrieving_label(treerow);
- obj.put_retrieving_label(treerow);
- treerow.addEventListener(
- 'flesh',
- function() {
+ if (typeof params.retrieve_row == 'function' || typeof this.retrieve_row == 'function') {
+ treerow.addEventListener(
+ 'flesh',
+ function() {
+
if (treerow.getAttribute('retrieved') == 'true') return; /* already running */
treerow.setAttribute('retrieved','true');
@@ -589,46 +589,45 @@
obj.retrieve_row( params );
- } else {
-
- inc_fleshed();
- }
- },
- false
- );
- /*
- setTimeout(
- function() {
- util.widgets.dispatch('flesh',treerow);
- }, 0
- );
- */
- } else {
- obj.put_retrieving_label(treerow);
- treerow.addEventListener(
- 'flesh',
- function() {
- //dump('fleshing anon\n');
- if (treerow.getAttribute('fleshed') == 'true') return; /* already fleshed */
- obj._map_row_to_treecell(params,treerow);
- treerow.setAttribute('retrieved','true');
- treerow.setAttribute('fleshed','true');
- obj.row_count.fleshed++;
- if (obj.row_count.fleshed >= obj.row_count.total) {
- setTimeout( function() { obj.exec_on_all_fleshed(); }, 0 );
- }
- },
- false
- );
- /*
- setTimeout(
- function() {
- util.widgets.dispatch('flesh',treerow);
- }, 0
- );
- */
- }
- this.error.sdump('D_LIST',s);
+ } else {
+
+ inc_fleshed();
+ }
+ },
+ false
+ );
+ /*
+ setTimeout(
+ function() {
+ util.widgets.dispatch('flesh',treerow);
+ }, 0
+ );
+ */
+ } else {
+ treerow.addEventListener(
+ 'flesh',
+ function() {
+ //dump('fleshing anon\n');
+ if (treerow.getAttribute('fleshed') == 'true') return; /* already fleshed */
+ obj._map_row_to_treecell(params,treerow);
+ treerow.setAttribute('retrieved','true');
+ treerow.setAttribute('fleshed','true');
+ obj.row_count.fleshed++;
+ if (obj.row_count.fleshed >= obj.row_count.total) {
+ setTimeout( function() { obj.exec_on_all_fleshed(); }, 0 );
+ }
+ },
+ false
+ );
+ /*
+ setTimeout(
+ function() {
+ util.widgets.dispatch('flesh',treerow);
+ }, 0
+ );
+ */
+ }
+ this.error.sdump('D_LIST',s);
try {
@@ -651,30 +650,23 @@
return params;
},
- '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++;
- }
- */
- for (var i = 0; i < obj.columns.length; i++) {
- var treecell = document.createElement('treecell'); treecell.setAttribute('label',document.getElementById('offlineStrings').getString('list.row_retrieving'));
- treerow.appendChild(treecell);
- }
- /*
- dump('\t' + cols_idx + '\n');
- */
- } catch(E) {
- alert(E);
- }
- },
+ 'put_retrieving_label' : function(treerow) {
+ var obj = this;
+ try {
+ for (var i = 0; i < obj.columns.length; i++) {
+ 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'));
+ }
+ } catch(E) {
+ alert(E);
+ }
+ },
'detect_visible' : function() {
var obj = this;
@@ -876,44 +868,50 @@
},
- '_map_row_to_treecell' : function(params,treerow) {
- var obj = this;
- var s = '';
- util.widgets.remove_children(treerow);
+ '_map_row_to_treecell' : function(params,treerow) {
+ var obj = this;
+ var s = '';
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 = document.createElement('treecell');
- var label = '';
- 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;
- }
-
- if (typeof params.map_row_to_column == 'function') {
-
- label = params.map_row_to_column(params.row,this.columns[i]);
-
- } else if (typeof this.map_row_to_column == 'function') {
-
- label = this.map_row_to_column(params.row,this.columns[i]);
-
- }
- treecell.setAttribute('label',label ? label : '');
- 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') {
+ for (var i = 0; i < this.columns.length; 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);
+ 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);
+ s += ('treecell = ' + treecell + ' with label = ' + label + '\n');
+ continue;
+ }
+
+ if (typeof params.map_row_to_column == 'function') {
+
+ label = params.map_row_to_column(params.row,this.columns[i]);
+
+ } else if (typeof this.map_row_to_column == 'function') {
+
+ label = this.map_row_to_column(params.row,this.columns[i]);
+
+ }
+ if (this.columns[i].type == 'checkbox') { treecell.setAttribute('value',label); } else { treecell.setAttribute('label',label ? label : ''); }
+ s += ('treecell = ' + treecell + ' with label = ' + label + '\n');
+ }
+ } else if (typeof params.map_row_to_columns == 'function' || typeof this.map_row_to_columns == 'function') {
+
var labels = [];
if (typeof params.map_row_to_columns == 'function') {
@@ -924,13 +922,23 @@
labels = this.map_row_to_columns(params.row,this.columns);
- }
- for (var i = 0; i < labels.length; i++) {
- var treecell = document.createElement('treecell');
- treecell.setAttribute('label',typeof labels[i] == 'string' || typeof labels[i] == 'number' ? labels[i] : '');
- treerow.appendChild( treecell );
- s += ('treecell = ' + treecell + ' with label = ' + labels[i] + '\n');
- }
+ }
+ for (var i = 0; i < labels.length; 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] : '');
+ }
+ s += ('treecell = ' + treecell + ' with label = ' + labels[i] + '\n');
+ }
} else {
@@ -1037,20 +1045,27 @@
},
- '_dump_tree_with_keys' : function(params) {
- var obj = this;
- var dump = [];
- for (var i = 0; i < this.treechildren.childNodes.length; i++) {
- var row = {};
- 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');
- }
- dump.push( row );
- }
- return dump;
- },
+ '_dump_tree_with_keys' : function(params) {
+ var obj = this;
+ var dump = [];
+ for (var i = 0; i < this.treechildren.childNodes.length; i++) {
+ var row = {};
+ var treeitem = this.treechildren.childNodes[i];
+ var treerow = treeitem.firstChild;
+ for (var j = 0; j < treerow.childNodes.length; j++) {
+ 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 );
+ }
+ return dump;
+ },
'dump_csv' : function(params) {
var obj = this;
@@ -1186,24 +1201,31 @@
},
- '_dump_tree_selection_with_keys' : function(params) {
- var obj = this;
- var dump = [];
- var list = obj._retrieve_selection_from_tree();
- for (var i = 0; i < list.length; i++) {
- var row = {};
- var treeitem = list[i];
- var treerow = treeitem.firstChild;
- 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;
- }
- dump.push( row );
- }
- return dump;
- },
+ '_dump_tree_selection_with_keys' : function(params) {
+ var obj = this;
+ var dump = [];
+ var list = obj._retrieve_selection_from_tree();
+ for (var i = 0; i < list.length; i++) {
+ var row = {};
+ var treeitem = list[i];
+ var treerow = treeitem.firstChild;
+ 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;
+ 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 );
+ }
+ return dump;
+ },
'clipboard' : function(params) {
try {
More information about the open-ils-commits
mailing list