Skip to content

Commit

Permalink
Update targets dates from admin->reporting UI #3386
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisala committed Jan 22, 2025
1 parent def707f commit 8f010aa
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions grails-app/assets/javascripts/organisation.js
Original file line number Diff line number Diff line change
Expand Up @@ -705,21 +705,26 @@ OrganisationPageViewModel = function (props, options) {
return;
}

// The end date will be set to midnight at the start of the day because the datepicker
// isn't supplying the time. This causes issues with the display of the end date of the final
// report because the final report end date is fudged because project end dates are a day early.
// Setting a time of 23:59:59 fixes this.
var periodEnd = moment(self.endDate());
periodEnd.set('hour', 23);
periodEnd.set('minute', 59);
periodEnd.set('second', 59);
var periodEndString = periodEnd.toDate().toISOStringNoMillis();

_.each(currentConfig.organisationReports, function(reportCategory) {
reportCategory.periodStart = self.startDate();

// The end date will be set to midnight at the start of the day because the datepicker
// isn't supplying the time. This causes issues with the display of the end date of the final
// report because the final report end date is fudged because project end dates are a day early.
// Setting a time of 23:59:59 fixes this.
var periodEnd = moment(self.endDate());
periodEnd.set('hour', 23);
periodEnd.set('minute', 59);
periodEnd.set('second', 59);

reportCategory.periodEnd = periodEnd.toDate().toISOStringNoMillis();
reportCategory.periodEnd = periodEndString;
});

if (currentConfig.targets && currentConfig.targets.periodGenerationConfig) {
currentConfig.targets.periodGenerationConfig.periodStart = self.startDate();
currentConfig.targets.periodGenerationConfig.periodEnd = periodEndString;
}

blockUIWithMessage("Saving configuration...");
self.saveConfig(currentConfig).done(function() {
blockUIWithMessage("Configuration saved. Reloading page...");
Expand Down

0 comments on commit 8f010aa

Please sign in to comment.