tickets 2787, 3063, 3001, 3061
This commit is contained in:
@@ -71,13 +71,16 @@ TimeSeriesPresenter.prototype.indicatorList = function (dashboardId) {
|
||||
var that = this;
|
||||
var requestFinished = $.Deferred();
|
||||
var dummyDate = this.helper.date2MysqlString(new Date());
|
||||
var indicatorsAllowed = [1010, 1030];
|
||||
this.model.indicatorList(dashboardId, dummyDate, dummyDate).done(function (data) {
|
||||
var newArray = [];
|
||||
$.each(data, function(index, originalObject) {
|
||||
var newObject = {label: originalObject.DAS_IND_TITLE,
|
||||
value: originalObject.DAS_IND_UID
|
||||
}
|
||||
newArray.push(newObject);
|
||||
if (indicatorsAllowed.indexOf(originalObject.DAS_IND_TYPE*1) >= 0) {
|
||||
var newObject = {label: originalObject.DAS_IND_TITLE,
|
||||
value: originalObject.DAS_IND_UID
|
||||
}
|
||||
newArray.push(newObject);
|
||||
}
|
||||
});
|
||||
|
||||
requestFinished.resolve(newArray);
|
||||
@@ -144,8 +147,8 @@ TimeSeriesPresenter.prototype.historicData = function (indicator, periodicity, i
|
||||
initYear, endPeriod, endYear) {
|
||||
var that = this;
|
||||
var requestFinished = $.Deferred();
|
||||
var initDate = this.periodInitDate(periodicity, initPeriod, initYear);
|
||||
var endDate = this.periodEndDate(periodicity, endPeriod, endYear);
|
||||
var initDate = this.helper.periodInitDate(periodicity, initPeriod, initYear);
|
||||
var endDate = this.helper.periodEndDate(periodicity, endPeriod, endYear);
|
||||
this.model.historicData(indicator, periodicity, initDate, endDate).done(function (data) {
|
||||
var graphData = [];
|
||||
$.each(data, function(index, originalObject) {
|
||||
@@ -235,8 +238,8 @@ TimeSeriesPresenter.prototype.periodEquivalentFromDate = function (periodicity,
|
||||
switch (periodicity * 1) {
|
||||
case this.helper.ReportingPeriodicityEnum.MONTH:
|
||||
for (var i = 1; i < 12; i++) {
|
||||
var periodInitDate = this.periodInitDate (periodicity, i, year);
|
||||
var periodEndDate = this.periodEndDate (periodicity, i, year);
|
||||
var periodInitDate = this.helper.periodInitDate (periodicity, i, year);
|
||||
var periodEndDate = this.helper.periodEndDate (periodicity, i, year);
|
||||
if (periodInitDate <= date && periodEndDate >= date) {
|
||||
retval = i;
|
||||
}
|
||||
@@ -244,8 +247,8 @@ TimeSeriesPresenter.prototype.periodEquivalentFromDate = function (periodicity,
|
||||
break;
|
||||
case this.helper.ReportingPeriodicityEnum.QUARTER:
|
||||
for (var i = 1; i < 4; i++) {
|
||||
var periodInitDate = this.periodInitDate (periodicity, i, year);
|
||||
var periodEndDate = this.periodEndDate (periodicity, i, year);
|
||||
var periodInitDate = this.helper.periodInitDate (periodicity, i, year);
|
||||
var periodEndDate = this.helper.periodEndDate (periodicity, i, year);
|
||||
if (periodInitDate <= date && periodEndDate >= date) {
|
||||
retval = i;
|
||||
}
|
||||
@@ -253,8 +256,8 @@ TimeSeriesPresenter.prototype.periodEquivalentFromDate = function (periodicity,
|
||||
break;
|
||||
case this.helper.ReportingPeriodicityEnum.SEMESTER:
|
||||
for (var i = 1; i < 2; i++) {
|
||||
var periodInitDate = this.periodInitDate (periodicity, i, year);
|
||||
var periodEndDate = this.periodEndDate (periodicity, i, year);
|
||||
var periodInitDate = this.helper.periodInitDate (periodicity, i, year);
|
||||
var periodEndDate = this.helper.periodEndDate (periodicity, i, year);
|
||||
if (periodInitDate <= date && periodEndDate >= date) {
|
||||
retval = i;
|
||||
}
|
||||
@@ -270,49 +273,3 @@ TimeSeriesPresenter.prototype.periodEquivalentFromDate = function (periodicity,
|
||||
return retval;
|
||||
}
|
||||
|
||||
TimeSeriesPresenter.prototype.periodInitDate = function (periodicity, period, year) {
|
||||
var retval = null;
|
||||
switch (periodicity * 1) {
|
||||
case this.helper.ReportingPeriodicityEnum.MONTH:
|
||||
retval = new Date(year, period - 1, 1);
|
||||
break;
|
||||
case this.helper.ReportingPeriodicityEnum.QUARTER:
|
||||
retval = new Date(year, 3 * (period-1), 1);
|
||||
break;
|
||||
case this.helper.ReportingPeriodicityEnum.SEMESTER:
|
||||
retval = new Date(year, 6 * (period-1), 1);
|
||||
break;
|
||||
case this.helper.ReportingPeriodicityEnum.YEAR:
|
||||
retval = new Date(year, 0, 1);
|
||||
break;
|
||||
}
|
||||
if (retval == null) {
|
||||
throw new Error("The periodicity " + periodicity + " is not supported.");
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
TimeSeriesPresenter.prototype.periodEndDate = function (periodicity, period, year) {
|
||||
var retval = null;
|
||||
switch (periodicity * 1) {
|
||||
case this.helper.ReportingPeriodicityEnum.MONTH:
|
||||
retval = new Date(year, period, 0, 23,59,59);
|
||||
break;
|
||||
case this.helper.ReportingPeriodicityEnum.QUARTER:
|
||||
retval = new Date(year, 3 * (period), 0, 23, 59, 59);
|
||||
break;
|
||||
case this.helper.ReportingPeriodicityEnum.SEMESTER:
|
||||
retval = new Date(year, 6 * (period), 0, 23, 59, 59);
|
||||
break;
|
||||
case this.helper.ReportingPeriodicityEnum.YEAR:
|
||||
retval = new Date(year, 11, 31, 23, 59, 59);
|
||||
break;
|
||||
}
|
||||
if (retval == null) {
|
||||
throw new Error("The periodicity " + periodicity + " is not supported.");
|
||||
}
|
||||
return retval;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -323,3 +323,61 @@ ViewDashboardHelper.prototype.putInCache = function (endPoint, data) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
ViewDashboardHelper.prototype.periodInitDate = function (periodicity, period, year) {
|
||||
var retval = null;
|
||||
switch (periodicity * 1) {
|
||||
case this.ReportingPeriodicityEnum.MONTH:
|
||||
retval = new Date(year, period - 1, 1);
|
||||
break;
|
||||
case this.ReportingPeriodicityEnum.QUARTER:
|
||||
retval = new Date(year, 3 * (period-1), 1);
|
||||
break;
|
||||
case this.ReportingPeriodicityEnum.SEMESTER:
|
||||
retval = new Date(year, 6 * (period-1), 1);
|
||||
break;
|
||||
case this.ReportingPeriodicityEnum.YEAR:
|
||||
retval = new Date(year, 0, 1);
|
||||
break;
|
||||
}
|
||||
if (retval == null) {
|
||||
throw new Error("The periodicity " + periodicity + " is not supported.");
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
ViewDashboardHelper.prototype.periodEndDate = function (periodicity, period, year) {
|
||||
var retval = null;
|
||||
switch (periodicity * 1) {
|
||||
case this.ReportingPeriodicityEnum.MONTH:
|
||||
retval = new Date(year, period, 0, 23,59,59);
|
||||
break;
|
||||
case this.ReportingPeriodicityEnum.QUARTER:
|
||||
retval = new Date(year, 3 * (period), 0, 23, 59, 59);
|
||||
break;
|
||||
case this.ReportingPeriodicityEnum.SEMESTER:
|
||||
retval = new Date(year, 6 * (period), 0, 23, 59, 59);
|
||||
break;
|
||||
case this.ReportingPeriodicityEnum.YEAR:
|
||||
retval = new Date(year, 11, 31, 23, 59, 59);
|
||||
break;
|
||||
}
|
||||
if (retval == null) {
|
||||
throw new Error("The periodicity " + periodicity + " is not supported.");
|
||||
}
|
||||
return retval;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
ViewDashboardHelper.prototype.unescape = function (string) {
|
||||
var temp = document.createElement("div");
|
||||
temp.innerHTML = string;
|
||||
var result = temp.childNodes[0].nodeValue;
|
||||
temp.removeChild(temp.firstChild);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ ViewDashboardPresenter.prototype.dashboardIndicatorsViewModel = function(data) {
|
||||
: "normal";
|
||||
|
||||
//rounding
|
||||
newObject.comparative = Math.round(newObject.comparative*100)/100;
|
||||
newObject.comparative = Math.round(newObject.comparative * 100)/100;
|
||||
newObject.comparative = ((newObject.comparative > 0) ? "+": "") + newObject.comparative;
|
||||
|
||||
newObject.percentComparative = (newObject.percentComparative != '--')
|
||||
@@ -141,6 +141,7 @@ ViewDashboardPresenter.prototype.setStatusButtonWidthsAndDisplayValues = functio
|
||||
var minPercent = 10;
|
||||
var barsLessThanMin = [];
|
||||
var barsNormal = [];
|
||||
var barsNonZero = [];
|
||||
|
||||
var classifyBar = function (bar) {
|
||||
if (bar.valueRounded <= minPercent && bar.valueRounded > 0) {
|
||||
@@ -150,6 +151,12 @@ ViewDashboardPresenter.prototype.setStatusButtonWidthsAndDisplayValues = functio
|
||||
}
|
||||
}
|
||||
|
||||
var nonZeroBar = function (bar) {
|
||||
if (bar.valueRounded != null && bar.valueRounded > 0) {
|
||||
barsNonZero.push (bar);
|
||||
}
|
||||
}
|
||||
|
||||
var atRisk = {
|
||||
type : "atRisk",
|
||||
value : data.percentageAtRisk,
|
||||
@@ -180,10 +187,39 @@ ViewDashboardPresenter.prototype.setStatusButtonWidthsAndDisplayValues = functio
|
||||
? ""
|
||||
: onTime.valueRounded + "%";
|
||||
|
||||
classifyBar(atRisk);
|
||||
classifyBar(overdue);
|
||||
classifyBar(atRisk);
|
||||
classifyBar(onTime);
|
||||
|
||||
nonZeroBar(overdue);
|
||||
nonZeroBar(atRisk);
|
||||
nonZeroBar(onTime);
|
||||
|
||||
var valuesArray = barsNonZero.map(function (d) { return d.valueRounded; });
|
||||
var completedTo100Sum = 100 - valuesArray.reduce(function(prev, curr, index, array) {
|
||||
var acum = (index == valuesArray.length -1)
|
||||
? prev
|
||||
: prev + curr;
|
||||
return acum;
|
||||
}, 0);
|
||||
|
||||
switch (barsNonZero.length) {
|
||||
case 0:
|
||||
barsNormal [0].valueToShow = "100%";
|
||||
barsNormal [0].valueRounded = 100;
|
||||
break;
|
||||
case 1:
|
||||
barsNonZero[0].valueToShow = "100%";
|
||||
barsNonZero[0].valueRounded = 100;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
barsNonZero[barsNonZero.length - 1].valueToShow = completedTo100Sum + "%";
|
||||
barsNonZero[barsNonZero.length - 1].valueRounded = completedTo100Sum;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
var widthToDivide = 100 - barsLessThanMin.length * minPercent;
|
||||
var normalsSum = 0;
|
||||
$.each (barsNormal, function() {
|
||||
|
||||
@@ -505,7 +505,7 @@ var loadIndicator = function (indicatorId, initDate, endDate) {
|
||||
hideTitleAndSortDiv();
|
||||
$('[data-toggle="tooltip"]').tooltip({
|
||||
animated: 'fade',
|
||||
placement: 'bottom'
|
||||
placement: 'top'
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -538,17 +538,16 @@ var defaultInitDate = function() {
|
||||
var date = new Date();
|
||||
var dateMonth = date.getMonth();
|
||||
var dateYear = date.getFullYear();
|
||||
var initDate = $('#initYearList').val() + '-' + $('#initPeriodList').val() + '-' + '01';
|
||||
return initDate;
|
||||
var initDate = new Date(dateYear, dateMonth, 1);
|
||||
initDate.setMonth(initDate.getMonth() - 1);
|
||||
var retval = $('#initYearList').val() + '-' + (initDate.getMonth() + 1) + '-' + '01';
|
||||
return retval;
|
||||
}
|
||||
|
||||
var defaultEndDate = function () {
|
||||
//TODO use the timeSeries function that finds the last day in the period
|
||||
var date = new Date();
|
||||
var dateMonth = date.getMonth();
|
||||
var dateYear = date.getFullYear();
|
||||
var initDate = $('#endYearList').val() + '-' + $('#endPeriodList').val() + '-' + '30';
|
||||
return initDate;
|
||||
var endDate = helper.periodEndDate ($('#periodicityList').val() , $('#endPeriodList').val() , $('#endYearList').val());
|
||||
var retval = $('#endYearList').val() + '-' + $('#endPeriodList').val() + '-' + endDate.getDate();
|
||||
return retval;
|
||||
}
|
||||
|
||||
var fillDashboardsList = function (presenterData) {
|
||||
@@ -562,7 +561,7 @@ var fillDashboardsList = function (presenterData) {
|
||||
window.loadedDashboards = presenterData;
|
||||
for (key in presenterData) {
|
||||
var dashboard = presenterData[key];
|
||||
dashboard.title = dashboard.title.replace(''', "'");
|
||||
dashboard.title = helper.unescape(dashboard.title);
|
||||
$('#dashboardsList').append(template(dashboard));
|
||||
if (dashboard.isFavorite == 1) {
|
||||
window.currentDashboardId = dashboard.id;
|
||||
@@ -796,6 +795,11 @@ var fillSpecialIndicatorSecondView = function(presenterData) {
|
||||
graph.drawChart();
|
||||
}
|
||||
this.fillSpecialIndicatorSecondViewDetail(presenter.orderDataList(presenterData.entityData, selectedOrderOfDetailList()));
|
||||
$('[data-toggle="tooltip"]').tooltip({
|
||||
animated: 'fade',
|
||||
placement: 'top'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
var fillSpecialIndicatorSecondViewDetail = function (list) {
|
||||
|
||||
Reference in New Issue
Block a user