Permalink
Browse files

GADGETS-45: Properties not displayed for Situation.

  • Loading branch information...
jeffyu committed Mar 18, 2013
1 parent d571740 commit 513325083e5240f9e2a297c1ab5bc9e0a3b70abb
@@ -66,8 +66,9 @@
var theContext = [{"type":"Message", "value":"This is the first message"},
{"type":"message", "value":"Another message"}];
- appendContext(theContext, rowId, theBody, "Context");
- appendContext(theContext, rowId, theBody, "Properties");
+ var theProperty = {"customer":"Fred", "total":"240.0", "item":"JAM"};
+ appendContext(theContext, rowId, theBody);
+ appendProperties(theProperty, rowId, theBody);
}
function appendContextHeader(theBody, rowId){
@@ -88,7 +89,7 @@
theRow.appendChild(cell);
}
- function appendContext(data, rowId, theBody, description) {
+ function appendContext(data, rowId, theBody) {
var i, contextRow, cell;
if (data.length > 0) {
for (i = 0; i < data.length; i++) {
@@ -97,22 +98,49 @@
theBody.appendChild(contextRow);
cell = document.createElement("TD");
if (i == 0) {
- cell.innerHTML="<b>" + description + "</b>";
+ cell.innerHTML="<b>Context</b>";
}
contextRow.appendChild(cell);
cell = document.createElement("TD");
- cell.innerHTML=data.type;
+ cell.innerHTML=data[i].type;
contextRow.appendChild(cell);
cell = document.createElement("TD");
cell.setAttribute("colspan", "3");
- cell.innerHTML=data.message;
+ cell.innerHTML=data[i].value;
contextRow.appendChild(cell);
}
}
}
+ function appendProperties(data, rowId, theBody) {
+ var i, contextRow, cell, property;
+ i = 0;
+ for (property in data) {
+ contextRow = document.createElement("TR");
+ contextRow.setAttribute("class", "table-row detail child-" + rowId);
+ theBody.appendChild(contextRow);
+ cell = document.createElement("TD");
+ if (i == 0) {
+ cell.innerHTML="<b>Properties</b>";
+ }
+ contextRow.appendChild(cell);
+
+ cell = document.createElement("TD");
+ cell.innerHTML=property;
+ contextRow.appendChild(cell);
+
+ cell = document.createElement("TD");
+ cell.setAttribute("colspan", "3");
+ cell.innerHTML=data[property];
+ contextRow.appendChild(cell);
+
+ i++;
+ }
+
+ }
+
function parseJSON(data) {
return window.JSON && window.JSON.parse ? window.JSON.parse( data ) : (new Function("return " + data))();
}
@@ -99,8 +99,8 @@
theRow.appendChild(theCell);
appendContextHeader(theBody, rowId);
- appendContext(rawData.context, rowId, theBody, "Context");
- appendContext(rawData.properties, rowId, theBody, "Properties");
+ appendContext(rawData.context, rowId, theBody);
+ appendProperties(rawData.properties, rowId, theBody);
}
function appendContextHeader(theBody, rowId){
@@ -122,7 +122,7 @@
theRow.appendChild(cell);
}
- function appendContext(data, rowId, theBody, description) {
+ function appendContext(data, rowId, theBody) {
var i, contextRow, cell;
if (data.length > 0) {
for (i = 0; i < data.length; i++) {
@@ -131,7 +131,7 @@
theBody.appendChild(contextRow);
cell = document.createElement("TD");
if (i == 0) {
- cell.innerHTML="<b>" + description + "</b>";
+ cell.innerHTML="<b>Context</b>";
}
contextRow.appendChild(cell);
@@ -147,6 +147,33 @@
}
}
+ function appendProperties(data, rowId, theBody) {
+ var i, contextRow, cell, property;
+ i = 0;
+ for (property in data) {
+ contextRow = document.createElement("TR");
+ contextRow.setAttribute("class", "table-row detail child-" + rowId);
+ theBody.appendChild(contextRow);
+ cell = document.createElement("TD");
+ if (i == 0) {
+ cell.innerHTML="<b>Properties</b>";
+ }
+ contextRow.appendChild(cell);
+
+ cell = document.createElement("TD");
+ cell.innerHTML=property;
+ contextRow.appendChild(cell);
+
+ cell = document.createElement("TD");
+ cell.setAttribute("colspan", "3");
+ cell.innerHTML=data[property];
+ contextRow.appendChild(cell);
+
+ i++;
+ }
+
+ }
+
function deleteRows() {
var theBody, theSize, i;
theBody = document.getElementById("sla-body");

0 comments on commit 5133250

Please sign in to comment.