Skip to content

Commit 6b7b08b

Browse files
authored
Merge pull request #1019 from 200ok-ch/feat/visual-cue-for-overdue-headers
feat: Add visual cue for overdue headers when displaying headers
2 parents 971f634 + b3aa972 commit 6b7b08b

File tree

5 files changed

+63
-18
lines changed

5 files changed

+63
-18
lines changed

changelog.org

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@ When there are updates to the changelog, you will be notified and see a 'gift' i
99

1010
* [2025-05-06 Tue]
1111

12+
** Added
13+
14+
*** Add visual cue for overdue headers when displaying headers
15+
16+
- Before this change: When enabling the setting "Show Deadline
17+
Display", the respective deadline will be displayed on each header
18+
line.
19+
- After this change, in the deadline will show in grey if not overdue
20+
and in red if overdue.
21+
22+
This change was originally proposed and implemented by @dmorlitz:
23+
https://github.com/200ok-ch/organice/pull/970
24+
25+
The merged PR is: https://github.com/200ok-ch/organice/pull/1019
26+
1227
** Fixed
1328

1429
*** Resolved issue where search input field could scroll off-screen on iOS devices

sample.org

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ organice has native support for adding and editing DEADLINE and SCHEDULED items.
267267

268268
Scheduling an item should not be understood in the same way that we understand scheduling a meeting. Setting a date for a meeting is just a simple appointment, you can mark this entry with a simple plain timestamp, to get this item shown on the date where it applies.
269269

270-
** An item with a deadline
271-
DEADLINE: <2018-10-03 Wed>
270+
** An item with a deadline in the far future
271+
DEADLINE: <2088-05-06 Thu>
272272

273273
Deadlines and scheduled items produce entries in the agenda when they are over-due, so it is important to be able to mark such an entry as done once you have done so. When you mark a ‘DEADLINE’ or a ‘SCHEDULED’ with the TODO keyword ‘DONE’, it no longer produces entries in the agenda.
274274
** An item that is scheduled

src/components/OrgFile/components/Header/index.js

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -393,13 +393,25 @@ ${header.get('rawDescription')}`;
393393
.map((p) => p.get('timestamp'))
394394
.get(0);
395395

396-
const headerDeadline =
397-
headerDeadlineMap !== undefined
398-
? headerDeadlineMap.get('month') +
399-
'-' +
400-
headerDeadlineMap.get('day') +
401-
'-' +
402-
headerDeadlineMap.get('year')
396+
let isOverdue = false;
397+
let deadlineString = '';
398+
if (showDeadlineDisplay && headerDeadlineMap) {
399+
const year = headerDeadlineMap.get('year');
400+
const month = headerDeadlineMap.get('month');
401+
const day = headerDeadlineMap.get('day');
402+
// Ensure parts are parsed as integers for Date constructor
403+
const deadlineDate = new Date(parseInt(year), parseInt(month) - 1, parseInt(day));
404+
405+
const today = new Date();
406+
today.setHours(0, 0, 0, 0); // Normalize today to midnight for date-only comparison
407+
408+
isOverdue = deadlineDate < today;
409+
deadlineString = `${year}-${month}-${day}`;
410+
}
411+
412+
const clockDisplayString =
413+
showClockDisplay && header.get('totalTimeLoggedRecursive') !== 0
414+
? millisDuration(header.get('totalTimeLoggedRecursive'))
403415
: '';
404416

405417
const {
@@ -551,15 +563,11 @@ ${header.get('rawDescription')}`;
551563
isSelected={isSelected}
552564
shouldDisableExplicitWidth={swipedDistance === 0}
553565
shouldDisableActions={shouldDisableActions}
554-
addition={
555-
(showClockDisplay && header.get('totalTimeLoggedRecursive') !== 0
556-
? millisDuration(header.get('totalTimeLoggedRecursive'))
557-
: '') +
558-
// Spacing between 'clock display' and 'deadline
559-
// display' overlays
560-
(showClockDisplay && showDeadlineDisplay ? ' ' : '') +
561-
(showDeadlineDisplay && headerDeadline !== undefined ? headerDeadline : '')
562-
}
566+
addition={clockDisplayString}
567+
showDeadlineDisplay={showDeadlineDisplay}
568+
headerDeadlineMap={headerDeadlineMap}
569+
deadlineString={deadlineString}
570+
isOverdue={isOverdue}
563571
/>
564572

565573
<Collapse

src/components/OrgFile/components/Header/stylesheet.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,11 @@
5454
.swipe-action-container__icon--right {
5555
left: 10px;
5656
}
57+
58+
.header-deadline {
59+
padding-right: 0.5em;
60+
}
61+
62+
.header-deadline--overdue {
63+
color: var(--red);
64+
}

src/components/OrgFile/components/TitleLine/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ class TitleLine extends PureComponent {
104104
shouldDisableExplicitWidth,
105105
todoKeywordSets,
106106
addition,
107+
showDeadlineDisplay,
108+
headerDeadlineMap,
109+
deadlineString,
110+
isOverdue,
107111
} = this.props;
108112
const { containerWidth } = this.state;
109113

@@ -163,6 +167,16 @@ class TitleLine extends PureComponent {
163167
{!header.get('opened') && hasContent ? '...' : ''}
164168
</span>
165169
{addition ? <span style={additionStyle}>{addition}</span> : null}
170+
{showDeadlineDisplay && headerDeadlineMap && (
171+
<span
172+
className={classNames('header-deadline', {
173+
'header-deadline--overdue': isOverdue,
174+
})}
175+
>
176+
{addition ? ' ' : ''}
177+
{deadlineString}
178+
</span>
179+
)}
166180
</div>
167181
{header.getIn(['titleLine', 'tags']).size > 0 && (
168182
<div>

0 commit comments

Comments
 (0)