From 57cc977d6ae0c736a5f57bc687591b3d91ff68f1 Mon Sep 17 00:00:00 2001 From: David Wertheimer Date: Thu, 19 Nov 2026 12:46:43 -0800 Subject: [PATCH 01/21] Dashboard: responsive task / Interactive Processing dialog - Wrap and grow the item text on every platform (macOS used a one-line that truncated long tasks). - Phones: full-width sheet pinned near the top, single column, labels above controls, bigger targets. Week/month/quarter reschedule buttons move into a 'Later' menu so the row never overflows. - Touch devices: tapping into the editor collapses the dialog to the editor plus a quick strip (Complete, first two date buttons, More), leaving room for the keyboard. - Editor footer shows due/overdue status (deadline-aware, v2.6.0 due dates win over scheduled dates), a quiet Update that turns solid when edited, and Revert. - Complete is the primary button; 'then' names its date ('Done Jul 15'). - IP shows 'N of M' with a progress bar. - New DialogMenuButton (used by 'Later' and 'Type'); pure helpers in taskDialogHelpers.js with tests. EditableInput gains onFocus/onBlur. Co-Authored-By: Claude Opus 5.5 --- helpers/react/EditableInput.jsx | 7 + jgclark.Dashboard/CHANGELOG.md | 7 + .../react/components/DialogForTaskItems.jsx | 376 ++++++++++++------ .../src/react/components/DialogMenuButton.jsx | 92 +++++ .../__tests__/taskDialogHelpers.test.js | 106 +++++ .../src/react/components/taskDialogHelpers.js | 161 ++++++++ .../src/react/css/DashboardDialog.css | 368 +++++++++++++++-- 7 files changed, 961 insertions(+), 156 deletions(-) create mode 100644 jgclark.Dashboard/src/react/components/DialogMenuButton.jsx create mode 100644 jgclark.Dashboard/src/react/components/__tests__/taskDialogHelpers.test.js create mode 100644 jgclark.Dashboard/src/react/components/taskDialogHelpers.js diff --git a/helpers/react/EditableInput.jsx b/helpers/react/EditableInput.jsx index a9a417a5a..c43ce2032 100644 --- a/helpers/react/EditableInput.jsx +++ b/helpers/react/EditableInput.jsx @@ -19,6 +19,9 @@ type Props = { onEnterPress?: () => void, /** Optional boolean to automatically focus the input when mounted */ autofocusMe?: boolean, + /** Optional callbacks when the input gains / loses focus */ + onFocus?: () => void, + onBlur?: () => void, } type RefType = { @@ -91,6 +94,7 @@ const EditableInputBox: any = React.forwardRef((props, ref) => { if (divRef.current && !divRef.current.textContent) { divRef.current.innerHTML = `${props.placeholder || ''}` } + if (props.onBlur) props.onBlur() } const handleFocus = () => { @@ -98,6 +102,7 @@ const EditableInputBox: any = React.forwardRef((props, ref) => { // Cast: the `querySelector()` call in the guard invalidates Flow's null-refinement of divRef.current; it is still non-null here (divRef.current: any).innerHTML = '' } + if (props.onFocus) props.onFocus() } React.useImperativeHandle(ref, () => ({ @@ -131,6 +136,8 @@ const EditableInputBox: any = React.forwardRef((props, ref) => { value={inputValue} onChange={handleChange} onKeyDown={onKeyDown} + onFocus={props.onFocus} + onBlur={props.onBlur} /> ) }) diff --git a/jgclark.Dashboard/CHANGELOG.md b/jgclark.Dashboard/CHANGELOG.md index 794ec9463..4af01372b 100644 --- a/jgclark.Dashboard/CHANGELOG.md +++ b/jgclark.Dashboard/CHANGELOG.md @@ -13,6 +13,13 @@ For more details see the [plugin's documentation](https://noteplan.co/plugins/jg - The topbar add button opens one dialog for Task, Checklist, or Reminder (switchable either way). Calendar section add icons use the same dialog on Task for that period; the Reminders heading **+** opens it on Reminder. The old Quick Capture fallback and Dynamic Add To Anywhere flag are gone. ### Changes +- Redesigned task actions / Interactive Processing dialog: + - The item text now wraps and grows on macOS too, instead of being cut off in a one-line box. + - Phones: full-width sheet near the top, one column, bigger buttons. Week/month/quarter reschedule options move into a 'Later' menu so nothing runs off the edge. + - While you edit the text on iPhone/iPad, the dialog shrinks to the editor plus Complete, the first two date buttons and 'More', leaving room for the keyboard. + - The editor footer shows when the item is due or how overdue it is, using the due date (`!date`) when there is one. Update stays quiet until you change the text; Revert discards your edits. + - 'Complete' is now the primary button, and 'then' shows the date it will complete on (e.g. 'Done Jul 15'). + - Interactive Processing shows 'N of M' with a progress bar. - 'Reminder Lists to Use' also sets the order those lists appear in the add-reminder dialog. Adding a reminder shows a toast. - After adding a Reminder, only the section(s) that should show it regenerate (undated -> REM only), instead of a blanket refresh that also rebuilt Overdue. - Small UI tweaks to the refresh button and spinner. diff --git a/jgclark.Dashboard/src/react/components/DialogForTaskItems.jsx b/jgclark.Dashboard/src/react/components/DialogForTaskItems.jsx index 266aba9e9..96dabebe1 100644 --- a/jgclark.Dashboard/src/react/components/DialogForTaskItems.jsx +++ b/jgclark.Dashboard/src/react/components/DialogForTaskItems.jsx @@ -2,7 +2,7 @@ //-------------------------------------------------------------------------- // Dashboard React component to show the Dialog for tasks // Called by TaskItem component -// Last updated 2026-10-10 for v2.5.2 by @CursorAI +// Last updated 2026-11-19 for v2.6.x by @dwertheimer & @Claude (responsive IP layout) //-------------------------------------------------------------------------- // Notes: // - onClose & detailsMessageObject are passed down from Dashboard.jsx::handleDialogClose @@ -12,11 +12,14 @@ import { validateAndFlattenMessageObject } from '../../shared' import type { MessageDataObject, TSectionCode, TSectionCodeOrLogical } from '../../types' import { useAppContext } from './AppContext.jsx' import CalendarPicker from './CalendarPicker.jsx' +import DialogMenuButton from './DialogMenuButton.jsx' import { resolveSectionCodesToRefresh } from './dialogRefreshHelpers.js' import ItemNoteLink from './ItemNoteLink.jsx' import { buildReactSettingsAfterIPAdvance, ipItemsHaveBeenSkipped } from './interactiveProcessingHelpers.js' +import { getCompleteThenLabel, getDueStatus } from './taskDialogHelpers.js' import TooltipOnKeyPress from './ToolTipOnModifierPress.jsx' -import { hyphenatedDateString } from '@helpers/dateTime' +import { getTodaysDateHyphenated, hyphenatedDateString } from '@helpers/dateTime' +import { daysBeforeDueDate } from '@helpers/dueStartDates' import { clo, clof, JSP, logDebug, logInfo, logWarn } from '@helpers/dev' import EditableInput from '@helpers/react/EditableInput.jsx' import { extractModifierKeys } from '@helpers/react/reactMouseKeyboard.js' @@ -37,6 +40,8 @@ type DialogButtonProps = { description?: string, icons?: Array<{ className: string, position: 'left' | 'right' }>, sectionCodesToRefresh?: Array, + /** Reschedule buttons: 'day' ones are always shown; 'later' (week/month/quarter) ones go in the 'Later' menu */ + group?: 'day' | 'later', } type EditableInputHandle = { getValue: () => string } @@ -63,7 +68,8 @@ const DialogForTaskItems = ({ details: detailsMessageObject, onClose, positionDi // Note: typed as ?HTMLElement (not ?HTMLDivElement) because flowlib types 's ref instance as HTMLElement, // and React$RefObject is invariant in its type argument. const dialogRef: React$RefObject = useRef (null) - const changeTypeMenuRef: React$RefObject = useRef (null) + // Pending 'stop editing' timer: collapse is delayed after blur so a tap on a quick-strip button lands before the layout changes + const editBlurTimerRef: { current: ?TimeoutID } = useRef(null) //---------------------------------------------------------------------- // State @@ -72,7 +78,8 @@ const DialogForTaskItems = ({ details: detailsMessageObject, onClose, positionDi const [animationClass, setAnimationClass] = useState('') const [resetCalendar, setResetCalendar] = useState(false) // used to reset the calendar during IP processing if the date picker is open const [contentHasChanged, setContentHasChanged] = useState(false) // used to track if the content has changed - const [typeMenuOpen, setTypeMenuOpen] = useState(false) + const [isEditing, setIsEditing] = useState(false) // touch devices: user tapped into the editor, so the keyboard is (probably) up + const [editorKey, setEditorKey] = useState(0) // bumped to remount the editor (Revert) //---------------------------------------------------------------------- // Context (before validate / early return - Rules of Hooks) @@ -108,26 +115,10 @@ const DialogForTaskItems = ({ details: detailsMessageObject, onClose, positionDi } }, [showAnimations]) - // Close the type menu on outside tap or Escape. Listener is only attached while the menu is open. - useEffect(() => { - if (!typeMenuOpen) return undefined - function handlePointerDown(event: MouseEvent) { - const root = changeTypeMenuRef.current - const target = event.target - if (root && target instanceof Node && !root.contains(target)) { - setTypeMenuOpen(false) - } - } - function handleKeyDown(event: KeyboardEvent) { - if (event.key === 'Escape') setTypeMenuOpen(false) - } - document.addEventListener('pointerdown', handlePointerDown) - document.addEventListener('keydown', handleKeyDown) - return () => { - document.removeEventListener('pointerdown', handlePointerDown) - document.removeEventListener('keydown', handleKeyDown) - } - }, [typeMenuOpen]) + // Clear any pending editing-collapse timer on unmount + useEffect(() => () => { + if (editBlurTimerRef.current) clearTimeout(editBlurTimerRef.current) + }, []) //---------------------------------------------------------------------- // Constants (validated message / derived UI) @@ -156,6 +147,8 @@ const DialogForTaskItems = ({ details: detailsMessageObject, onClose, positionDi logDebug('DialogForTaskItems', `thisSectionCode=${String(thisSectionCode)}`) const isDesktop = pluginData.platform === 'macOS' + // Keyboard-aware collapse is only for touch devices, where the on-screen keyboard covers the lower part of the dialog + const isTouchDevice = pluginData.platform === 'iOS' || pluginData.platform === 'iPadOS' const monthsToShow = (pluginData.platform === 'iOS') ? 1 : 2 const resched = dashboardSettings?.rescheduleNotMove || pluginData?.dashboardSettings.rescheduleNotMove || false @@ -174,41 +167,51 @@ const DialogForTaskItems = ({ details: detailsMessageObject, onClose, positionDi // Set standard list of buttons to render. // ITEM_ORIG_SECTION resolves at click time to the open item's sectionCode (source section to refresh). const buttons: Array = [ - { label: 'today', controlStr: 't', sectionCodesToRefresh: ['ITEM_ORIG_SECTION', 'DT'], description: 'Re-schedule to today' }, - { label: '+1d', controlStr: '+1d', sectionCodesToRefresh: ['ITEM_ORIG_SECTION', 'DO'], description: 'Re-schedule to tomorrow' }, - { label: '+1b', controlStr: '+1b', sectionCodesToRefresh: ['ITEM_ORIG_SECTION', 'DO'], description: 'Re-schedule to next business day' }, - { label: '+2d', controlStr: '+2d', sectionCodesToRefresh: ['ITEM_ORIG_SECTION'], description: 'Re-schedule to 2 days later' }, - { label: 'this week', controlStr: '+0w', sectionCodesToRefresh: ['ITEM_ORIG_SECTION', 'W'], description: 'Re-schedule to this week' }, - { label: '+1w', controlStr: '+1w', sectionCodesToRefresh: ['ITEM_ORIG_SECTION'], description: 'Re-schedule to next week' }, - { label: '+2w', controlStr: '+2w', sectionCodesToRefresh: ['ITEM_ORIG_SECTION'], description: 'Re-schedule to 2 weeks later' }, - { label: 'this month', controlStr: '+0m', sectionCodesToRefresh: ['ITEM_ORIG_SECTION', 'M'], description: 'Re-schedule to this month' }, - { label: '+1m', controlStr: '+1m', sectionCodesToRefresh: ['ITEM_ORIG_SECTION'], description: 'Re-schedule to next month' }, - { label: 'this quarter', controlStr: '+0q', sectionCodesToRefresh: ['ITEM_ORIG_SECTION', 'Q'], description: 'Re-schedule to this quarter' }, + { label: 'today', group: 'day', controlStr: 't', sectionCodesToRefresh: ['ITEM_ORIG_SECTION', 'DT'], description: 'Re-schedule to today' }, + { label: '+1d', group: 'day', controlStr: '+1d', sectionCodesToRefresh: ['ITEM_ORIG_SECTION', 'DO'], description: 'Re-schedule to tomorrow' }, + { label: '+1b', group: 'day', controlStr: '+1b', sectionCodesToRefresh: ['ITEM_ORIG_SECTION', 'DO'], description: 'Re-schedule to next business day' }, + { label: '+2d', group: 'day', controlStr: '+2d', sectionCodesToRefresh: ['ITEM_ORIG_SECTION'], description: 'Re-schedule to 2 days later' }, + { label: 'this week', group: 'later', controlStr: '+0w', sectionCodesToRefresh: ['ITEM_ORIG_SECTION', 'W'], description: 'Re-schedule to this week' }, + { label: '+1w', group: 'later', controlStr: '+1w', sectionCodesToRefresh: ['ITEM_ORIG_SECTION'], description: 'Re-schedule to next week' }, + { label: '+2w', group: 'later', controlStr: '+2w', sectionCodesToRefresh: ['ITEM_ORIG_SECTION'], description: 'Re-schedule to 2 weeks later' }, + { label: 'this month', group: 'later', controlStr: '+0m', sectionCodesToRefresh: ['ITEM_ORIG_SECTION', 'M'], description: 'Re-schedule to this month' }, + { label: '+1m', group: 'later', controlStr: '+1m', sectionCodesToRefresh: ['ITEM_ORIG_SECTION'], description: 'Re-schedule to next month' }, + { label: 'this quarter', group: 'later', controlStr: '+0q', sectionCodesToRefresh: ['ITEM_ORIG_SECTION', 'Q'], description: 'Re-schedule to this quarter' }, ] // Now tweak this list if buttons slightly if we're on a weekly or monthly note etc. if (sectionCodes) { if (sectionCodes.includes('DT')) { buttons.splice(0, 1) // remove the 'today' item, as its redundant - buttons.splice(3, 0, { label: '+3d', controlStr: '+3d', sectionCodesToRefresh: ['ITEM_ORIG_SECTION'], description: 'Re-schedule to 3 days later' }) // add another one instead + buttons.splice(3, 0, { label: '+3d', group: 'day', controlStr: '+3d', sectionCodesToRefresh: ['ITEM_ORIG_SECTION'], description: 'Re-schedule to 3 days later' }) // add another one instead } if (sectionCodes.includes('W')) { buttons.splice(4, 1) // remove the 'this week' item, as its redundant } if (sectionCodes.includes('M')) { - buttons.splice(7, 1, { label: 'next month', controlStr: '+1m', sectionCodesToRefresh: ['ITEM_ORIG_SECTION'], description: 'Re-schedule to next month' }) // Replace the 'this month' item + buttons.splice(7, 1, { label: 'next month', group: 'later', controlStr: '+1m', sectionCodesToRefresh: ['ITEM_ORIG_SECTION'], description: 'Re-schedule to next month' }) // Replace the 'this month' item } if (sectionCodes.includes('Q')) { - buttons.splice(8, 1, { label: 'next quarter', controlStr: '+1q', sectionCodesToRefresh: ['ITEM_ORIG_SECTION'], description: 'Re-schedule to next quarter' }) // Replace the 'this quarter' item + buttons.splice(8, 1, { label: 'next quarter', group: 'later', controlStr: '+1q', sectionCodesToRefresh: ['ITEM_ORIG_SECTION'], description: 'Re-schedule to next quarter' }) // Replace the 'this quarter' item } } + // Day buttons are always visible; the rarer week/month/quarter ones live in the 'Later' menu + const dayButtons = buttons.filter((b) => b.group !== 'later') + const laterButtons = buttons.filter((b) => b.group === 'later') + + // 'Complete then' completes on para.dueDate, so name that date on the button. Also show a due/overdue status line. + const todayISO = getTodaysDateHyphenated() + const completeThenLabel = getCompleteThenLabel(para?.dueDate, todayISO) + const itemContent = String(para?.content ?? content ?? '') + const dueStatus = getDueStatus(para?.dueDate, itemContent, filename, todayISO, undefined, daysBeforeDueDate(itemContent)) + // Note: Extra setup is required for certain buttons: // - Cancel button icon circle or square, and function - // - Change type is a native setTimeChanged(e.currentTarget.value !== baseline.time)} + onKeyDown={(e) => { + if (e.key === 'Enter') handleEnterPress() + }} + /> + + {dueStatus?.text ?? ''} + {/* Revert / Update (and the Return hint) only appear once something has been changed */} + {hasChanges ? ( + <> + + {isDesktop ? ( + <> + ↩ save & {interactiveProcessing ? 'next' : 'close'} + + ) : null} + + + + + ) : ( + + )} + + -
Schedule:
-
- { - if (e.key === 'Enter') { - handleEnterPress() - } - }} - /> - {moveButtons.map((button, index) => ( - - ))} + {/* Reschedule ---------------- */} +
+
Reschedule
+
+
+ {dayButtons.map((button) => ( + + ))} +
+
-
Actions:
-
- {actionButtons.map((button, index) => ( - - ))} + {/* Actions: outcomes, then edits ---------------- */} +
+
Actions
+
+
+ {outcomeButtons.map((button) => renderActionButton(button, button.controlStr === 'completereminder' ? 'primaryAction' : ''))} +
+ {editButtons.length > 0 ?
{editButtons.map((button) => renderActionButton(button))}
: null}
diff --git a/jgclark.Dashboard/src/react/css/DashboardDialog.css b/jgclark.Dashboard/src/react/css/DashboardDialog.css index 5afef915e..f5affce89 100644 --- a/jgclark.Dashboard/src/react/css/DashboardDialog.css +++ b/jgclark.Dashboard/src/react/css/DashboardDialog.css @@ -262,109 +262,54 @@ dialog:modal { margin-top: 2px; } -/* Reminder IP / actions dialog (#779, #2.4.2 edit/reschedule) - * Fixed width for a given viewport (wider than the old content-sized dialog). +/* Reminder IP / actions dialog (DialogForReminderItems). + * It also has the .taskControlDialog class, so it shares the task dialog's layout and sizes (below). + * These are only the reminder-only parts: the notes field and the time field in the editor box. */ -.reminderControlDialog { - width: min(38rem, calc(100vw - 1.5rem)); - box-sizing: border-box; - - /* A couple of overrides are necessary to look good */ - .dialogBody { - padding-block-start: 0.5rem; - padding-inline-start: 1rem; - } - .dialogTitle { - padding-inline-start: 3rem; - } -} - -.buttonGrid.reminderButtonGrid { - grid-template-columns: auto minmax(0, 1fr); -} - -.buttonGrid.reminderButtonGrid > div.preText.reminderDialogRowLabel { - align-self: auto; /* baseline; */ - padding-block-start: 0; - padding-block-end: 0; - line-height: 1.35; -} - -.buttonGrid.reminderButtonGrid > div.reminderDialogLine { - align-self: baseline; - line-height: 1.35; - margin: 0; - padding: 0; -} - -.reminderDialogEditLine { +.reminderControlDialog .reminderDialogFromLabel { display: inline-flex; align-items: center; - flex-wrap: nowrap; - gap: 0.25rem; - width: 100%; -} - -.reminderDialogEditLine .fullTextInput { - flex: 1 1 12rem; - min-width: 0; -} - -.reminderDialogEditLine .reminderNotesInput { - flex: 1 1 auto; - max-width: calc(100% - 4.75rem); /* leave room for Update on the same row */ + gap: 0.35rem; font-weight: 500; } - -.reminderDialogEditLine .updateItemContentButton { - flex: 0 0 auto; -} - -.reminderDialogScheduleLine { - display: inline-flex; - align-items: center; - flex-wrap: wrap; - gap: 0.15rem; +/* Notes: a second, quieter text area under the title, inside the same editor box */ +.reminderControlDialog .reminderNotesText { + border-top: 1px solid var(--divider-color); + margin: 0 0.65rem; } - -.reminderTimeInput { - font-size: 0.9rem; - font-weight: 500; - width: 4.5rem; - flex: 0 0 auto; - padding: 1px 4px 1px 4px; - margin-right: 0.25rem; - border: 1px solid var(--divider-color); - border-radius: 4px; - background-color: var(--bg-mid-color); +.reminderControlDialog .taskEditor .reminderNotesText .fullTextArea.dialogItemContent { + padding: 0.35rem 0 0.25rem; + font-size: 0.85rem; + font-weight: 400; color: var(--fg-sidebar-color); } - -.reminderDialogNotesLine { +.reminderControlDialog .reminderNotesText .placeholder { color: var(--fg-placeholder-color); - font-size: 0.9rem; } - -.reminderDialogActions { +/* Time: small field at the start of the editor footer */ +.reminderControlDialog .reminderTimeField { display: inline-flex; - flex-wrap: wrap; align-items: center; - /* gap: 0.35rem; */ -} - -.reminderDialogTitleLine { - display: inline-flex; - flex-wrap: wrap; - align-items: baseline; + gap: 0.3rem; + flex: none; + color: var(--fg-placeholder-color); + font-size: 0.78rem; } - -.reminderDialogTitleText { - font-weight: 500; - line-height: inherit; +.reminderControlDialog .reminderTimeInput { + width: 3.6rem; + height: calc(var(--td-h) - 0.5rem); + padding: 0 0.3rem; + margin: 0; + border: 1px solid var(--divider-color); + border-radius: 4px; + background-color: var(--bg-main-color); + color: var(--fg-main-color); + font-size: 0.78rem; + font-variant-numeric: tabular-nums; } - -.reminderDialogFromLabel { - font-weight: 500; +.reminderControlDialog .reminderTimeInput:focus { + outline: none; + border-color: var(--tint-color); } /* ------------------------------------------------------------------ */ @@ -871,6 +816,10 @@ dialog:modal { text-box: normal; line-height: 1.25; } + /* Reminders have three outcomes (Complete, To task, Delete) */ + .reminderControlDialog .taskOutcomeButtons { + grid-template-columns: repeat(3, minmax(0, 1fr)); + } /* Edits: 2 equal columns, every control fills its cell; an odd last one spans the row */ .taskEditButtons { display: grid; From d94f3ef47ca6d26037d9f5ae653f482a8eecc470 Mon Sep 17 00:00:00 2001 From: jgclark Date: Fri, 4 Dec 2026 17:01:48 +0000 Subject: [PATCH 13/21] Update on .children() and .indents API bugs --- flow-typed/Noteplan.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flow-typed/Noteplan.js b/flow-typed/Noteplan.js index ad6f3b128..a0917500a 100644 --- a/flow-typed/Noteplan.js +++ b/flow-typed/Noteplan.js @@ -1721,6 +1721,7 @@ lineIndex: number; /** * Paragraph.indents * Get/Set the amount of indentations. + * WARNING: Long-standing BUG: updateParagraph() keeps .indents for type 'text', and drops it when the line is recognized as 'list' or 'quote' (content starts with `- ` or `> `). See https://github.com/NotePlan/plugins/issues/803, raised 2026-12-04 */ indents: number; /** @@ -1754,7 +1755,8 @@ lineIndex: number; * If it returns undefined, it means there has been a failure. * Note: Available from v3.3 * Note: this can become inaccurate if other content changes in the note; it is not automatically recalculated. Re-fetch paragraphs to avoid this. - * BUG (NotePlan Beta 3.22.1, 2026-12-03): after note.updateParagraph() on this same object, if the new content is shorter than the old content (priority `!!` -> `!`, `!` -> none, `>>` -> none), contentRange is left at the old end. children() then returns one phantom child: the next line, indent 0, empty content and rawContent, and a zero-width contentRange (start === end). Lengthening the line does not do this. Loading the paragraph again from the note returns the real children. + * WARNING: BUG (NotePlan Beta 3.22.1, 2026-12-03): after note.updateParagraph() on this same object, if the new content is shorter than the old content (priority `!!` -> `!`, `!` -> none, `>>` -> none), contentRange is left at the old end. children() then returns one phantom child: the next line, indent 0, empty content and rawContent, and a zero-width contentRange (start === end). Lengthening the line does not do this. Loading the paragraph again from the note returns the real children. + * TODO: @EduardMe reports that is fixed in the next beta after b1556 (3.22.1). Test and then remove workarounds and this warning. * Workaround: helpers/parentsAndChildren.js childrenExcludingStalePhantoms() drops entries whose content and rawContent are both empty. Callers that have just written the paragraph should also re-read it from the note before calling children() (Dashboard rereadParagraph()). * WARNING: appears to be unreliable on iOS. * @return {$ReadOnlyArray | void} From a077b39c9910ffc6a0bcace5fabb3e31b5de12c7 Mon Sep 17 00:00:00 2001 From: jgclark Date: Fri, 4 Dec 2026 19:55:46 +0000 Subject: [PATCH 14/21] Add 'add text note' to Task Dialog. Add 'useEditorWherePossible' optional field to MessageDataObject, to help when adding a new item to the currently-open note. --- helpers/__tests__/headings.test.js | 35 +++ helpers/headings.js | 7 +- jgclark.Dashboard/CHANGELOG.md | 26 +- jgclark.Dashboard/src/clickHandlers.js | 102 ++++++++ jgclark.Dashboard/src/dataGeneration.js | 2 +- jgclark.Dashboard/src/pluginToHTMLBridge.js | 5 + .../components/DialogForProjectItems.jsx | 11 +- .../components/DialogForReminderItems.jsx | 242 ++++++++++-------- .../react/components/DialogForTaskItems.jsx | 72 +++++- .../react/components/Header/AddToAnyNote.jsx | 2 +- .../src/react/css/DashboardDialog.css | 179 ++++++------- jgclark.Dashboard/src/refreshClickHandlers.js | 7 +- .../src/requestHandlers/addTaskToNote.js | 5 + jgclark.Dashboard/src/types.js | 8 +- 14 files changed, 482 insertions(+), 221 deletions(-) diff --git a/helpers/__tests__/headings.test.js b/helpers/__tests__/headings.test.js index 48b306c62..948e99475 100644 --- a/helpers/__tests__/headings.test.js +++ b/helpers/__tests__/headings.test.js @@ -205,6 +205,41 @@ describe('helpers/headings', () => { }) }) + describe('getHeadingHierarchyForThisPara', () => { + test('walks from the paragraph position when lineIndex is stale after an insert', () => { + const note = { + filename: '20261204.md', + paragraphs: [ + { type: 'title', content: 'Home', headingLevel: 2, lineIndex: 0 }, + { type: 'open', content: 'older', lineIndex: 1 }, + { type: 'open', content: 'Give feedback on Books app manual tracking', lineIndex: 4 }, + { type: 'title', content: 'NotePlan', headingLevel: 2, lineIndex: 3 }, + { type: 'open', content: 'other', lineIndex: 4 }, + ], + } + note.paragraphs.forEach((p) => { + p.note = note + }) + // lineIndex 4 is the following section. The task itself sits under Home. + expect(h.getHeadingHierarchyForThisPara(note.paragraphs[2])).toEqual(['Home']) + }) + + test('falls back to lineIndex when the paragraph object is not in the note array', () => { + const note = { + filename: '20261204.md', + paragraphs: [ + { type: 'title', content: 'Home', headingLevel: 2, lineIndex: 0 }, + { type: 'open', content: 'older', lineIndex: 1 }, + ], + } + note.paragraphs.forEach((p) => { + p.note = note + }) + const orphan = { type: 'open', content: 'x', lineIndex: 1, note } + expect(h.getHeadingHierarchyForThisPara(orphan)).toEqual(['Home']) + }) + }) + describe('stripFoldedHeadingEllipsis', () => { test('strips unicode ellipsis', () => { expect(h.stripFoldedHeadingEllipsis('Done …')).toBe('Done') diff --git a/helpers/headings.js b/helpers/headings.js index 6cd9c63c8..3ea4c8579 100644 --- a/helpers/headings.js +++ b/helpers/headings.js @@ -52,7 +52,6 @@ export function isParaAMatchForHeading(para: TParagraph, headingName: string, he * @returns {Array} array of headings, lowest (e.g. H4) to highest (e.g. H1) */ export function getHeadingHierarchyForThisPara(para: TParagraph): Array { - let lineIndex = para.lineIndex const noteFilename = para.note?.filename ?? '?' // logDebug('getHeadingHierarchyForThisPara', `Finding headings for line #${String(lineIndex)} in note ${noteFilename}:`) const thisNote = para.note @@ -61,11 +60,15 @@ export function getHeadingHierarchyForThisPara(para: TParagraph): Array logWarn('getHeadingHierarchyForThisPara', `-> no note paras found for ${noteFilename}`) return [] } + // lineIndex is not recalculated when another line is inserted, and Editor vs Note differ when the note has frontmatter. + // Walk from this paragraph's place in note.paragraphs so a just-added task is still under its real heading. + let lineIndex = noteParas.indexOf(para) + if (lineIndex < 0 && typeof para.lineIndex === 'number') lineIndex = para.lineIndex let currentHeadingLevel = 5 const theseHeadings = [] while (lineIndex >= 0) { const thisPara = noteParas[lineIndex] - if (thisPara.type === 'title') { + if (thisPara && thisPara.type === 'title') { const thisHeadingLevel = thisPara.headingLevel if (thisHeadingLevel < currentHeadingLevel) { theseHeadings.push(thisPara.content) diff --git a/jgclark.Dashboard/CHANGELOG.md b/jgclark.Dashboard/CHANGELOG.md index 1679da650..92d5ca28a 100644 --- a/jgclark.Dashboard/CHANGELOG.md +++ b/jgclark.Dashboard/CHANGELOG.md @@ -3,24 +3,22 @@ For more details see the [plugin's documentation](https://noteplan.co/plugins/jg -## [2.7.0] 2026-12-02 +## [2.7.0] 2026-12-04 ### Changes -- Redesigned task actions / Interactive Processing dialog: - - The item text now wraps and grows on macOS too, instead of being cut off in a one-line box. - - Phones: full-width sheet near the top, one column, bigger buttons. Week/month/quarter reschedule options move into a 'Later' menu so nothing runs off the edge. - - On iPhone/iPad the dialog no longer opens with the keyboard up. While you type with the on-screen keyboard showing, it shrinks to the editor plus Complete, the first two date buttons and a hide-keyboard button. - - The date picker shows two months on phones too, with arrows on the month line, and its day cells no longer pick up the dialog's button borders. +- Change: Redesigned Edit / Interactive Processing dialog for Tasks, Reminders and Projects. It should be more responsive on smaller devices, and provides clearer button labels. Changes include: + - The item text shows more formatting, as on Dashboard rows (links, tags and priorities styled). Click the text to edit the raw text, with the cursor where you clicked (or use the pencil in its footer); the eye button, Revert or Update go back to the formatted view. + - Some move/reschedule-to dates are now in a "Later" sub-menu. + - On iPhone/iPad the dialog no longer opens with the keyboard showing. - The 'Type' and 'Later' menus open upward when there isn't room below. - - The item text shows formatted, as on Dashboard rows (links, tags and priorities styled; markdown link syntax and block IDs hidden). Click the text to edit the raw text, with the cursor where you clicked (or use the pencil in its footer); the eye button, Revert or Update go back to the formatted view. - - The editor footer shows when the item is due or how overdue it is, using the due date (`!date`) when there is one. Update and Revert only appear once you change the text; undoing your edits by hand hides them again. **Update** now saves the text and keeps the dialog open, so you can go on to reschedule the item, change its type, etc. **Return** saves and closes (or moves to the next item in Interactive Processing), and the footer says which. An unsaved edit is no longer lost when you pick a date from the calendar. - - Pressing the priority up/down buttons more than once in the dialog now works. Before, the second press said it was "Unable to find para", because the dialog still had the line's old text. - - 'Complete' is now the primary button, and 'then' shows the date it will complete on (e.g. 'Done Jul 15'). - - Interactive Processing shows 'N of M' with a progress bar. + - The editor footer shows when the item is due or how overdue it is, using the due date (`!date`) when there is one. + - New: 'Add text note' asks for text, then inserts it under the item (after any children it already has), indented one level deeper. (for @Doug) + - 'Complete' is now the primary button, and 'Complete then' instead shows the date it was scheduled to (e.g. 'Done Jul 15') if available. - On iPhone/iPad, swipe the Interactive Processing dialog left to skip to the next item. - - Interactive Processing now animates between items: each new item slides in from the side (a plain fade with Reduce Motion on). Previously the 'transitions' setting only animated the first item. A swipe carries the old item off to the left first. + - Interactive Processing now animates between items, not just into the first item. - Opening the date picker keeps the top of the dialog where it is and only extends it downward. - - 'New Task' opens the Dashboard's own Add dialog (set to this item's note when it's a regular note, otherwise today) instead of the Quick Capture command sheet. The task dialog slides out and the Add dialog slides in at the same spot, then the task dialog slides back on the same item when you're done, so Interactive Processing carries on where you were. -Change: No match NotePlan app, more than three leading `!` no longer are treated as a priority indicator. For NotePlan only recognises `!`, `!!`, `!!!` and `>>`. + - 'New Task' opens the Dashboard's own Add dialog instead of the Quick Capture command sheet. +- Fix: A task added from Dashboard's Add dialog now shows in Today (or the other section that was refreshed) without waiting for a full refresh. The refresh was reading the note before the new line's heading was reliable, so a perspective that only shows one calendar heading (such as Home) left the task out. +- Change: To match Priority markers in the main app, more than three leading `!`s are no longer are treated as a priority indicator. For NotePlan only recognises `!`, `!!`, `!!!` and `>>`. ## [2.6.2] 2026-12-03 - Fix: Automatic refresh could stop working if the Time Block section was on after waking the device from sleep or changing to being the foreground window. dev: A second Time Block refresh was allowed to start while the first was still running, and both then stuck the plugin thread. The idle timer also skipped a refresh when its check ran late (sleep, or the window in the background) and started the wait over. diff --git a/jgclark.Dashboard/src/clickHandlers.js b/jgclark.Dashboard/src/clickHandlers.js index 547de77fe..71679deda 100644 --- a/jgclark.Dashboard/src/clickHandlers.js +++ b/jgclark.Dashboard/src/clickHandlers.js @@ -45,6 +45,7 @@ import { sendToHTMLWindow } from '@helpers/HTMLView' import { coreAddChecklistToNoteHeading, coreAddTaskToNoteHeading } from '@helpers/NPAddItems' import { smartOpenNoteInEditorFromFilename, smartShowLineInEditorFromFilename } from '@helpers/NPEditor' import { cancelItem, completeItem, completeItemEarlier, deleteItem, findParaFromStringAndFilename } from '@helpers/NPParagraph' +import { getIndentLevelFromRawContent } from '@helpers/paragraph' import { addAppleReminder, buildOpenTaskContentFromReminder, completeReminderById, deleteReminderById, mapCalendarItemToReminder, mapNotePlanPriorityToAppleReminder, parseLeadingPriorityFromReminderText, updateReminderById, type TUpdateAppleReminderParams } from '@helpers/NPReminders' import { unscheduleItem } from '@helpers/NPScheduleItems' import { generateCSSFromTheme } from '@helpers/NPThemeToCSS' @@ -897,6 +898,107 @@ export function doChangeParagraphType(data: MessageDataObject): TBridgeClickHand } } +/** + * The paragraph a new comment should follow: the parent, or its last descendant so existing children stay above it. + * @param {TParagraph} parentPara + * @returns {TParagraph} + */ +function paragraphToInsertCommentAfter(parentPara: TParagraph): TParagraph { + const children = parentPara.children() || [] + let last = parentPara + for (const child of children) { + if (child && typeof child.lineIndex === 'number' && child.lineIndex > last.lineIndex) last = child + } + return last +} + +/** + * Text of a comment line with a list or quote marker removed, so we can find the paragraph after NotePlan parses it. + * @param {string} line + * @returns {string} + */ +function commentLineBody(line: string): string { + if (line.startsWith('- ')) return line.slice(2) + if (line.startsWith('> ')) return line.slice(2) + if (line.startsWith('>')) return line.slice(1).trimStart() + return line +} + +/** + * True when this paragraph is the comment line we just inserted. + * NotePlan may keep the marker in content, or move it into the paragraph type and leave only the body. + * @param {TParagraph} para + * @param {string} line - the comment line as typed, without the indent we add + * @returns {boolean} + */ +function paragraphIsInsertedComment(para: TParagraph, line: string): boolean { + const raw = String(para.rawContent || '') + const body = String(para.content || '') + const markerStripped = commentLineBody(line) + return body === line || body === markerStripped || raw.endsWith(line) || (markerStripped !== '' && raw.endsWith(markerStripped)) +} + +/** + * Add one or more indented paragraphs under the item (a comment). + * The comment text arrives in userInputObj.commentText, not updatedContent, so a pending edit of the item itself still applies first. + * Leading tabs are part of the inserted text. Setting .indents and then updateParagraph keeps the indent for plain text, + * but drops it when the line is recognized as a list (`-`) or a quote (`>`). + * @param {MessageDataObject} data + * @returns {Promise} + */ +export async function doAddComment(data: MessageDataObject): Promise { + const validated = validateMessageDataForHandler(data, 'doAddComment') + if (!validated.ok) return validated.result + const { filename, content, sectionCode } = validated.data + const commentInput = data.userInputObj + const rawComment = commentInput && typeof commentInput.commentText === 'string' ? commentInput.commentText : '' + const lines = rawComment.split('\n').map((line) => line.trim()).filter((line) => line !== '') + if (lines.length === 0) { + logWarn('doAddComment', 'No comment text') + return handlerResult(false, [], { errorMsg: 'Type a comment to add under this item.', errorMessageLevel: 'WARN' }) + } + + const possiblePara = findParaFromStringAndFilename(filename, content) + if (typeof possiblePara === 'boolean' || !possiblePara) { + logWarn('doAddComment', `unable to find para {${content}} in filename ${filename}`) + return handlerResult(false, ['REFRESH_SECTION_IN_JSON'], { sectionCodes: [sectionCode], errorMsg: `Unable to find para "${content}" in filename: "${filename}". I will refresh this section, then please try again.`, errorMessageLevel: 'WARN' }) + } + const note = possiblePara.note + if (!note) { + return handlerResult(false, ['REFRESH_SECTION_IN_JSON'], { sectionCodes: [sectionCode], errorMsg: `Could not get note for filename ${filename}.`, errorMessageLevel: 'ERROR' }) + } + + try { + const parentIndents = Math.max( + typeof possiblePara.indents === 'number' ? possiblePara.indents : 0, + getIndentLevelFromRawContent(String(possiblePara.rawContent || '')), + ) + const childIndents = parentIndents + 1 + const indentPrefix = '\t'.repeat(childIndents) + let anchor = paragraphToInsertCommentAfter(possiblePara) + for (const line of lines) { + const insertedAt = anchor.lineIndex + 1 + // Tabs go in the inserted text. updateParagraph after setting .indents rewrites list and quote lines without them. + // The API is typed as void but resolves asynchronously in the app. + await note.insertParagraphAfterParagraph(`${indentPrefix}${line}`, anchor, 'text') + const newPara = note.paragraphs[insertedAt] + if (!newPara || !paragraphIsInsertedComment(newPara, line)) { + throw new Error(`Inserted comment was not found under "${content}"`) + } + anchor = newPara + } + DataStore.updateCache(note, false) + logDebug('doAddComment', `added ${lines.length} comment line(s) under "${content}" at indent ${childIndents}`) + return handlerResult(true, ['UPDATE_LINE_IN_JSON', 'REFRESH_SECTION_IN_JSON'], { + updatedParagraph: makeDashboardParas([rereadParagraph(possiblePara)])[0], + sectionCodes: [sectionCode], + }) + } catch (error) { + logError('doAddComment', error.message) + return handlerResult(false, ['REFRESH_SECTION_IN_JSON'], { sectionCodes: [sectionCode], errorMsg: `${error.message}. I will refresh this Section; please then try again.`, errorMessageLevel: 'ERROR' }) + } +} + /** * Send a request to unscheduleItem to plugin * @param {MessageDataObject} data - The data object containing item info diff --git a/jgclark.Dashboard/src/dataGeneration.js b/jgclark.Dashboard/src/dataGeneration.js index 4dfe3851d..cb824e0e3 100644 --- a/jgclark.Dashboard/src/dataGeneration.js +++ b/jgclark.Dashboard/src/dataGeneration.js @@ -237,7 +237,7 @@ export async function getSomeSectionsData( if (placement.homeless.length > 0) { const parts = placement.homeless.map((h) => `${String(h.count)} ${h.label}`) - logWarn('getSomeSectionsData', `- ${parts.join('; ')} reminder(s) have no visible section and will not be shown anywhere`) + logInfo('getSomeSectionsData', `- ${parts.join('; ')} reminder(s) have no visible section and will not be shown anywhere`) } // DT and TB sections are generated separately but share paragraph data fetching. diff --git a/jgclark.Dashboard/src/pluginToHTMLBridge.js b/jgclark.Dashboard/src/pluginToHTMLBridge.js index 3d85a2a47..819e6ecc1 100644 --- a/jgclark.Dashboard/src/pluginToHTMLBridge.js +++ b/jgclark.Dashboard/src/pluginToHTMLBridge.js @@ -30,6 +30,7 @@ import { doShowNoteInEditorFromFilename, doShowNoteInEditorFromTitle, doShowLineInEditorFromFilename, + doAddComment, doChangeParagraphType, doUnscheduleItem, doWindowResized, @@ -378,6 +379,10 @@ export async function bridgeClickDashboardItem(data: MessageDataObject) { result = await doChangeParagraphType(data) break } + case 'addTextNote': { + result = await doAddComment(data) + break + } case 'cyclePriorityStateUp': { result = await doCyclePriorityStateUp(data) break diff --git a/jgclark.Dashboard/src/react/components/DialogForProjectItems.jsx b/jgclark.Dashboard/src/react/components/DialogForProjectItems.jsx index c35470c3d..9e5ae4645 100644 --- a/jgclark.Dashboard/src/react/components/DialogForProjectItems.jsx +++ b/jgclark.Dashboard/src/react/components/DialogForProjectItems.jsx @@ -254,10 +254,10 @@ const DialogForProjectItems = ({ details: detailsMessageObject, onClose, positio let reviewButtons: Array = [ { label: 'Start', controlStr: 'start', description: 'Open the project note in the Editor', handlingFunction: 'startReview', icons: [{ className: 'fa-solid fa-play', position: 'left' }], notOnMobile: false }, { label: 'Finish Review', controlStr: 'finish', description: 'Update the @review(...) date on the project to today', handlingFunction: 'reviewFinished', icons: [{ className: 'fa-regular fa-calendar-check', position: 'left' }], notOnMobile: false }, - { label: 'Skip 1w', controlStr: 'nr+1w', description: 'Add a @nextReview(...) date for 1 week to the project metadata', handlingFunction: 'setNextReviewDate', icons: [{ className: 'fa-solid fa-forward', position: 'left' }], notOnMobile: false }, - { label: 'Skip 2w', controlStr: 'nr+2w', description: 'Add a @nextReview(...) date for 2 weeks to the project metadata', handlingFunction: 'setNextReviewDate', icons: [{ className: 'fa-solid fa-forward', position: 'left' }], notOnMobile: false }, - { label: 'Skip 1m', controlStr: 'nr+1m', description: 'Add a @nextReview(...) date for 1 month to the project metadata', handlingFunction: 'setNextReviewDate', icons: [{ className: 'fa-solid fa-forward', position: 'left' }], notOnMobile: false }, - { label: 'Skip 1q', controlStr: 'nr+1q', description: 'Add a @nextReview(...) date for 1 quarter to the project metadata', handlingFunction: 'setNextReviewDate', icons: [{ className: 'fa-solid fa-forward', position: 'left' }], notOnMobile: false }, + { label: 'Skip 1w', group: 'skip', controlStr: 'nr+1w', description: 'Add a @nextReview(...) date for 1 week to the project metadata', handlingFunction: 'setNextReviewDate', icons: [{ className: 'fa-solid fa-forward', position: 'left' }], notOnMobile: false }, + { label: '2w', group: 'skip', controlStr: 'nr+2w', description: 'Add a @nextReview(...) date for 2 weeks to the project metadata', handlingFunction: 'setNextReviewDate', notOnMobile: false }, + { label: '1m', group: 'skip', controlStr: 'nr+1m', description: 'Add a @nextReview(...) date for 1 month to the project metadata', handlingFunction: 'setNextReviewDate', notOnMobile: false }, + { label: '1q', group: 'skip', controlStr: 'nr+1q', description: 'Add a @nextReview(...) date for 1 quarter to the project metadata', handlingFunction: 'setNextReviewDate', notOnMobile: false }, ] let projectButtons: Array = [ @@ -385,6 +385,7 @@ const DialogForProjectItems = ({ details: detailsMessageObject, onClose, positio {reviewSkipButtons.map((button) => renderActionButton(button))}
) : null} + {/* TODO: Ideally combine this into the "Skip review" group above */} diff --git a/jgclark.Dashboard/src/react/components/DialogForReminderItems.jsx b/jgclark.Dashboard/src/react/components/DialogForReminderItems.jsx index 647bf31b0..b330ca040 100644 --- a/jgclark.Dashboard/src/react/components/DialogForReminderItems.jsx +++ b/jgclark.Dashboard/src/react/components/DialogForReminderItems.jsx @@ -2,7 +2,7 @@ //-------------------------------------------------------------------------- // Dashboard React dialog for Apple Reminder items (Interactive Processing + actions). // Edit title/notes/time, reschedule, complete / convert to today / delete / open in Reminders. -// Last updated 2026-10-02 for v2.5.1 by @CursorAI +// Last updated 2026-12-04 for v2.7.0 by @CursorAI //-------------------------------------------------------------------------- import React, { useRef, useLayoutEffect, useState, useCallback } from 'react' @@ -68,7 +68,7 @@ const DialogForReminderItems = ({ details: detailsMessageObject, onClose, positi // Prefer TSectionCode | '' (not | string) so unshift into Array type-checks after the truthiness guard. const sectionCode: TSectionCode | '' = item?.sectionCode || detailsMessageObject.sectionCodes?.[0] || '' const canOpenInReminders = Boolean(pluginData?.appleAppCallbacksAvailable && reminder?.id) - const monthsToShow = pluginData.platform === 'iOS' ? 1 : 2 + const monthsToShow = 2 // fits on phones too, with the smaller cells set in DashboardDialog.css const shouldStartCalendarOpen = Boolean(detailsMessageObject.modifierKey) const startingSelectedDate = reminder?.date ? getDateObjFromDateString(reminder.date) : new Date() @@ -325,63 +325,73 @@ const repositionCalendarForPicker = useCallback((): void => { return null } -// Day-scale reschedule only (week/month/quarter shortcuts omitted for reminders) -// ITEM_ORIG_SECTION resolves at click time to the open item's sectionCode (source section to refresh). -const moveButtons: Array = [ - { label: 'today', controlStr: 't', sectionCodesToRefresh: ['ITEM_ORIG_SECTION', 'DT', 'TB'], handlingFunction: 'rescheduleReminder', description: 'Re-schedule to today' }, - { label: '+1d', controlStr: '+1d', sectionCodesToRefresh: ['ITEM_ORIG_SECTION', 'DO'], handlingFunction: 'rescheduleReminder', description: 'Re-schedule to tomorrow' }, - { label: '+1b', controlStr: '+1b', sectionCodesToRefresh: ['ITEM_ORIG_SECTION', 'DO'], handlingFunction: 'rescheduleReminder', description: 'Re-schedule to next business day' }, - { label: '+2d', controlStr: '+2d', sectionCodesToRefresh: ['ITEM_ORIG_SECTION'], handlingFunction: 'rescheduleReminder', description: 'Re-schedule to 2 days later' }, - { label: '+3d', controlStr: '+3d', sectionCodesToRefresh: ['ITEM_ORIG_SECTION'], handlingFunction: 'rescheduleReminder', description: 'Re-schedule to 3 days later' }, - { label: 'Unsched', controlStr: 'unsched', sectionCodesToRefresh: ['ITEM_ORIG_SECTION', 'REM'], handlingFunction: 'rescheduleReminder', description: 'Remove due date from this reminder' }, -] - -if (sectionCode === 'DT') { - moveButtons.splice(0, 1) // remove 'today' when already in Today -} + // Day-scale reschedule only (week/month/quarter shortcuts omitted for reminders) + // ITEM_ORIG_SECTION resolves at click time to the open item's sectionCode (source section to refresh). + const dayButtons: Array = [ + { label: 'today', controlStr: 't', sectionCodesToRefresh: ['ITEM_ORIG_SECTION', 'DT', 'TB'], handlingFunction: 'rescheduleReminder', description: 'Re-schedule to today' }, + { label: '+1d', controlStr: '+1d', sectionCodesToRefresh: ['ITEM_ORIG_SECTION', 'DO'], handlingFunction: 'rescheduleReminder', description: 'Re-schedule to tomorrow' }, + { label: '+1b', controlStr: '+1b', sectionCodesToRefresh: ['ITEM_ORIG_SECTION', 'DO'], handlingFunction: 'rescheduleReminder', description: 'Re-schedule to next business day' }, + { label: '+2d', controlStr: '+2d', sectionCodesToRefresh: ['ITEM_ORIG_SECTION'], handlingFunction: 'rescheduleReminder', description: 'Re-schedule to 2 days later' }, + { label: '+3d', controlStr: '+3d', sectionCodesToRefresh: ['ITEM_ORIG_SECTION'], handlingFunction: 'rescheduleReminder', description: 'Re-schedule to 3 days later' }, + ] + + if (sectionCode === 'DT') { + dayButtons.splice(0, 1) // remove 'today' when already in Today + } -const actionButtons: Array = [ - { - label: '', - controlStr: 'completereminder', - description: 'Complete reminder', - handlingFunction: 'completeReminder', - icons: [{ className: 'fa-regular fa-circle-check', position: 'left' }], - sectionCodesToRefresh: ['ITEM_ORIG_SECTION'], - }, - { - label: 'Convert to', - controlStr: 'converttotoday', - description: "Convert to task in today's note (and delete reminder)", - handlingFunction: 'convertReminderToTask', - icons: [{ className: 'fa-regular fa-circle', position: 'right' }], - sectionCodesToRefresh: ['ITEM_ORIG_SECTION', 'DT', 'TB'], - }, -] - -if (canOpenInReminders) { - actionButtons.push({ - label: 'Open', - controlStr: 'openreminder', - description: 'Open in Apple Reminders', - handlingFunction: 'openURL', - icons: [{ className: 'fa-regular fa-arrow-up-right-from-square', position: 'right' }], - sectionCodesToRefresh: [], - }) -} + const actionButtons: Array = [ + { + label: 'Complete', + controlStr: 'completereminder', + description: 'Complete reminder', + handlingFunction: 'completeReminder', + icons: [{ className: 'fa-regular fa-circle-check', position: 'left' }], + sectionCodesToRefresh: ['ITEM_ORIG_SECTION'], + }, + { + label: 'Convert to', + controlStr: 'converttotoday', + description: "Convert to task in today's note (and delete reminder)", + handlingFunction: 'convertReminderToTask', + icons: [{ className: 'fa-regular fa-circle', position: 'right' }], + sectionCodesToRefresh: ['ITEM_ORIG_SECTION', 'DT', 'TB'], + }, + ] + + if (canOpenInReminders) { + actionButtons.push({ + label: 'Open', + controlStr: 'openreminder', + description: 'Open in Apple Reminders', + handlingFunction: 'openURL', + icons: [{ className: 'fa-regular fa-arrow-up-right-from-square', position: 'right' }], + sectionCodesToRefresh: [], + }) + } -actionButtons.push( - { - label: '', - controlStr: 'deletereminder', - description: 'Delete reminder', - handlingFunction: 'deleteReminder', - icons: [{ className: 'fa-regular fa-trash-can', position: 'left' }], - sectionCodesToRefresh: ['ITEM_ORIG_SECTION'], - }, -) + actionButtons.push( + { + label: 'Unschedule', + controlStr: 'unsched', + description: 'Remove due date from this reminder', + handlingFunction: 'rescheduleReminder', + icons: [{ className: 'fa-regular fa-calendar-xmark', position: 'left' }], + sectionCodesToRefresh: ['ITEM_ORIG_SECTION', 'REM'], + }, + { + label: 'Delete', + controlStr: 'deletereminder', + description: 'Delete reminder', + handlingFunction: 'deleteReminder', + icons: [{ className: 'fa-regular fa-trash-can', position: 'left' }], + sectionCodesToRefresh: ['ITEM_ORIG_SECTION'], + }, + ) const showBackNavigate = canNavigateBackInIP(currentIPIndex) + const ipPosition = typeof currentIPIndex === 'number' ? currentIPIndex + 1 : 0 + const showIPStatus = Boolean(interactiveProcessing) && ipPosition > 0 + const ipProgressPercent = showIPStatus && totalTasks ? Math.min(100, Math.round((ipPosition / totalTasks) * 1000) / 10) : 0 const titleParts: Array = [] if (reminder.listname) titleParts.push(reminder.listname) @@ -391,41 +401,81 @@ actionButtons.push( logDebug('DialogForReminderItems', `Rendering reminder "${reminder.title || ''}" section=${String(sectionCode)}`) + // Same button markup as DialogForTaskItems: icon, then .buttonLabel, so shared CSS can centre them + const renderActionButton = (button: DialogButtonProps, extraClassName: string = ''): React.Node => ( + + ) + + const renderDateButton = (button: DialogButtonProps): React.Node => ( + + ) + return ( - +
List:
{fromLabel}
- {interactiveProcessing && currentIPIndex !== undefined && ( + {showIPStatus && ( {showBackNavigate && ( )} - {currentIPIndex + 1}/{totalTasks} + + {ipPosition} of {totalTasks} + )} -
+ {showIPStatus ? ( +
+ +
+ ) : null} -
-
-
Reminder:
-
+
+
+
Reminder
+
{/* $FlowFixMe[incompatible-type] */}
+
-
Notes:
-
+
+
Notes
+
{/* $FlowFixMe[incompatible-type] */}
+
-
Schedule:
-
+
+
Time
+
{ if (e.key === 'Enter') { @@ -475,16 +530,13 @@ actionButtons.push( } }} /> - {moveButtons.map((button, index) => ( - - ))} +
+
+ +
+
Schedule
+
+
{dayButtons.map(renderDateButton)}
+
-
Actions:
-
- {actionButtons.map((button, index) => ( - - ))} +
+
Actions
+
+ {actionButtons.map((button) => renderActionButton(button, button.controlStr === 'completereminder' ? 'primaryAction' : ''))}
diff --git a/jgclark.Dashboard/src/react/components/DialogForTaskItems.jsx b/jgclark.Dashboard/src/react/components/DialogForTaskItems.jsx index 4ce4442da..4aeefe9ec 100644 --- a/jgclark.Dashboard/src/react/components/DialogForTaskItems.jsx +++ b/jgclark.Dashboard/src/react/components/DialogForTaskItems.jsx @@ -165,6 +165,9 @@ const DialogForTaskItems = ({ details: detailsMessageObject, onClose, positionDi const [showRawText, setShowRawText] = useState(false) // Text just sent with Update, shown until this item's data catches up (or we move to another item) const [savedContent, setSavedContent] = useState(null) + // Add text note: prompt for text, then insert it as an indented child paragraph + const [textNotePromptOpen, setTextNotePromptOpen] = useState(false) + const [textNoteDraft, setTextNoteDraft] = useState('') // Each new item (e.g. the next one in Interactive Processing) starts formatted again const itemIDForReset = detailsMessageObject?.item?.ID @@ -186,6 +189,8 @@ const DialogForTaskItems = ({ details: detailsMessageObject, onClose, positionDi useEffect(() => { setShowRawText(false) setSavedContent(null) + setTextNotePromptOpen(false) + setTextNoteDraft('') }, [itemIDForReset]) // Editor just swapped in for the formatted text: focus it with the caret where the user clicked. @@ -429,7 +434,14 @@ const DialogForTaskItems = ({ details: detailsMessageObject, onClose, positionDi icons: [{ className: 'fa-regular fa-square-plus', position: 'left' }], sectionCodesToRefresh: [], }, - // TODO: Add a 'Add comment' button for @Garba + { + label: 'Add text note', + controlStr: 'addtextnote', + description: 'Add a text note to the item', + handlingFunction: 'addTextNote', + icons: [{ className: 'fa-regular fa-comment', position: 'left' }], + sectionCodesToRefresh: ['ITEM_ORIG_SECTION'], + }, ] // Now filter out some that cannot be shown: @@ -648,8 +660,13 @@ const DialogForTaskItems = ({ details: detailsMessageObject, onClose, positionDi return true } - function handleButtonClick(event: MouseEvent, controlStr: string, handlingFunction: string, sectionCodesToRefresh: Array) { + function handleButtonClick(event: MouseEvent | KeyboardEvent, controlStr: string, handlingFunction: string, sectionCodesToRefresh: Array, commentText?: string) { if (controlStr === 'qath' && openAddDialogForNewTask()) return + // Add comment asks for the text first. The text arrives on the second call, after the prompt is submitted. + if (controlStr === 'addtextnote' && (commentText == null || commentText.trim() === '')) { + setTextNotePromptOpen(true) + return + } const { metaKey } = extractModifierKeys(event) // Indicates whether ⌘-key was pressed // clo(detailsMessageObject, 'handleButtonClick detailsMessageObject') const currentContent = savedContent ?? para.content @@ -693,6 +710,8 @@ const DialogForTaskItems = ({ details: detailsMessageObject, onClose, positionDi actionType: handlingFunction, controlStr: controlStr, updatedContent: contentActuallyChanged ? inputValue : '', + // Comment text is separate from updatedContent, which is a pending edit of the item itself + userInputObj: controlStr === 'addcomment' ? { commentText: (commentText ?? '').trim() } : undefined, sectionCodes: sectionCodesToSend, } if (contentActuallyChanged) { @@ -702,8 +721,12 @@ const DialogForTaskItems = ({ details: detailsMessageObject, onClose, positionDi setContentHasChanged(false) } - // Don't close dialog yet if openNote button or one of the priority buttons clicked - if (controlStr === 'openNote' || controlStr.startsWith('pri')) { + // Don't close dialog yet if openNote, a priority button, or Add comment was clicked + if (controlStr === 'openNote' || controlStr.startsWith('pri') || controlStr === 'addtextnote') { + if (controlStr === 'addtextnote') { + setTextNotePromptOpen(false) + setTextNoteDraft('') + } return } @@ -1151,6 +1174,47 @@ const DialogForTaskItems = ({ details: detailsMessageObject, onClose, positionDi
+ + {textNotePromptOpen ? ( +
+
Text note
+
+