From 8f010aac073de40334ca4e8e6e11eccf1c0a49dc Mon Sep 17 00:00:00 2001 From: chrisala Date: Thu, 23 Jan 2025 09:26:15 +1100 Subject: [PATCH] Update targets dates from admin->reporting UI #3386 --- grails-app/assets/javascripts/organisation.js | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/grails-app/assets/javascripts/organisation.js b/grails-app/assets/javascripts/organisation.js index 40ebf051f..f531e1967 100644 --- a/grails-app/assets/javascripts/organisation.js +++ b/grails-app/assets/javascripts/organisation.js @@ -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...");