Skip to content

Commit

Permalink
testresults views overview table server side loading
Browse files Browse the repository at this point in the history
  • Loading branch information
evlach committed Jun 3, 2014
1 parent 2de2d8f commit 0f6a169
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 60 deletions.
17 changes: 14 additions & 3 deletions js/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@
URL_SERVICE_GET_TESTUNITS: "test",
URL_SERVICE_GET_TESTUNITS_TREE: "test/tree",
// TestResult resource
URL_SERVICE_TESTRESULT_DATAOVERVIEW: "testresult/browse/dataoverview",
URL_SERVICE_TESTRESULT_BYTECHNIQUE_OVERVIEW: "testresult/browse/bytechnique/overview",
URL_SERVICE_TESTRESULT_BYTEST_OVERVIEW: "testresult/browse/bytest/overview/", //{techNameId}

URL_SERVICE_TESTRESULT_FULLVIEWTECHNIQUE: "testresult/browse/fullviewtechnique/",
URL_SERVICE_TESTRESULT_VIEWTECHNIQUE: "testresult/browse/resultsview/",
URL_SERVICE_TESTRESULT_TREE_AT: "testresult/browse/at/tree",
Expand Down Expand Up @@ -150,14 +152,23 @@
persistBunch: function (bunch, callback) {
ajax(accessdb.config.services.URL_SERVICE_TESTRESULT_PERSIST, 'POST', bunch, callback);
},
getDataOverview: function (filter, callback, targetE) {
var url = accessdb.config.services.URL_SERVICE_TESTRESULT_DATAOVERVIEW;
findByFilterTestResultTechniqueOveview: function (filter, callback, targetE) {
var url = accessdb.config.services.URL_SERVICE_TESTRESULT_BYTECHNIQUE_OVERVIEW;
ajax(url, "POST", filter, function (error, data, status) {
if(data)
data = data.list;
callback(error, data, status);
}, targetE);
},
findByFilterTestResultTestOveview: function (filter,techNameId, callback, targetE) {
var url = accessdb.config.services.URL_SERVICE_TESTRESULT_BYTEST_OVERVIEW + techNameId;
ajax(url, "POST", filter, function (error, data, status) {
if(data)
data = data.list;
callback(error, data, status);
}, targetE);
},

getResultsByTechnique : function(filter, techniqueNameId, callback, targetE){
ajax(accessdb.config.services.URL_SERVICE_TESTRESULT_VIEWTECHNIQUE + techniqueNameId, "POST", filter, callback, targetE);
},
Expand Down
84 changes: 30 additions & 54 deletions js/testresult-views.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,6 @@
* }
*
*/

testcaseData = {
"entity": [
{
"noOfAll": "2",
"noOfPass": "1",
"testCaseId": "H49_0000073",
"testCaseTitle": "Em and strong elements can be used to stress parts of a text"
},
{
"noOfAll": "3",
"noOfPass": "1",
"testCaseId": "H49_0000074",
"testCaseTitle": "sub elements indicate subscript in HTML"
},
{
"noOfAll": "4",
"noOfPass": "1",
"testCaseId": "H49_0000075",
"testCaseTitle": "sup elements indicate superscript in HTML"
},
{
"noOfAll": "5",
"noOfPass": "2",
"testCaseId": "H49_0000076",
"testCaseTitle": "abbr and acronym can identify special text in html"
},
{
"noOfAll": "6",
"noOfPass": "3",
"testCaseId": "H49_0000077",
"testCaseTitle": "b, i and u can identify special text in HTML"
},
{
"noOfAll": "7",
"noOfPass": "5",
"testCaseId": "H49_0000078",
"testCaseTitle": "small identifies special text in HTML"
}
]
};

accessdb.Views.TestResultsDataOverview = function (){
this.$el = $("#TestResultsDataOverviewDiv");
this.results = null;
Expand All @@ -64,28 +22,30 @@ accessdb.Views.TestResultsDataOverview = function (){
});
}
};
this.fetch = function (filter, callback){
this.fetch = function (params, callback){
var self = this;
if (!filter){
if (!params || params.length<1 ){
console.warn("No filter defined!");
callback("No filter defined!", null);
}
else {
accessdb.API.TESTRESULT.getDataOverview(filter, function (error, data, status) {
accessdb.API.TESTRESULT.findByFilterTestResultTechniqueOveview(params.filter, function (error, data, status) {
if(!error){
console.log(data);
self.results = data;
callback(null, self.results);
}
callback(error);
}, self.$el);
else
callback(error);
});
}
};
this.reload = function(){
var pageId = accessdb.config.PAGE_ID_PREFIX+"results";
if(accessdb.appRouter.page === pageId){
var self = this;
this.fetch( accessdb.filters[pageId], function(error, data){
var params = {filter: accessdb.filters[pageId]};
this.fetch(params, function(error, data){
if(!error)
self.render();
});
Expand All @@ -103,8 +63,8 @@ accessdb.Views.TestResultsDataTestCaseOverview = function (){
icon = this.$el.find('.icon');
iconlabel = icon.find('.visuallyhidden');
eltbody.toggleClass('collapsed');
console.log(testcaseData);
var tctemplate = _.template( $("#TestResultsDataOverviewTestCases_template").html(), {results: testcaseData.entity} );
console.log(this.results);
var tctemplate = _.template( $("#TestResultsDataOverviewTestCases_template").html(), {results: this.results} );
sistertbody.html( tctemplate );
icon.toggleClass('icon-collapse icon-expand');
if (icon.is('.icon-expand')) {
Expand All @@ -114,16 +74,32 @@ accessdb.Views.TestResultsDataTestCaseOverview = function (){
}
}
};
this.fetch = function (filter, callback){
this.fetch = function (params, callback){
var self = this;
self.results = testcaseData;
callback();
if (!params || params.length<2 ){
console.warn("No filter defined!");
callback("No filter defined!", null);
}
else {
var filter = params.filter;
var techNameId = $(this.$el).val();
accessdb.API.TESTRESULT.findByFilterTestResultTestOveview(params.filter, techNameId, function (error, data, status) {
if(!error){
console.log(data);
self.results = data;
callback(null, self.results);
}
else
callback(error);
});
}
};
this.reload = function(){
var pageId = accessdb.config.PAGE_ID_PREFIX+"results";
if(accessdb.appRouter.page === pageId){
var self = this;
this.fetch( accessdb.filters[pageId], function(error, data){
var params = {filter:accessdb.filters[pageId]};
this.fetch(params , function(error, data){
if(!error)
self.render();
});
Expand Down
13 changes: 10 additions & 3 deletions templates.html
Original file line number Diff line number Diff line change
Expand Up @@ -289,28 +289,35 @@ <h4>Test Results</h4>
<script type="text/template" id="TestResultsDataOverviewTestCases_template">
<% lresults = results.length %>
<% first = true %>
<% _.each(results, function(r) { %>
<% _.each(results, function(r) { %>
<tr>
<% if (first) { %>
<td class="empty" rowspan="<%=lresults%>"></td>
<th scope="rowgroup" rowspan="<%=lresults%>">
Test Cases
</th>
<% first = false %>
<% } %>
<% }
%>
<th scope="row">
<%= r.testCaseId %>: <a href="http://www.w3.org/TR/WCAG20-TECHS/<%= r.testCaseId %>"> <%= r.testCaseTitle %>
<%= r.testUnitId %>: <a href="http://www.w3.org/TR/WCAG20-TECHS/<%= r.testUnitId %>"> <%= r.testTitle %>
<span class="icon-external-link"><span class="visuallyhidden">Link to external page.</span></span></a>
</th>

<td class="result">
<a href="h4.html" class="btn btn-small">
<span class="chart" style="display:none"><%= r.noOfPass %>/<%= r.noOfAll %></span>
<%
console.log("template");
console.log(r);
%>
<%= r.noOfPass %>/<%= r.noOfAll %>
<span class="icon-arrow-right2">
<span class="visuallyhidden">Show results</span>
</span>
</a>
</td>
</tr>

<% }); %>
</script>

0 comments on commit 0f6a169

Please sign in to comment.