Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc reviewer dashboard - sorting bug fix #36

Merged
merged 12 commits into from
Jul 25, 2023
17 changes: 13 additions & 4 deletions web/app/routes/authenticated/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,30 @@ export default class DashboardRoute extends Route {
this.recentDocs.all = null;
}
}



docsWaitingForReview._result = docsWaitingForReview._result.sort((a, b) => {
// Use optional chaining to access the 'dueDate' property safely
const dueDateA = a.dueDate?.toString()||"";
const dueDateB = b.dueDate?.toString()||"";

// Check if 'dueDate' property exists in both 'a' and 'b'
if (a.dueDate && b.dueDate) {
return a.dueDate.localeCompare(b.dueDate);
} else if (a.dueDate) {
if (dueDateA && dueDateB) {
return dueDateA.localeCompare(dueDateB);
} else if (dueDateA) {
// If 'dueDate' exists in 'a' but not in 'b', consider 'a' to come before 'b'
return -1;
} else if (b.dueDate) {
} else if (dueDateB) {

// If 'dueDate' exists in 'b' but not in 'a', consider 'b' to come before 'a'
return 1;
} else {
// If 'dueDate' doesn't exist in both 'a' and 'b', maintain their original order
return 0;
}
});

return RSVP.hash({
docsWaitingForReview: docsWaitingForReview,
});
Expand Down
15 changes: 10 additions & 5 deletions web/app/routes/authenticated/waiting-for-me.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,26 @@ export default class WaitingForMeRoute extends Route {
}

docsWaitingForReview._result = docsWaitingForReview._result.sort((a, b) => {

// Use optional chaining to access the 'dueDate' property safely
const dueDateA = a.dueDate?.toString()||"";
const dueDateB = b.dueDate?.toString()||"";

// Check if 'dueDate' property exists in both 'a' and 'b'
if (a.dueDate && b.dueDate) {
return a.dueDate.localeCompare(b.dueDate);
} else if (a.dueDate) {
if (dueDateA && dueDateB) {
return dueDateA.localeCompare(dueDateB);
} else if (dueDateA) {
// If 'dueDate' exists in 'a' but not in 'b', consider 'a' to come before 'b'
return -1;
} else if (b.dueDate) {
} else if (dueDateB) {
// If 'dueDate' exists in 'b' but not in 'a', consider 'b' to come before 'a'
return 1;
} else {
// If 'dueDate' doesn't exist in both 'a' and 'b', maintain their original order
return 0;
}
});

return RSVP.hash({
docsWaitingForReview: docsWaitingForReview,
docsReviewed: docsReviewed,
Expand Down
Loading