Skip to content

Commit f7cb092

Browse files
committed
2.2.1 for DBW test: adds 'due date' option for Tag/Overdue sections
1 parent b2c15d3 commit f7cb092

File tree

7 files changed

+59
-55
lines changed

7 files changed

+59
-55
lines changed

jgclark.Dashboard/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ For more details see the [plugin's documentation](https://github.com/NotePlan/pl
77
- TODO: ^⌥s triggers the search bar
88
- TODO: fix long-standing layout bug where some tooltips were getting clipped
99
-->
10+
## [2.2.1] 2025-04-???
11+
### New
12+
- you can now order results in Tag and Overdue sections by due date, as well as by the existing options (for @LauraH)
13+
1014
## [2.2.0] 2025-04-11
1115
### New
1216
- Search section. Click on the new icon in the header and a small search bar opens up, where you can type a term to search for open tasks and checklists in regular or calendar notes. This uses the extended syntax from my separate [Search Extensions plugin](https://noteplan.co/plugins/jgclark.SearchExtensions/) to allow more complex searches than NotePlan natively allows. The Search Section stays until either you manually refresh the dashboard, or you click the close `[x]` button. This means you can edit the items like any other section contents, and also use Interactive Processing.

jgclark.Dashboard/plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"plugin.name": "🎛 Dashboard",
66
"plugin.description": "A Dashboard for NotePlan, that in one place shows\n- a compact list of open tasks and checklists from today's note\n- scheduled open tasks and checklists from other notes.\n- Similarly for yesterday's note, tomorrow's note, and the weekly, monthly and quarterly notes too (if used)\n- all overdue tasks\n- all open tasks and checklists that contain particular @tags or #mentions of your choosing\n- the next notes ready to review (if you use the 'Projects and Reviews' plugin).",
77
"plugin.author": "@jgclark",
8-
"plugin.version": "2.2.0",
8+
"plugin.version": "2.2.1",
99
"plugin.hidden": false,
10-
"plugin.lastUpdateInfo": "2.2.0: Add 'Search' section. New keyboard shortcuts. Plus many small improvements, bug fixes and performance improvements. See documentation for details.\n2.1.10: More move-under-heading options. Bug fixes and performance improvements.\n2.1.9: performance improvements and better UI for iPhone users.\n2.1.8: various fixes and small improvements.\n2.1.7: various fixes and small improvements.\n2.1.6: allow all current timeblocks to be shown, not just the first. Add new @repeat()s if using the extended syntax from the Repeat Extensions plugin. Bug fixes.\n2.1.5: fixes to time blocks and scheduling items.\n2.1.4: fix to Interactive Processing, and Edit All Perspectives dialog now shows unsaved changes.\n2.1.3: fixes to display of timeblocks, and checklist counts being wrong. Slightly smarter task dialog.\n2.1.2: fix bug - Today section not showing up; fix settings description for max items to show.\n2.1.1: fix bug - Tomorrow section not showing up.\n2.1.0: Add Perspectives; new 'Current Time Block' section; new 'Last Week' section; and many other improvements and fixes.\n2.0.0: major new release with many new features, following major re-write.",
10+
"plugin.lastUpdateInfo": "2.2.1: Add new sorting option for Tag and Overdue sections.\n2.2.0: Add 'Search' section. New keyboard shortcuts. Plus many small improvements, bug fixes and performance improvements. See documentation for details.\n2.1.10: More move-under-heading options. Bug fixes and performance improvements.\n2.1.9: performance improvements and better UI for iPhone users.\n2.1.8: various fixes and small improvements.\n2.1.7: various fixes and small improvements.\n2.1.6: allow all current timeblocks to be shown, not just the first. Add new @repeat()s if using the extended syntax from the Repeat Extensions plugin. Bug fixes.\n2.1.5: fixes to time blocks and scheduling items.\n2.1.4: fix to Interactive Processing, and Edit All Perspectives dialog now shows unsaved changes.\n2.1.3: fixes to display of timeblocks, and checklist counts being wrong. Slightly smarter task dialog.\n2.1.2: fix bug - Today section not showing up; fix settings description for max items to show.\n2.1.1: fix bug - Tomorrow section not showing up.\n2.1.0: Add Perspectives; new 'Current Time Block' section; new 'Last Week' section; and many other improvements and fixes.\n2.0.0: major new release with many new features, following major re-write.",
1111
"plugin.dependencies": [],
1212
"plugin.requiredFiles": [
1313
"react.c.WebView.bundle.dev.js"

jgclark.Dashboard/src/dashboardHelpers.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @flow
22
//-----------------------------------------------------------------------------
33
// Dashboard plugin helper functions
4-
// Last updated 2025-04-10 for v2.2.0.a13
4+
// Last updated 2025-04-15 for v2.2.1, @jgclark
55
//-----------------------------------------------------------------------------
66

77
import moment from 'moment/min/moment-with-locales'
@@ -28,13 +28,15 @@ import { createRunPluginCallbackUrl, displayTitle } from '@helpers/general'
2828
import { getHeadingHierarchyForThisPara } from '@helpers/headings'
2929
import { sendToHTMLWindow, getGlobalSharedData } from '@helpers/HTMLView'
3030
import { filterOutParasInExcludeFolders, isNoteFromAllowedFolder, pastCalendarNotes, projectNotesFromFilteredFolders } from '@helpers/note'
31+
import { getFirstDateInPeriod } from '@helpers/NPdateTime'
3132
import { getReferencedParagraphs } from '@helpers/NPnote'
3233
import { isAChildPara } from '@helpers/parentsAndChildren'
34+
import { RE_FIRST_SCHEDULED_DATE_CAPTURE } from '@helpers/regex'
3335
import { caseInsensitiveSubstringIncludes } from '@helpers/search'
3436
import { getNumericPriorityFromPara } from '@helpers/sorting'
3537
import { eliminateDuplicateSyncedParagraphs } from '@helpers/syncedCopies'
3638
import { getStartTimeObjFromParaContent, getTimeBlockString, isActiveOrFutureTimeBlockPara } from '@helpers/timeblocks'
37-
import { isOpen, isOpenNotScheduled, removeDuplicates } from '@helpers/utils'
39+
import { hasScheduledDate, isOpen, isOpenNotScheduled, removeDuplicates } from '@helpers/utils'
3840

3941
//-----------------------------------------------------------------
4042
// Settings
@@ -206,6 +208,23 @@ export function makeDashboardParas(origParas: Array<TParagraph>): Array<TParagra
206208
const anyChildren = p.children()
207209
const hasChild = anyChildren && anyChildren.length > 0
208210
const isAChild = isAChildPara(p, note)
211+
let dueDateStr = 'none'
212+
const hasDueDate = hasScheduledDate(p.content)
213+
if (hasDueDate) {
214+
const dueDateMatch = p.content.match(RE_FIRST_SCHEDULED_DATE_CAPTURE)
215+
if (dueDateMatch) {
216+
dueDateStr = getFirstDateInPeriod(dueDateMatch[0], 'day')
217+
}
218+
} else {
219+
// If this is from a calendar note, then use that date instead
220+
if (note.type === 'Calendar') {
221+
const dueDate = getFirstDateInPeriod(note.title, 'day')
222+
if (dueDate) {
223+
dueDateStr = dueDate
224+
}
225+
}
226+
}
227+
// logDebug('makeDashboardParas', `dueDateStr: ${dueDateStr} in note ${note.filename}`)
209228

210229
// Note: debugging why sometimes hasChild is wrong
211230
// TODO(later): remove this debugging
@@ -236,11 +255,11 @@ export function makeDashboardParas(origParas: Array<TParagraph>): Array<TParagra
236255
indentLevel: p.indents, // TEST: not returning correct indents at times?
237256
lineIndex: p.lineIndex,
238257
priority: getNumericPriorityFromPara(p),
239-
// timeStr: startTime,
240258
startTime: startTimeStr,
241259
changedDate: note?.changedDate,
242260
hasChild: hasChild,
243261
isAChild: isAChild,
262+
dueDate: dueDateStr,
244263
}
245264
} else {
246265
logWarn('makeDashboardParas', `No note found for para {${p.content}}`)

jgclark.Dashboard/src/dashboardSettings.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @flow
22
//-----------------------------------------------------------------------------
33
// Settings for the dashboard - loaded/set in React Window
4-
// Last updated 2025-04-09 for v2.2.0.a12
4+
// Last updated 2025-04-15 for v2.2.1, @jgclark
55
//-----------------------------------------------------------------------------
66
import type { TSettingItem } from './types.js'
77
import { clo, clof, logDebug } from '@helpers/react/reactDev'
@@ -243,6 +243,16 @@ export const dashboardSettingDefs: Array<TSettingItem> = [
243243
default: false,
244244
refreshAllOnChange: true,
245245
},
246+
{
247+
key: 'overdueSortOrder',
248+
label: 'Sort order for Tag/Mention and Overdue items',
249+
description:
250+
"The order to show items: 'priority' shows the higher priority (from `>>`, `!!!`, `!!` and `!` markers), 'earliest' by earliest modified date of the note, 'due date' by the due date (if present), or 'most recent' changed note.",
251+
type: 'dropdown-select',
252+
options: ['priority', 'earliest', 'due date', 'most recent'],
253+
default: 'priority',
254+
compactDisplay: true,
255+
},
246256
{
247257
label: 'Hide priority markers?',
248258
key: 'hidePriorityMarkers',
@@ -311,17 +321,6 @@ export const dashboardSettingDefs: Array<TSettingItem> = [
311321
type: 'heading',
312322
label: 'Overdue Tasks section',
313323
},
314-
{
315-
key: 'overdueSortOrder',
316-
label: 'Sort order for Tag/Mention and Overdue items',
317-
description:
318-
"The order to show items: 'priority' shows the higher priority (from `>>`, `!!!`, `!!` and `!` markers), 'earliest' by earliest modified date of the note, or 'most recent' changed note.",
319-
type: 'dropdown-select',
320-
options: ['priority', 'earliest', 'most recent'],
321-
default: 'priority',
322-
compactDisplay: true,
323-
// fixedWidth: 150,
324-
},
325324
{
326325
key: 'lookBackDaysForOverdue',
327326
label: 'Number of days to look back for Overdue tasks',

jgclark.Dashboard/src/dataGeneration.js

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @flow
22
//-----------------------------------------------------------------------------
33
// Dashboard plugin main function to generate data
4-
// Last updated 2025-04-01 for v2.2.0.a10, @jgclark
4+
// Last updated 2025-04-15 for v2.2.1, @jgclark
55
//-----------------------------------------------------------------------------
66

77
import moment from 'moment/min/moment-with-locales'
@@ -547,33 +547,6 @@ export function getThisQuarterSectionData(config: TDashboardSettings, useDemoDat
547547
// fa-calendar-days (same as quarter). This would be section #6
548548
//----------------------------------------------------------------
549549

550-
/**
551-
* Note: now not used, as core of it is now in getSomeSectionsData() above. This is because:
552-
* 1. it is really just a wrapper around getTaggedSectionData()
553-
* 2. this means multiple TAG sections can be returned as they are generated, rather than all at once, which feels more natural.
554-
* Get the tagged sections for each tag - they will all be sectionCode=TAG
555-
* sectionName will be the tag name, and showSettingName will be unique for this tag
556-
* @param {TDashboardSettings} config
557-
* @param {boolean} [useDemoData=false]
558-
* @returns {Array<TSection>}
559-
*/
560-
// export function getTaggedSections(config: TDashboardSettings, useDemoData: boolean = false): Array<TSection> {
561-
// const startTime = new Date()
562-
// const tagSections = getTagSectionDetails(removeInvalidTagSections(config))
563-
// // clo(tagSections)
564-
// // logInfo('getTaggedSections', `- after getTagSectionDetails: ${timer(startTime)}`)
565-
//
566-
// const output = tagSections.reduce((acc: Array<TSection>, sectionDetail: TSectionDetails, index: number) => {
567-
// // $FlowIgnore[invalid-computed-prop]
568-
// const showSettingForTag = config[sectionDetail.showSettingName]
569-
// // logDebug('getTaggedSections', `sectionDetail.sectionName=${sectionDetail.sectionName} showSettingForTag=${showSettingForTag}`)
570-
// if (typeof showSettingForTag === 'undefined' || showSettingForTag) acc.push(getTaggedSectionData(config, useDemoData, sectionDetail, index))
571-
// return acc // Return the accumulator
572-
// }, [])
573-
// logTimer('getTaggedSections', startTime, `at end`, 1500)
574-
// return output
575-
// }
576-
577550
/**
578551
* Generate data for a section for items with a Tag/Mention.
579552
* Only find paras with this *single* tag/mention which include open tasks that aren't scheduled in the future.
@@ -720,8 +693,10 @@ export async function getTaggedSectionData(config: TDashboardSettings, useDemoDa
720693
config.overdueSortOrder === 'priority'
721694
? ['-priority', '-changedDate']
722695
: config.overdueSortOrder === 'earliest'
723-
? ['changedDate', 'priority']
724-
: ['-changedDate', 'priority'] // 'most recent'
696+
? ['changedDate', '-priority']
697+
: config.overdueSortOrder === 'due date'
698+
? ['dueDate', '-priority']
699+
: ['-changedDate', '-priority'] // 'most recent'
725700
const sortedTagParas = sortListBy(dashboardParas, sortOrder)
726701
logTimer('getTaggedSectionData', thisStartTime, `- Filtered, Reduced & Sorted ${sortedTagParas.length} items by ${String(sortOrder)}`)
727702

@@ -828,7 +803,13 @@ export async function getOverdueSectionData(config: TDashboardSettings, useDemoD
828803

829804
// Sort paragraphs by one of several options
830805
const sortOrder =
831-
config.overdueSortOrder === 'priority' ? ['-priority', '-changedDate'] : config.overdueSortOrder === 'earliest' ? ['changedDate', 'priority'] : ['-changedDate', 'priority'] // 'most recent'
806+
config.overdueSortOrder === 'priority'
807+
? ['-priority', '-changedDate']
808+
: config.overdueSortOrder === 'earliest'
809+
? ['changedDate', '-priority']
810+
: config.overdueSortOrder === 'due date'
811+
? ['dueDate', '-priority']
812+
: ['-changedDate', '-priority'] // 'most recent'
832813
const sortedOverdueTaskParas = sortListBy(dashboardParas, sortOrder)
833814
logDebug('getOverdueSectionData', `- Sorted ${sortedOverdueTaskParas.length} items by ${String(sortOrder)} after ${timer(thisStartTime)}`)
834815

jgclark.Dashboard/src/types.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @flow
22
//-----------------------------------------------------------------------------
33
// Types for Dashboard code
4-
// Last updated 2025-04-09 for v2.2.0.a12, @jgclark
4+
// Last updated 2025-04-15 for v2.2.1, @jgclark
55
//-----------------------------------------------------------------------------
66
// Types for Settings
77

@@ -84,7 +84,7 @@ export type TDashboardSettings = {
8484
moveSubItems: boolean,
8585
newTaskSectionHeading: string,
8686
newTaskSectionHeadingLevel: number,
87-
overdueSortOrder: string,
87+
overdueSortOrder: string, // 'priority' | 'earliest' | 'most recent'
8888
parentChildMarkersEnabled: boolean,
8989
rescheduleNotMove: boolean,
9090
separateSectionForReferencedNotes: boolean,
@@ -179,13 +179,12 @@ export type TParagraphForDashboard = {
179179
lineIndex: number, // needed for child ordering processing
180180
priority: number,
181181
blockId?: string,
182-
// timeStr?: string, // = used to order extended paragraphs. TEST: Can it be consolidated with .startTime?
183182
startTime?: string, // this is still definitely used to style time blocks
184183
endTime?: string,
185184
changedDate?: Date, // required for sorting items in display
186185
hasChild?: boolean, // whether it has child item(s)
187186
isAChild?: boolean, // whether it is a child item
188-
// children?: Function, // TEST: removing it as JGC can't see it being used on 2024-12-10
187+
dueDate?: string, // ISO string of due date, or 'none', required for sorting items in display
189188
}
190189

191190
// a project item within a section

np.Tidy/src/tidyMain.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//-----------------------------------------------------------------------------
33
// Main functions for Tidy plugin
44
// Jonathan Clark
5-
// Last updated 2024-12-18 for v0.14.4, @jgclark
5+
// Last updated 2025-03-11 for v0.14.5, @jgclark
66
//-----------------------------------------------------------------------------
77

88
import moment from 'moment/min/moment-with-locales'
@@ -323,6 +323,8 @@ export async function removeDoneTimeParts(params: string = ''): Promise<void> {
323323
/**
324324
* Remove a given section (by matching on their section heading) from recently-changed Notes. Note: does not match on note title.
325325
* Can be passed parameters to override default time interval through an x-callback call.
326+
* FIXME: Found 248 'Stats' sections in my notes.
327+
* FIXME: numDays
326328
* @author @jgclark
327329
* @param {?string} params optional JSON string
328330
*/
@@ -341,7 +343,7 @@ export async function removeSectionFromRecentNotes(params: string = ''): Promise
341343
}
342344

343345
// Get num days to process from param, or by asking user if necessary
344-
const numDays: number = await getTagParamsFromString(params ?? '', 'numDays', config.numDays ?? 0)
346+
const numDays: number = await getTagParamsFromString(params ?? '', 'numDays', config.numDays || 0)
345347
logDebug('removeSectionFromRecentNotes', `numDays = ${String(numDays)}`)
346348
// Note: can be 0 at this point, which implies process all days
347349

@@ -395,7 +397,7 @@ export async function removeSectionFromRecentNotes(params: string = ''): Promise
395397
// Check user wants to proceed (if not calledWithParams)
396398
if (!runSilently) {
397399
const res = await showMessageYesNo(`Do you want to remove ${String(numToRemove)} '${sectionHeading}' sections?`, ['Yes', 'No'], 'Remove Section from Notes')
398-
if (res === 'No') {
400+
if (res !== 'Yes') {
399401
logInfo('removeSectionFromRecentNotes', `User cancelled operation`)
400402
return
401403
}

0 commit comments

Comments
 (0)