Skip to content

Commit 0a85acf

Browse files
authored
Merge pull request #3416 from AtlasOfLivingAustralia/feature/issue3386
Update targets dates from admin->reporting UI #3386
2 parents eeb65f0 + 8f010aa commit 0a85acf

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

Diff for: grails-app/assets/javascripts/organisation.js

+16-11
Original file line numberDiff line numberDiff line change
@@ -705,21 +705,26 @@ OrganisationPageViewModel = function (props, options) {
705705
return;
706706
}
707707

708+
// The end date will be set to midnight at the start of the day because the datepicker
709+
// isn't supplying the time. This causes issues with the display of the end date of the final
710+
// report because the final report end date is fudged because project end dates are a day early.
711+
// Setting a time of 23:59:59 fixes this.
712+
var periodEnd = moment(self.endDate());
713+
periodEnd.set('hour', 23);
714+
periodEnd.set('minute', 59);
715+
periodEnd.set('second', 59);
716+
var periodEndString = periodEnd.toDate().toISOStringNoMillis();
717+
708718
_.each(currentConfig.organisationReports, function(reportCategory) {
709719
reportCategory.periodStart = self.startDate();
710-
711-
// The end date will be set to midnight at the start of the day because the datepicker
712-
// isn't supplying the time. This causes issues with the display of the end date of the final
713-
// report because the final report end date is fudged because project end dates are a day early.
714-
// Setting a time of 23:59:59 fixes this.
715-
var periodEnd = moment(self.endDate());
716-
periodEnd.set('hour', 23);
717-
periodEnd.set('minute', 59);
718-
periodEnd.set('second', 59);
719-
720-
reportCategory.periodEnd = periodEnd.toDate().toISOStringNoMillis();
720+
reportCategory.periodEnd = periodEndString;
721721
});
722722

723+
if (currentConfig.targets && currentConfig.targets.periodGenerationConfig) {
724+
currentConfig.targets.periodGenerationConfig.periodStart = self.startDate();
725+
currentConfig.targets.periodGenerationConfig.periodEnd = periodEndString;
726+
}
727+
723728
blockUIWithMessage("Saving configuration...");
724729
self.saveConfig(currentConfig).done(function() {
725730
blockUIWithMessage("Configuration saved. Reloading page...");

0 commit comments

Comments
 (0)