mirror of
https://github.com/wekan/wekan.git
synced 2026-01-31 05:35:16 +01:00
Fix My Due Cards to be sorted by due date, oldest first.
Thanks to xet7 ! Fixes #5956
This commit is contained in:
parent
e29d9dcd17
commit
a540b12895
2 changed files with 23 additions and 7 deletions
|
|
@ -32,7 +32,8 @@ template(name="dueCards")
|
|||
span.global-search-error-messages
|
||||
= msg
|
||||
else
|
||||
+resultsPaged(this)
|
||||
each card in dueCardsList
|
||||
+resultCard(card)
|
||||
|
||||
template(name="dueCardsViewChangePopup")
|
||||
if currentUser
|
||||
|
|
|
|||
|
|
@ -31,6 +31,13 @@ Template.dueCards.helpers({
|
|||
userId() {
|
||||
return Meteor.userId();
|
||||
},
|
||||
dueCardsList() {
|
||||
const component = BlazeComponent.getComponentForElement(this);
|
||||
if (component && component.dueCardsList) {
|
||||
return component.dueCardsList();
|
||||
}
|
||||
return [];
|
||||
},
|
||||
});
|
||||
|
||||
BlazeComponent.extendComponent({
|
||||
|
|
@ -142,18 +149,26 @@ class DueCardsComponent extends CardSearchPagedComponent {
|
|||
});
|
||||
}
|
||||
|
||||
// Sort by due date: oldest first (ascending order)
|
||||
cards.sort((a, b) => {
|
||||
const x = a.dueAt === null ? new Date('2100-12-31') : a.dueAt;
|
||||
const y = b.dueAt === null ? new Date('2100-12-31') : b.dueAt;
|
||||
// Handle null/undefined due dates by putting them at the end
|
||||
const aDueAt = a.dueAt ? new Date(a.dueAt) : new Date('2100-12-31');
|
||||
const bDueAt = b.dueAt ? new Date(b.dueAt) : new Date('2100-12-31');
|
||||
|
||||
if (x > y) return 1;
|
||||
else if (x < y) return -1;
|
||||
// Debug logging
|
||||
if (process.env.DEBUG === 'true') {
|
||||
console.log(`Comparing cards: "${a.title}" (${a.dueAt}) vs "${b.title}" (${b.dueAt})`);
|
||||
console.log(`Parsed dates: ${aDueAt.toISOString()} vs ${bDueAt.toISOString()}`);
|
||||
console.log(`Time difference: ${aDueAt.getTime() - bDueAt.getTime()}`);
|
||||
}
|
||||
|
||||
return 0;
|
||||
// Compare dates: if a is earlier than b, return negative (a comes first)
|
||||
// if a is later than b, return positive (b comes first)
|
||||
return aDueAt.getTime() - bDueAt.getTime();
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('cards:', cards);
|
||||
console.log('cards sorted by due date (oldest first):', cards);
|
||||
return cards;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue