Skip to content

Commit

Permalink
Merge pull request #3326 from AtlasOfLivingAustralia/feature/issue2954
Browse files Browse the repository at this point in the history
Updates to the report status column in My Projects #2954
  • Loading branch information
salomon-j authored Sep 16, 2024
2 parents 8a49cb2 + 52a0681 commit 143a7d1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 30 deletions.
7 changes: 2 additions & 5 deletions grails-app/assets/javascripts/meriplan.js
Original file line number Diff line number Diff line change
Expand Up @@ -2496,13 +2496,13 @@ var Report = function (report) {
};

self.isDue = function () {
return report.activityCount > 0 && report.publicationStatus != 'pendingApproval' &&
return report.publicationStatus != 'pendingApproval' &&
report.publicationStatus != 'published' &&
toDate < now && (!dueDate || dueDate >= now); // Due date is temporarily optional.
};

self.isOverdue = function () {
return report.activityCount > 0 && report.publicationStatus != 'pendingApproval' &&
return report.publicationStatus != 'pendingApproval' &&
report.publicationStatus != 'published' &&
dueDate && dueDate < now;
};
Expand All @@ -2525,9 +2525,6 @@ var Report = function (report) {
if (self.isCurrent()) {
return name + ' in progress';
}
if (report.activityCount == 0) {
return name + ' has no activities to report';
}

return '';
};
Expand Down
47 changes: 22 additions & 25 deletions grails-app/assets/javascripts/my-projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,45 +22,41 @@ var ProjectReportsViewModel = function (project) {

var currentReport = null;

_.sortBy(project.reports, function(report) { return report.toDate });

if (project.reports) {
for (var i = 0; i < project.reports.length; i++) {

var report = new Report(project.reports[i]);
self.reports.push(report);
if (!currentReport) {
currentReport = report;
}

// Rule for "current" report is:
// 1) Any report awaiting action. (Overdue > Submitted).
// 2) Current stage.

if (report.isOverdue()) {
currentReport = report;
} else if (report.isSubmitted() && !currentReport.isOverdue()) {
currentReport = report;
} else if (report.isDue() && !currentReport.isOverdue() && !currentReport.isSubmitted()) {
currentReport = report;
} else if (report.isCurrent() && !currentReport.isDue() && !currentReport.isOverdue() && !currentReport.isSubmitted()) {
currentReport = report;
}

if (report.isSubmitted() || report.isApproved()) {
self.submittedReportCount++;
reportingTimeSum += report.submissionDelta();
}


}

for (var i = 0; i < self.reports.length; i++) {
var report = self.reports[i];
if (report.isOverdue() || report.isSubmitted() || report.isDue()) {
if (report !== currentReport) {
if (!currentReport) {
currentReport = report;
}
else {
self.extendedStatus.push(report.status());
}
}
}

if (!currentReport) {
var reports = _.filter(self.reports, function(report) {
return report.isCurrent();
});
if (reports.length > 0) {
currentReport = reports[0];

if (reports.length > 1) {
for (var i= 0; i<reports.length; i++) {
self.extendedStatus.push(reports[i].status());
}
}
}
}
}


Expand Down Expand Up @@ -90,6 +86,7 @@ var ProjectReportsViewModel = function (project) {
self.historyVisible = ko.observable(false);

self.currentStatus = function () {

if (currentReport) {
return currentReport.status();
}
Expand Down

0 comments on commit 143a7d1

Please sign in to comment.