Commit 48adee34 authored by Jérome Perrin's avatar Jérome Perrin

Input_viewResultComparison: support cases where a given order does not exist in all scenarios

parent 568a370b
......@@ -19,7 +19,7 @@
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("render", function (options) {
var gadget = this, order_lateness = {}, json_result;
var gadget = this, order_lateness = {}, general_json;
this.props.jio_key = options.id;
return gadget.aq_getAttachment({
......@@ -34,11 +34,12 @@
throw error;
})
.push(function (sim_json) {
var result = JSON.parse(sim_json).result,
var json = JSON.parse(sim_json),
result = json.result,
result_list = [],
document_list = [],
i;
json_result = result;
general_json = result;
if (result && result.result_list) {
document_list = result.result_list;
}
......@@ -51,16 +52,17 @@
return RSVP.all(result_list);
})
.push(function (result_list) {
var i, link, result,
var i, link, result, scenario_id,
calculateOrderLateness = function(order_id) {
var order = result.order_lateness[order_id];
order.link = link;
if (!order_lateness[order_id]){
order_lateness[order_id] = [];
order_lateness[order_id] = {};
}
order_lateness[order_id].push(order);
order_lateness[order_id][scenario_id] = order;
};
for (i=0; i<result_list.length; i+=1) {
scenario_id = result_list[i][1].name || i;
link = result_list[i][0];
result = result_list[i][1];
Object.keys(result.order_lateness).forEach(calculateOrderLateness);
......@@ -69,16 +71,16 @@
})
.push(function(tableeditor) {
var i,
data = [],
data = {}, data_list = [],
colHeaders = ["Project"],
columns = [{data: 0}];
columns = [{data: "id"}];
Object.keys(order_lateness).forEach(function(order_id) {
var order = order_lateness[order_id];
order.unshift(order_id);
data.push(order);
order.id = order_id;
data[order_id] = order;
});
/*jslint unparam: true */
function orderHtmlRenderer(instance, td, row, col, prop, value, cellProperties) {
var a, color = "yellow";
......@@ -89,7 +91,7 @@
if (value.delay > 0.5) {
color = "red";
}
$(td).css({"background-color": color});
$(td).text("").css({"background-color": color});
a = $("<a>").attr("href", value.link)
.text(value.completionDate + "\n" + (value.delay || 0).toFixed(0))
.css({color: "black", "text-shadow": "none"});
......@@ -98,13 +100,17 @@
return td;
}
for (i=1; i < data[0].length; i+=1) {
colHeaders.push(json_result.result_list[i-1].name || ("Solution #" + i));
columns.push({data: i, renderer: orderHtmlRenderer});
for (i=0; i < general_json.result_list.length; i+=1) {
colHeaders.push(general_json.result_list[i].name || ("Solution #" + (i+1)));
columns.push({data: general_json.result_list[i].name || i, renderer: orderHtmlRenderer});
}
Object.keys(data).forEach(function(order_id) {
data_list.push(order_lateness[order_id]);
});
return tableeditor.render(
JSON.stringify(data),
JSON.stringify(data_list),
{
colHeaders: colHeaders,
columns: columns,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment