Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

Commit

Permalink
fix(pi): JavaScript error when a PI does not exists
Browse files Browse the repository at this point in the history
Closes #DOST05-582
  • Loading branch information
kdaimiel committed Jan 24, 2018
1 parent d468f88 commit 1011b66
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ <h3 class="title-desc" rv-hide="programIncrement.features">No data for PI</h3>
}


model.programIncrement.products.forEach(function(product) {
model.programIncrement.products && model.programIncrement.products.forEach(function(product) {
//All product should take the same space, so we take a count of
//per product totals to use them as factor
let productStories = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ var ProgramIncrementController = (
}

this.getProgramIncrementStatus = function (programIncrement) {
if(!programIncrement) return;
if(!programIncrement || !programIncrement.endDate) return;

var totalWorkingDays = Utils.getWorkingDays(programIncrement.startDate,programIncrement.endDate);
var remainingWorkingDays = programIncrement.getDaysLeft();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,36 +90,41 @@ <h2 class="title" rv-hide="programIncrement.features">No data for PI</h2>
let format = "MMMM Do";

model.programIncrement = data;
model.daysLeft = data.getDaysLeft();

if(data.endDate) {
model.daysLeft = data.getDaysLeft();
}

if (data.startDate){
model.dateRange = moment(data.startDate).format(format) + ' - ' + moment(data.endDate).format(format);
}

model.items = [];
var remain = 100;


for(var i in order) {
var width = 100 * data.report.perStatus[i] / data.report.totalEstimate;
if(width) {
remain -= width;
if(!model.items[i]) {
model.items.push({
status: i,
width: width
});
} else {
model.items[i].width += width;
if(data.report) {

model.items = [];
var remain = 100;

for(var i in order) {
var width = 100 * data.report.perStatus[i] / data.report.totalEstimate;
if(width) {
remain -= width;
if(!model.items[i]) {
model.items.push({
status: i,
width: width
});
} else {
model.items[i].width += width;
}
}
}
}

if(remain && remain > 0.01) {
model.items.push({
status: 'remain',
width: remain
});
if(remain && remain > 0.01) {
model.items.push({
status: 'remain',
width: remain
});
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions mirrorgate-dashboard/test/mocks/dashboards/empty/details
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"boards": [
"empty"
],
"programIncrement": "empty",
"applications": ["empty"],
"slackTeam": "empty",
"urlAlerts": "dashboards/empty/alerts",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions mirrorgate-dashboard/test/mocks/dashboards/errors/details
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"boards": [
"error"
],
"programIncrement": "error",
"applications": ["error"],
"slackTeam":"error",
"urlAlerts": "error",
Expand Down

0 comments on commit 1011b66

Please sign in to comment.