Skip to content

Commit

Permalink
Porting the following fix: "Fixing [ #314415 ] Datatable within an xf…
Browse files Browse the repository at this point in the history
…orms:repeat are not properly initialized when iterations are deleted and added again. Also including a unit test." to the master branch.
  • Loading branch information
evlist committed Nov 4, 2009
1 parent cc28577 commit c539065
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 17 deletions.
Expand Up @@ -202,7 +202,7 @@ ORBEON.widgets.datatable.unittests_lib = {

getBodyTable: function(table, isSplit) {
if (isSplit) {
var container = table.parentNode.parentNode;
var container = YAHOO.util.Dom.getAncestorByClassName(table, 'yui-dt');
return container.getElementsByTagName('table')[1];
} else {
return table;
Expand Down Expand Up @@ -298,7 +298,7 @@ ORBEON.widgets.datatable.unittests_lib = {
},

checkCellClassesInARow: function(row, classPrefix) {
var iActual = 0;
var iActual = 0; f
for (var i = 0; i < row.cells.length; i++)
{
var cell = row.cells[i];
Expand Down
Expand Up @@ -74,6 +74,7 @@
<controls>
<maxLength>20</maxLength>
<loading>true</loading>
<show>true</show>
</controls>
</xforms:instance>

Expand Down
77 changes: 63 additions & 14 deletions src/resources-packaged/xbl/orbeon/datatable/datatable-unittest.js
Expand Up @@ -17,6 +17,41 @@ var testCase = {

name: "datatable",

test314415: function() {
var thiss = this;
thiss.openAccordionCase(thiss, '_314415', function() {

ORBEON.util.Test.executeCausingAjaxRequest(thiss, function() {
ORBEON.xforms.Document.setValue("show", "true");
}, function() {
// Check the table structure
var table = YAHOO.util.Dom.get('my-accordion$_314415-table$_314415-table-table·1');
thiss.checkTableStructure(table, 1, true);

ORBEON.util.Test.executeCausingAjaxRequest(thiss, function() {
ORBEON.xforms.Document.setValue("show", "false");
}, function() {
table = YAHOO.util.Dom.get('my-accordion$_314415-table$_314415-table-table·1');
YAHOO.util.Assert.isNull(table, "The table should have been deleted");
ORBEON.util.Test.executeCausingAjaxRequest(thiss, function() {
ORBEON.xforms.Document.setValue("show", "true");
}, function() {
// Check the table structure
table = YAHOO.util.Dom.get('my-accordion$_314415-table$_314415-table-table·1');
thiss.checkTableStructure(table, 1, true);

thiss.closeAccordionCase(thiss, '_314415');
});
});

});

}
)
;
},


test314422: function() {
var thiss = this;
thiss.openAccordionCase(thiss, '_314422', function() {
Expand Down Expand Up @@ -49,7 +84,8 @@ var testCase = {
});

});
},
}
,


test314359: function() {
Expand All @@ -66,7 +102,8 @@ var testCase = {

});

},
}
,

test314217: function() {
var thiss = this;
Expand All @@ -76,7 +113,8 @@ var testCase = {
thiss.checkHorizontalScrollbar(bodyContainer);
thiss.closeAccordionCase(thiss, '_314217');
});
},
}
,

testWidths: function() {
var thiss = this;
Expand All @@ -86,7 +124,8 @@ var testCase = {
thiss.checkTableAndContainerWidths(YAHOO.util.Dom.get('my-accordion$table-widths$table-widths-table'));
thiss.closeAccordionCase(thiss, 'widths');
});
},
}
,

testWidthsResizeable: function() {
var thiss = this;
Expand All @@ -96,7 +135,8 @@ var testCase = {
thiss.checkTableAndContainerWidths(table);
thiss.closeAccordionCase(thiss, 'widths-resizeable');
});
},
}
,

testWidthsResizeable100pxRight: function() {
var thiss = this;
Expand All @@ -113,7 +153,8 @@ var testCase = {
thiss.checkRowWidth(table.tHead.rows[0]);
thiss.closeAccordionCase(thiss, 'widths-resizeable');
});
},
}
,

testWidthsResizeable100pxLeft: function() {
var thiss = this;
Expand All @@ -130,7 +171,8 @@ var testCase = {
thiss.checkRowWidth(table.tHead.rows[0]);
thiss.closeAccordionCase(thiss, 'widths-resizeable');
});
},
}
,

testWidthsResizeable10MorePxLeft: function() {
var thiss = this;
Expand All @@ -147,7 +189,8 @@ var testCase = {
YAHOO.util.Assert.areEqual(width2 - 10, th2.clientWidth, "The width of the second column should be " + (width2 - 10) + ", not " + th2.clientWidth);
thiss.closeAccordionCase(thiss, 'widths-resizeable');
});
},
}
,

test314216: function() {
var thiss = this;
Expand All @@ -162,7 +205,8 @@ var testCase = {
thiss.checkCellWidth(th);
thiss.closeAccordionCase(thiss, '_314216');
});
},
}
,

test314209: function() {
var thiss = this;
Expand All @@ -176,7 +220,8 @@ var testCase = {
});

});
},
}
,

test314211: function() {
var thiss = this;
Expand All @@ -186,14 +231,16 @@ var testCase = {
thiss.closeAccordionCase(thiss, '_314211');

});
},
}
,

test314174: function() {
var thiss = this;
thiss.openAccordionCase(thiss, '_314174');
//TODO: test something here!
thiss.closeAccordionCase(thiss, '_314174');
},
}
,

test314210: function() {
var thiss = this;
Expand All @@ -202,7 +249,8 @@ var testCase = {
YAHOO.util.Assert.isTrue(headerTable.clientWidth > headerTable.parentNode.clientWidth, 'The table header width (' + headerTable.clientWidth + 'px) should be larger than its container width (' + headerTable.parentNode.clientWidth + 'px).');
thiss.closeAccordionCase(thiss, '_314210');
});
},
}
,

test314292: function() {
var thiss = this;
Expand All @@ -223,7 +271,8 @@ var testCase = {
}, 500);

});
},
}
,

EOS: ""
}
Expand Down
Expand Up @@ -41,6 +41,14 @@
</xforms:input>
</xforms:group>
</xhtml:p>
<xhtml:p>
<xforms:group ref="instance('controls')">
<xforms:input ref="show" id="show">
<xforms:label>Show: </xforms:label>
<xforms:help>Used by tests that hide/show cycles.</xforms:help>
</xforms:input>
</xforms:group>
</xhtml:p>
<xhtml:ol>
<xhtml:li>
<xforms:trigger appearance="minimal" id="open-all">
Expand Down Expand Up @@ -94,6 +102,36 @@
</fr:datatable>
</xhtml:div>
</fr:case>-->
<fr:case selected="true" id="_314415">
<fr:label>#314415:Datatable within an xforms:repeat are not properly initialized
when iterations are deleted and added again</fr:label>
<xhtml:div>
<xhtml:p>Bug <xhtml:a
href="http://forge.ow2.org/tracker/index.php?func=detail&amp;aid=314415&amp;group_id=168&amp;atid=350207"
>314415</xhtml:a>.</xhtml:p>
<xforms:group ref="instance('lorem')[instance('controls')/show = 'true']">
<xforms:repeat nodeset="line[position() = (1, 2)]">
<fr:datatable id="_314415-table" scrollable="both" width="500px" height="200px">
<xhtml:thead>
<xhtml:tr>
<xhtml:th>Text</xhtml:th>
</xhtml:tr>
</xhtml:thead>
<xhtml:tbody>
<xforms:repeat
nodeset="instance('lorem')/line[string-length(.) > 100]">
<xhtml:tr>
<xhtml:td>
<xforms:output value="."/>
</xhtml:td>
</xhtml:tr>
</xforms:repeat>
</xhtml:tbody>
</fr:datatable>
</xforms:repeat>
</xforms:group>
</xhtml:div>
</fr:case>
<fr:case selected="true" id="_314422">
<fr:label>#314422: Datatable: go to the last page when the current page
disappears</fr:label>
Expand Down
3 changes: 2 additions & 1 deletion src/resources-packaged/xbl/orbeon/datatable/datatable.js
Expand Up @@ -726,11 +726,12 @@ ORBEON.widgets.datatable.init = function (target, innerTableWidth) {
var container = target.parentNode.parentNode;
var id = container.id;
if (! YAHOO.util.Dom.hasClass(target, 'xforms-disabled')) {
if (ORBEON.widgets.datatable.datatables[id] == undefined) {
if (ORBEON.widgets.datatable.datatables[id] == undefined || container.fr_dt_initialized == undefined) {
var table = YAHOO.util.Selector.query('table', target.parentNode, false)[0];
var region = YAHOO.util.Region.getRegion(table);
if (region.left >= 0 && region.top >= 0) {
ORBEON.widgets.datatable.datatables[id] = new ORBEON.widgets.datatable(table, id, innerTableWidth);
container.fr_dt_initialized = true;
} else {
//Hack!!! We are here if the datatable is hidden unselected in an xforms:switch/xforms:case...
var cmd = "ORBEON.widgets.datatable.init(document.getElementById('" + target.id + "'), " + innerTableWidth + ");";
Expand Down

0 comments on commit c539065

Please sign in to comment.