NDD-54, NDD-46, NDD-53

This commit is contained in:
Dante
2015-04-27 16:15:06 -04:00
parent 4a56af1e35
commit 7705a9852a
5 changed files with 175 additions and 149 deletions

View File

@@ -164,24 +164,7 @@ ViewDashboardPresenter.prototype.peiViewModel = function(data) {
"inefficiencyCost" : "value"
};
var newObject = that.helper.merge(originalObject, {}, map);
var shortLabel = (newObject.datalabel == null)
? ""
: newObject.datalabel.substring(0,15);
newObject.datalabel = shortLabel;
//use positive values for drawing;
if (newObject.value > 0) {
newObject.value = 0;
}
if (newObject.value < 0) {
newObject.value = Math.abs(newObject.value);
}
if (newObject.value > 0) {
graphData.push(newObject);
}
graphData.push(newObject);
originalObject.inefficiencyCostToShow = "$ " + Math.round(originalObject.inefficiencyCost);
originalObject.efficiencyIndexToShow = Math.round(originalObject.efficiencyIndex * 100) / 100;
originalObject.indicatorId = data.id;
@@ -190,13 +173,9 @@ ViewDashboardPresenter.prototype.peiViewModel = function(data) {
var retval = {};
retval = data;
graphData.sort(function(a,b) {
var retval = 0;
retval = ((a.value*1.0 <= b.value*1.0) ? -1 : 1);
return retval;
})
retval.dataToDraw = graphData.splice(0,7);
this.makeShortLabel(graphData, 12);
retval.dataToDraw = this.adaptGraphData(graphData);
//TODO aumentar el símbolo de moneda $
retval.inefficiencyCostToShow = "$ " +Math.round(retval.inefficiencyCost);
@@ -216,22 +195,7 @@ ViewDashboardPresenter.prototype.ueiViewModel = function(data) {
"deviationTime" : "dispersion"
};
var newObject = that.helper.merge(originalObject, {}, map);
var shortLabel = (newObject.datalabel == null)
? ""
: newObject.datalabel.substring(0,7);
newObject.datalabel = shortLabel;
//use positive values for drawing;
if (newObject.value > 0) {
newObject.value = 0;
}
if (newObject.value < 0) {
newObject.value = Math.abs(newObject.value);
}
if (newObject.value > 0) {
graphData.push(newObject);
}
graphData.push(newObject);
originalObject.inefficiencyCostToShow = "$ " + Math.round(originalObject.inefficiencyCost);
originalObject.efficiencyIndexToShow = Math.round(originalObject.efficiencyIndex * 100) / 100;
originalObject.indicatorId = data.id;
@@ -240,12 +204,8 @@ ViewDashboardPresenter.prototype.ueiViewModel = function(data) {
var retval = {};
retval = data;
graphData.sort(function(a,b) {
var retval = 0;
retval = ((a.value*1.0 <= b.value*1.0) ? 1 : -1);
return retval;
})
retval.dataToDraw = graphData.splice(0,7);
this.makeShortLabel(graphData, 10);
retval.dataToDraw = this.adaptGraphData(graphData);
//TODO aumentar el símbolo de moneda $
retval.inefficiencyCostToShow = "$ " + Math.round(retval.inefficiencyCost);
@@ -268,15 +228,15 @@ ViewDashboardPresenter.prototype.statusViewModel = function(indicatorId, data) {
//TODO Do not use the str. replace when color and lable in pie 2D is solved.
var newObject1 = {
datalabel : title.trim().replace(" ", "_"),
datalabel : title,
value : originalObject.percentageTotalOverdue
};
var newObject2 = {
datalabel : title.trim().replace(" ", "_"),
datalabel : title,
value : originalObject.percentageTotalAtRisk
};
var newObject3 = {
datalabel : title.trim().replace(" ", "_"),
datalabel : title,
value : originalObject.percentageTotalOnTime
};
@@ -299,7 +259,6 @@ ViewDashboardPresenter.prototype.statusViewModel = function(indicatorId, data) {
retval.graph2Data = this.orderGraphData(graph2Data, "down").splice(0,7)
retval.graph3Data = this.orderGraphData(graph3Data, "down").splice(0,7)
//TODO correct 2D Pie so we don't depend on label name
$.each(retval.graph1Data, function(index, item) { item.datalabel = (index + 1) + "." + item.datalabel; });
$.each(retval.graph2Data, function(index, item) { item.datalabel = (index + 1) + "." + item.datalabel; });
$.each(retval.graph3Data, function(index, item) { item.datalabel = (index + 1) + "." + item.datalabel; });
@@ -370,29 +329,15 @@ ViewDashboardPresenter.prototype.returnIndicatorSecondLevelPei = function(modelD
"deviationTime" : "dispersion"
};
var newObject = that.helper.merge(originalObject, {}, map);
newObject.datalabel = ((newObject.datalabel == null) ? "" : newObject.datalabel.substring(0, 7));
originalObject.inefficiencyCostToShow = "$ " + Math.round(originalObject.inefficiencyCost);
originalObject.efficiencyIndexToShow = Math.round(originalObject.efficiencyIndex * 100) / 100;
originalObject.deviationTimeToShow = Math.round(originalObject.deviationTime);
//use positive values for drawing;
if (newObject.value > 0) {
newObject.value = 0;
}
if (newObject.value < 0) {
newObject.value = Math.abs(newObject.value);
}
if (newObject.value > 0) {
graphData.push(newObject);
}
originalObject.rankToShow = originalObject.rank + "/" + modelData.length;
graphData.push(newObject);
});
var retval = {};
graphData.sort(function(a,b) {
var retval = 0;
retval = ((a.value*1.0 <= b.value*1.0) ? 1 : -1);
return retval;
})
retval.dataToDraw = graphData.splice(0,7);
this.makeShortLabel(graphData, 10);
retval.dataToDraw = this.adaptGraphData(graphData);
retval.entityData = modelData;
return retval;
};
@@ -411,30 +356,16 @@ ViewDashboardPresenter.prototype.returnIndicatorSecondLevelUei = function(modelD
"deviationTime" : "dispersion"
};
var newObject = that.helper.merge(originalObject, {}, map);
newObject.datalabel = ((newObject.datalabel == null) ? "" : newObject.datalabel.substring(0, 7));
originalObject.inefficiencyCostToShow = "$ " +Math.round(originalObject.inefficiencyCost);
originalObject.efficiencyIndexToShow = Math.round(originalObject.efficiencyIndex * 100) / 100;
originalObject.deviationTimeToShow = Math.round(originalObject.deviationTime);
//use positive values for drawing;
if (newObject.value > 0) {
newObject.value = 0;
}
if (newObject.value < 0) {
newObject.value = Math.abs(newObject.value);
}
if (newObject.value > 0) {
graphData.push(newObject);
}
originalObject.rankToShow = originalObject.rank + "/" + modelData.length;
graphData.push(newObject);
});
var retval = {};
graphData.sort(function(a,b) {
var retval = 0;
retval = ((a.value*1.0 <= b.value*1.0) ? 1 : -1);
return retval;
})
retval.dataToDraw = graphData.splice(0,7);
this.makeShortLabel(graphData, 10);
retval.dataToDraw = this.adaptGraphData(graphData);
retval.entityData = modelData;
return retval;
};
@@ -479,3 +410,33 @@ ViewDashboardPresenter.prototype.orderGraphData = function(listData, orderDirect
}
return listData.sort(orderToUse);
}
ViewDashboardPresenter.prototype.adaptGraphData = function(listData) {
var workList = this.orderGraphData(listData, "up");
var newList = [];
$.each(workList, function(index, item) {
item.datalabel = (index + 1) + "." + item.datalabel;
//use positive values for drawing;
if (item.value > 0) {
item.value = 0;
}
if (item.value < 0) {
item.value = Math.abs(item.value);
}
if (item.value > 0) {
newList.push(item);
}
});
return newList.splice(0,7);
}
ViewDashboardPresenter.prototype.makeShortLabel = function(listData, labelLength) {
$.each(listData, function(index, item) {
var shortLabel = (item.datalabel == null)
? ""
: item.datalabel.substring(0,labelLength);
item.datalabel = shortLabel;
item.datalabel = shortLabel;
});
}

View File

@@ -141,13 +141,41 @@ WidgetBuilder.prototype.buildSpecialIndicatorSecondView = function (secondViewDa
return $retval;
};
WidgetBuilder.prototype.buildSpecialIndicatorSecondViewDetail = function (oneItemDetail) {
WidgetBuilder.prototype.buildSpecialIndicatorSecondViewDetailPei = function (oneItemDetail) {
if (oneItemDetail == null){throw new Error("oneItemDetail is null ");}
if (!typeof(oneItemDetail) === 'object'){throw new Error( "detailData is not and object ->" + oneItemDetail);}
if (!oneItemDetail.hasOwnProperty("name")){throw new Error("buildSpecialIndicatorFirstViewDetail -> detailData has not the name param. Has it the correct Type? ->" + oneItemDetail);}
_.templateSettings.variable = "detailData";
var template = _.template ($("script.specialIndicatorSencondViewDetail").html());
var template = _.template ($("script.specialIndicatorSecondViewDetailPei").html());
var $retval = $(template(oneItemDetail));
$retval.find(".detail-efficiency-selector").text(G_STRING.ID_EFFICIENCY_INDEX);
$retval.find(".detail-cost-selector").text(G_STRING.ID_INEFFICIENCY_COST);
this.setColorForInefficiency($retval.find(".detail-cost-number-selector"), oneItemDetail);
return $retval;
}
WidgetBuilder.prototype.buildSpecialIndicatorSecondViewDetailUei = function (oneItemDetail) {
if (oneItemDetail == null){throw new Error("oneItemDetail is null ");}
if (!typeof(oneItemDetail) === 'object'){throw new Error( "detailData is not and object ->" + oneItemDetail);}
if (!oneItemDetail.hasOwnProperty("name")){throw new Error("buildSpecialIndicatorFirstViewDetail -> detailData has not the name param. Has it the correct Type? ->" + oneItemDetail);}
_.templateSettings.variable = "detailData";
var template = _.template ($("script.specialIndicatorSecondViewDetailUei").html());
var $retval = $(template(oneItemDetail));
$retval.find(".detail-efficiency-selector").text(G_STRING.ID_EFFICIENCY_INDEX);
$retval.find(".detail-cost-selector").text(G_STRING.ID_INEFFICIENCY_COST);
this.setColorForInefficiency($retval.find(".detail-cost-number-selector"), oneItemDetail);
return $retval;
}
WidgetBuilder.prototype.buildSpecialIndicatorSecondViewDetaiUei = function (oneItemDetail) {
if (oneItemDetail == null){throw new Error("oneItemDetail is null ");}
if (!typeof(oneItemDetail) === 'object'){throw new Error( "detailData is not and object ->" + oneItemDetail);}
if (!oneItemDetail.hasOwnProperty("name")){throw new Error("buildSpecialIndicatorFirstViewDetail -> detailData has not the name param. Has it the correct Type? ->" + oneItemDetail);}
_.templateSettings.variable = "detailData";
var template = _.template ($("script.specialIndicatorSencondViewDetailUei").html());
var $retval = $(template(oneItemDetail));
$retval.find(".detail-efficiency-selector").text(G_STRING.ID_EFFICIENCY_INDEX);
$retval.find(".detail-cost-selector").text(G_STRING.ID_INEFFICIENCY_COST);
@@ -281,6 +309,7 @@ $(document).ready(function() {
'height': item.height <= 1 ? 2 : item.height
}
widgets.push(widgetsObj);
console.log(widgetsObj);
}
});
@@ -587,8 +616,8 @@ var fillSpecialIndicatorFirstView = function(presenterData) {
graph: {
allowDrillDown:false,
allowTransition:true,
axisX:{ showAxis: true, label: G_STRING.ID_GROUPS},
axisY:{ showAxis: true, label: G_STRING.ID_COSTS},
axisX:{ showAxis: true, label: "Group" },
axisY:{ showAxis: true, label: "Cost" },
gridLinesX:false,
gridLinesY:true,
showTip: true,
@@ -669,8 +698,8 @@ var fillSpecialIndicatorSecondView = function(presenterData) {
gridLinesX: true,
gridLinesY: true,
area: {visible: false, css:"area"},
axisX:{ showAxis: true, label: G_STRING.ID_USER },
axisY:{ showAxis: true, label: G_STRING.ID_COSTS },
axisX:{ showAxis: true, label: "User" },
axisY:{ showAxis: true, label: "Cost" },
showErrorBars: true
}
@@ -679,7 +708,7 @@ var fillSpecialIndicatorSecondView = function(presenterData) {
var indicatorPrincipalData = widgetBuilder.getIndicatorLoadedById(window.currentEntityData.indicatorId);
if (window.currentIndicator.type == "1010") {
detailParams.graph.axisX.label = G_STRING.ID_TASK;
detailParams.graph.axisX.label = "Task";
var graph = new BarChart(presenterData.dataToDraw, detailParams, null, null);
graph.drawChart();
}
@@ -704,7 +733,14 @@ var fillSpecialIndicatorSecondViewDetail = function (list) {
window.currentDetailFunction = fillSpecialIndicatorSecondViewDetail;
$.each(list, function(index, dataItem) {
var $widget = widgetBuilder.buildSpecialIndicatorSecondViewDetail(dataItem);
if (window.currentIndicator.type == "1010") {
var $widget = widgetBuilder.buildSpecialIndicatorSecondViewDetailPei(dataItem);
}
if (window.currentIndicator.type == "1030") {
var $widget = widgetBuilder.buildSpecialIndicatorSecondViewDetailUei(dataItem);
}
var x = (index % 2 == 0) ? 6 : 0;
//the first 2 elements are not hidden
if (index < 2) {
@@ -788,7 +824,7 @@ var fillGeneralIndicatorFirstView = function (presenterData) {
allowDrillDown:false,
allowTransition:true,
axisX:{ showAxis: true, label: G_STRING.ID_YEAR },
axisY:{ showAxis: true, label: G_STRING.ID_COSTS},
axisY:{ showAxis: true, label: "Q" },
gridLinesX:false,
gridLinesY:true,
showTip: true,
@@ -810,7 +846,7 @@ var fillGeneralIndicatorFirstView = function (presenterData) {
allowDrillDown:false,
allowTransition:true,
axisX:{ showAxis: true, label: G_STRING.ID_YEAR },
axisY:{ showAxis: true, label: G_STRING.ID_COSTS },
axisY:{ showAxis: true, label: "Q" },
gridLinesX:false,
gridLinesY:true,
showTip: true,