Fix due dates to use colors: red = overdue, amber = due soon, no shade = not due yet.

Thanks to xet7 !

Fixes #5963
This commit is contained in:
Lauri Ojansivu 2025-10-21 14:47:57 +03:00
parent 7f31d7c812
commit 1aa0d84977
3 changed files with 180 additions and 42 deletions

View file

@ -8,39 +8,72 @@
.card-date.is-active { .card-date.is-active {
background-color: #b3b3b3; background-color: #b3b3b3;
} }
.card-date.current, /* Date status colors - red = overdue, amber = due soon, no shade = not due */
.card-date.almost-due, .card-date.overdue {
.card-date.due, background-color: #ff4444; /* Red for overdue */
.card-date.long-overdue {
color: #fff; color: #fff;
} }
.card-date.overdue:hover,
.card-date.overdue.is-active {
background-color: #cc3333;
}
.card-date.due-soon {
background-color: #ffaa00; /* Amber for due soon */
color: #000;
}
.card-date.due-soon:hover,
.card-date.due-soon.is-active {
background-color: #e69900;
}
.card-date.not-due {
/* No special background - uses default date type colors */
}
.card-date.current { .card-date.current {
background-color: #5ba639; background-color: #5ba639; /* Green for current/active */
color: #fff;
} }
.card-date.current:hover, .card-date.current:hover,
.card-date.current.is-active { .card-date.current.is-active {
background-color: #46802c; background-color: #46802c;
} }
.card-date.almost-due {
background-color: #edc909; .card-date.completed {
background-color: #90ee90; /* Light green for completed */
color: #000;
} }
.card-date.almost-due:hover, .card-date.completed:hover,
.card-date.almost-due.is-active { .card-date.completed.is-active {
background-color: #bc9f07; background-color: #7dd87d;
} }
.card-date.due {
background-color: #fa3f00; .card-date.completed-early {
background-color: #4caf50; /* Green for completed early */
color: #fff;
} }
.card-date.due:hover, .card-date.completed-early:hover,
.card-date.due.is-active { .card-date.completed-early.is-active {
background-color: #c73200; background-color: #45a049;
} }
.card-date.long-overdue {
background-color: #fd5d47; .card-date.completed-late {
background-color: #ff9800; /* Orange for completed late */
color: #fff;
} }
.card-date.long-overdue:hover, .card-date.completed-late:hover,
.card-date.long-overdue.is-active { .card-date.completed-late.is-active {
background-color: #fd3e24; background-color: #f57c00;
}
.card-date.completed-on-time {
background-color: #2196f3; /* Blue for completed on time */
color: #fff;
}
.card-date.completed-on-time:hover,
.card-date.completed-on-time.is-active {
background-color: #1976d2;
} }
/* Date type specific colors */ /* Date type specific colors */

View file

@ -157,14 +157,18 @@ class CardReceivedDate extends CardDate {
const endAt = this.data().getEnd(); const endAt = this.data().getEnd();
const startAt = this.data().getStart(); const startAt = this.data().getStart();
const theDate = this.date.get(); const theDate = this.date.get();
// if dueAt, endAt and startAt exist & are > receivedAt, receivedAt doesn't need to be flagged const now = this.now.get();
// Received date logic: if received date is after start, due, or end dates, it's overdue
if ( if (
(startAt && isAfter(theDate, startAt)) || (startAt && isAfter(theDate, startAt)) ||
(endAt && isAfter(theDate, endAt)) || (endAt && isAfter(theDate, endAt)) ||
(dueAt && isAfter(theDate, dueAt)) (dueAt && isAfter(theDate, dueAt))
) ) {
classes += 'long-overdue'; classes += 'overdue';
else classes += 'current'; } else {
classes += 'not-due';
}
return classes; return classes;
} }
@ -193,16 +197,22 @@ class CardStartDate extends CardDate {
} }
classes() { classes() {
let classes = 'start-date' + ' '; let classes = 'start-date ';
const dueAt = this.data().getDue(); const dueAt = this.data().getDue();
const endAt = this.data().getEnd(); const endAt = this.data().getEnd();
const theDate = this.date.get(); const theDate = this.date.get();
const now = this.now.get(); const now = this.now.get();
// if dueAt or endAt exist & are > startAt, startAt doesn't need to be flagged
if ((endAt && isAfter(theDate, endAt)) || (dueAt && isAfter(theDate, dueAt))) // Start date logic: if start date is after due or end dates, it's overdue
classes += 'long-overdue'; if ((endAt && isAfter(theDate, endAt)) || (dueAt && isAfter(theDate, dueAt))) {
else if (isAfter(theDate, now)) classes += ''; classes += 'overdue';
else classes += 'current'; } else if (isAfter(theDate, now)) {
// Start date is in the future - not due yet
classes += 'not-due';
} else {
// Start date is today or in the past - current/active
classes += 'current';
}
return classes; return classes;
} }
@ -231,17 +241,33 @@ class CardDueDate extends CardDate {
} }
classes() { classes() {
let classes = 'due-date' + ' '; let classes = 'due-date ';
const endAt = this.data().getEnd(); const endAt = this.data().getEnd();
const theDate = this.date.get(); const theDate = this.date.get();
const now = this.now.get(); const now = this.now.get();
// if the due date is after the end date, green - done early
if (endAt && isAfter(theDate, endAt)) classes += 'current'; // If there's an end date and it's before the due date, task is completed early
// if there is an end date, don't need to flag the due date if (endAt && isBefore(endAt, theDate)) {
else if (endAt) classes += ''; classes += 'completed-early';
else if (diff(now, theDate, 'days') >= 2) classes += 'long-overdue'; }
else if (diff(now, theDate, 'minute') >= 0) classes += 'due'; // If there's an end date, don't show due date status since task is completed
else if (diff(now, theDate, 'days') >= -1) classes += 'almost-due'; else if (endAt) {
classes += 'completed';
}
// Due date logic based on current time
else {
const daysDiff = diff(theDate, now, 'days');
if (daysDiff < 0) {
// Due date is in the past - overdue
classes += 'overdue';
} else if (daysDiff <= 1) {
// Due today or tomorrow - due soon
classes += 'due-soon';
} else {
// Due date is more than 1 day away - not due yet
classes += 'not-due';
}
}
return classes; return classes;
} }
@ -270,12 +296,23 @@ class CardEndDate extends CardDate {
} }
classes() { classes() {
let classes = 'end-date' + ' '; let classes = 'end-date ';
const dueAt = this.data().getDue(); const dueAt = this.data().getDue();
const theDate = this.date.get(); const theDate = this.date.get();
if (!dueAt) classes += '';
else if (isBefore(theDate, dueAt)) classes += 'current'; if (!dueAt) {
else if (isAfter(theDate, dueAt)) classes += 'due'; // No due date set - just show as completed
classes += 'completed';
} else if (isBefore(theDate, dueAt)) {
// End date is before due date - completed early
classes += 'completed-early';
} else if (isAfter(theDate, dueAt)) {
// End date is after due date - completed late
classes += 'completed-late';
} else {
// End date equals due date - completed on time
classes += 'completed-on-time';
}
return classes; return classes;
} }

View file

@ -229,6 +229,74 @@
background-color: #ff9999; background-color: #ff9999;
} }
/* Date status colors for minicards - matching cardDate.css */
.minicard .card-date.overdue {
background-color: #ff4444 !important; /* Red for overdue */
color: #fff !important;
}
.minicard .card-date.overdue:hover,
.minicard .card-date.overdue.is-active {
background-color: #cc3333 !important;
}
.minicard .card-date.due-soon {
background-color: #ffaa00 !important; /* Amber for due soon */
color: #000 !important;
}
.minicard .card-date.due-soon:hover,
.minicard .card-date.due-soon.is-active {
background-color: #e69900 !important;
}
.minicard .card-date.not-due {
/* No special background - uses default date type colors */
}
.minicard .card-date.current {
background-color: #5ba639 !important; /* Green for current/active */
color: #fff !important;
}
.minicard .card-date.current:hover,
.minicard .card-date.current.is-active {
background-color: #46802c !important;
}
.minicard .card-date.completed {
background-color: #90ee90 !important; /* Light green for completed */
color: #000 !important;
}
.minicard .card-date.completed:hover,
.minicard .card-date.completed.is-active {
background-color: #7dd87d !important;
}
.minicard .card-date.completed-early {
background-color: #4caf50 !important; /* Green for completed early */
color: #fff !important;
}
.minicard .card-date.completed-early:hover,
.minicard .card-date.completed-early.is-active {
background-color: #45a049 !important;
}
.minicard .card-date.completed-late {
background-color: #ff9800 !important; /* Orange for completed late */
color: #fff !important;
}
.minicard .card-date.completed-late:hover,
.minicard .card-date.completed-late.is-active {
background-color: #f57c00 !important;
}
.minicard .card-date.completed-on-time {
background-color: #2196f3 !important; /* Blue for completed on time */
color: #fff !important;
}
.minicard .card-date.completed-on-time:hover,
.minicard .card-date.completed-on-time.is-active {
background-color: #1976d2 !important;
}
/* Font Awesome icons in minicard dates */ /* Font Awesome icons in minicard dates */
.minicard .card-date i.fa { .minicard .card-date i.fa {
margin-right: 0.3vw; margin-right: 0.3vw;