Default compare month[C

This commit is contained in:
Dante
2015-04-29 08:52:32 -04:00
parent 925aa82016
commit ea7e63188f
5 changed files with 71 additions and 39 deletions

View File

@@ -78,7 +78,6 @@ ViewDashboardModel.prototype.getPositionIndicator = function(callBack) {
"y" : originalObject.y,
"width" : originalObject.width,
"height" : originalObject.height
};
graphData.push(map);
});

View File

@@ -90,15 +90,31 @@ ViewDashboardPresenter.prototype.dashboardIndicatorsViewModel = function(data) {
newObject.comparative = Math.round(newObject.comparative*1000)/1000;
newObject.comparative = ((newObject.comparative > 0)? "+": "") + newObject.comparative;
newObject.percentComparative = (newObject.percentComparative != '--')
? '(' + newObject.percentComparative + '%)'
: "";
newObject.value = (newObject.category == "normal")
? Math.round(newObject.value) + ""
: Math.round(newObject.value*100)/100 + ""
newObject.favorite = 0;
newObject.percentageOverdue = Math.round(newObject.percentageOverdue);
newObject.percentageAtRisk = Math.round(newObject.percentageAtRisk);
//to be sure that percentages sum up to 100 (the rounding will lost decimals)%
newObject.percentageOnTime = 100 - newObject.percentageOverdue - newObject.percentageAtRisk;
newObject.percentageOverdueWidth = Math.round(newObject.percentageOverdue);
newObject.percentageAtRiskWidth = Math.round(newObject.percentageAtRisk);
//to be sure that percentages sum up to 100 (the rounding will lose decimals)%
newObject.percentageOnTimeWidth = 100 - newObject.percentageOverdueWidth - newObject.percentageAtRiskWidth;
newObject.percentageOverdueToShow = ((newObject.percentageOverdue == 0 ||newObject.percentageOverdue == null ) ? "" : newObject.percentageOverdueWidth + "%");
newObject.percentageAtRiskToShow = ((newObject.percentageAtRisk == 0 || newObject.percentageAtRisk == null) ? "" : newObject.percentageAtRiskWidth + "%");
newObject.percentageOnTimeToShow = ((newObject.percentageOnTime == 0 || newObject.percentageOnTime == 0)
? G_STRING['ID_INBOX'] + ' ' + G_STRING['ID_EMPTY']
: newObject.percentageOnTimeWidth + "%");
newObject.overdueVisibility = (newObject.percentageOverdue > 0)? "visible" : "hidden";
newObject.atRiskVisibility = (newObject.percentageAtRisk > 0)? "visible" : "hidden";
newObject.onTimeVisibility = (newObject.percentageOnTime > 0)? "visible" : "hidden";

View File

@@ -353,20 +353,17 @@ $(document).ready(function() {
presenter.getDashboardIndicators(dashboardId, defaultInitDate(), defaultEndDate())
.done(function(indicatorsVM) {
fillIndicatorWidgets(indicatorsVM);
//TODO use real data
loadIndicator(getFavoriteIndicator().id, defaultInitDate(), defaultEndDate());
});
});
$('#indicatorsGridStack').on('click','.ind-button-selector', function() {
var indicatorId = $(this).data('indicator-id');
//TODO use real data
loadIndicator(indicatorId, defaultInitDate(), defaultEndDate());
});
$('body').on('click','.bread-back-selector', function() {
var indicatorId = window.currentIndicator.id;
//TODO use real data
loadIndicator(indicatorId, defaultInitDate(), defaultEndDate());
return false;
});
@@ -380,7 +377,6 @@ $(document).ready(function() {
"inefficiencyCost":$(this).data('detail-cost'),
"name":$(this).data('detail-name')
};
//TODO PASS REAL VALUES
presenter.getSpecialIndicatorSecondLevel(detailId, window.currentIndicator.type, defaultInitDate(), defaultEndDate())
.done(function (viewModel) {
fillSpecialIndicatorSecondView(viewModel);
@@ -406,8 +402,15 @@ var hideTitleAndSortDiv = function(){
switch (window.currentIndicator.type) {
case "1010":
case "1030":
$('#relatedLabel').css('visibility', 'visible');
$('#relatedLabel').show();
if($('.detail-button-selector').length == 0) {
$('#relatedLabel').hide();
//$('#relatedLabel').find('h3').text(G_STRING['ID_NO_DATA_TO_DISPLAY']);
}
else {
$('#relatedLabel').css('visibility', 'visible');
$('#relatedLabel').show();
}
break;
default:
$('#relatedLabel').hide();
@@ -419,6 +422,15 @@ var selectedOrderOfDetailList = function () {
return ($('#sortListButton').hasClass('fa-chevron-up') ? "up" : "down");
}
var selectDefaultMonthAndYear = function () {
var compareDate = new Date();
compareDate.setMonth(compareDate.getMonth() - 1);
var compareMonth = compareDate.getMonth() + 1;
var compareYear = compareDate.getYear();
$('#month').val(compareMonth);
$('#year').val(compareYear);
}
var initialDraw = function () {
presenter.getUserDashboards(pageUserId)
.then(function(dashboardsVM) {
@@ -427,6 +439,7 @@ var initialDraw = function () {
/**** window initialization with favorite dashboard*****/
presenter.getDashboardIndicators(window.currentDashboardId, defaultInitDate(), defaultEndDate())
.done(function(indicatorsVM) {
selectDefaultMonthAndYear();
fillIndicatorWidgets(indicatorsVM);
loadIndicator(getFavoriteIndicator().id, defaultInitDate(), defaultEndDate());
});
@@ -523,10 +536,6 @@ var fillIndicatorWidgets = function (presenterData) {
$.each(presenterData, function(key, indicator) {
var $widget = widgetBuilder.getIndicatorWidget(indicator);
grid.add_widget($widget, indicator.toDrawX, indicator.toDrawY, indicator.toDrawWidth, indicator.toDrawHeight, true);
//TODO will exist animation?
/*if (indicator.category == "normal") {
animateProgress(indicator, $widget);
}*/
var $title = $widget.find('.ind-title-selector');
if (indicator.favorite == "1") {
$title.addClass("panel-active");