Skip to content

Commit aec24e3

Browse files
committed
Add '+New Task' button to DialogForTaskItems
1 parent 3b13b66 commit aec24e3

File tree

5 files changed

+40
-10
lines changed

5 files changed

+40
-10
lines changed

jgclark.Dashboard/CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# What's changed in 🎛 Dashboard plugin?
22
For more details see the [plugin's documentation](https://github.com/NotePlan/plugins/tree/main/jgclark.Dashboard/).
33

4-
## [2.1.8] 2025-01-31 (unreleased)
4+
<!-- Hiding from view as we are on the main branch
5+
## [2.1.8] 2025-02-01 (unreleased)
6+
### New
7+
- Added a '+ New Task' button to the end of the Task edit dialog. This effectively runs the '/quick add task under heading' command (from Quick Capture) which allows you to add a new task in any note under any heading without having to leave the Dashboard.
58
### Changed
69
- When clicking on a Section Title or note link, the note will be opened in the Editor window, and that will now be brought to the front.
710
- The Edit All Perspectives table now has subtly shaded alternate rows
8-
- The window starts saying 'Generating' not 'Refreshing'
11+
- The window starts saying 'Generating' not 'Refreshing' -->
912

1013
## [2.1.7] 2025-01-30
1114
### Changed

jgclark.Dashboard/src/clickHandlers.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Handler functions for some dashboard clicks that come over the bridge.
55
// There are 4+ other clickHandler files now.
66
// The routing is in pluginToHTMLBridge.js/bridgeClickDashboardItem()
7-
// Last updated for v2.1.6
7+
// Last updated for v2.1.8
88
//-----------------------------------------------------------------------------
99
import moment from 'moment'
1010
import { getDashboardSettings, handlerResult, setPluginData } from './dashboardHelpers'
@@ -110,6 +110,17 @@ export async function doAddItem(data: MessageDataObject): Promise<TBridgeClickHa
110110
}
111111
}
112112

113+
/**
114+
* Add a new item anywhere, using the /quickAddTaskUnderHeading command from Quick Capture plugin.
115+
* Calls the doAddItem logic, once new filename is worked out.
116+
* @param {MessageDataObject} {date: .data.data.data, text: .data.data.}
117+
* @returns {TBridgeClickHandlerResult} result to be used by click result handler
118+
*/
119+
export async function doAddTaskAnywhere(): Promise<void> {
120+
logDebug('doAddTaskAnywhere', `starting. Just calling addTaskToNoteHeading().`)
121+
const res = await DataStore.invokePluginCommandByName('quick add task under heading', 'jgclark.QuickCapture') // with no args, this will prompt for the note, heading and text
122+
}
123+
113124
/**
114125
* Add a new item to a future date, using the date and text provided.
115126
* Calls the doAddItem logic, once new filename is worked out.
@@ -121,8 +132,8 @@ export async function doAddItemToFuture(data: MessageDataObject): Promise<TBridg
121132
const { userInputObj } = data // "date": "2024-12-04T08:00:00.000Z",
122133
if (!userInputObj) return handlerResult(false)
123134
const { date, text } = userInputObj
124-
if (!text) return handlerResult(false, [], { errorMsg: `No text was provided to addItemToFuture: "${date}"` })
125-
if (!date) return handlerResult(false, [], { errorMsg: `No date was provided to addItemToFuture: "${text}"` })
135+
if (!text) return handlerResult(false, [], { errorMsg: `No text was provided to addItemToFuture` })
136+
if (!date) return handlerResult(false, [], { errorMsg: `No date was provided to addItemToFuture` })
126137
const extension = DataStore.defaultFileExtension
127138
const filename = `${moment(date).format(`YYYYMMDD`)}.${extension}`
128139
data.toFilename = filename

jgclark.Dashboard/src/pluginToHTMLBridge.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
// @flow
22
//-----------------------------------------------------------------------------
33
// Bridging functions for Dashboard plugin
4-
// Last updated for v2.1.6
4+
// Last updated for v2.1.8
55
//-----------------------------------------------------------------------------
66

77
import pluginJson from '../plugin.json'
88
import { allCalendarSectionCodes, allSectionCodes, WEBVIEW_WINDOW_ID } from './constants'
99
import {
1010
doAddItem,
1111
doAddItemToFuture,
12+
doAddTaskAnywhere,
1213
doCancelChecklist,
1314
doCancelTask,
1415
doContentUpdate,
@@ -310,6 +311,11 @@ export async function bridgeClickDashboardItem(data: MessageDataObject) {
310311
result = await doAddItem(data)
311312
break
312313
}
314+
case 'addTaskAnywhere': {
315+
// Note: calls Quick Capture plugin /qath command which doesn't return anything
316+
await doAddTaskAnywhere()
317+
break
318+
}
313319
case 'addTaskToFuture': {
314320
result = await doAddItemToFuture(data)
315321
break

jgclark.Dashboard/src/react/components/DialogForTaskItems.jsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//--------------------------------------------------------------------------
33
// Dashboard React component to show the Dialog for tasks
44
// Called by TaskItem component
5-
// Last updated 2025-01-13 for v2.1.3
5+
// Last updated 2025-02-01 for v2.1.8
66
//--------------------------------------------------------------------------
77
// Notes:
88
// - onClose & detailsMessageObject are passed down from Dashboard.jsx::handleDialogClose
@@ -69,6 +69,7 @@ const DialogForTaskItems = ({ details: detailsMessageObject, onClose, positionDi
6969
{ label: '+1w', controlStr: '+1w' },
7070
{ label: '+2w', controlStr: '+2w' },
7171
{ label: 'this month', controlStr: '+0m' },
72+
{ label: '+1m', controlStr: '+1m' },
7273
{ label: 'this quarter', controlStr: '+0q' },
7374
]
7475

@@ -134,17 +135,25 @@ const DialogForTaskItems = ({ details: detailsMessageObject, onClose, positionDi
134135
icons: [{ className: itemType === 'checklist' ? 'fa-regular fa-circle' : 'fa-regular fa-square', position: 'right' }],
135136
},
136137
{
137-
label: 'Complete Then',
138+
label: 'Complete',
138139
controlStr: 'commpletethen',
139140
description: 'Mark the item as completed on the date it was scheduled for',
140141
handlingFunction: 'completeTaskThen',
142+
icons: [{ className: 'fa-regular fa-arrow-left', position: 'left' }],
141143
},
142144
{
143-
label: 'Unschedule',
145+
label: 'Unsched',
144146
controlStr: 'unsched',
145147
description: 'Remove date from this item',
146148
handlingFunction: 'unscheduleItem',
147149
},
150+
{
151+
label: 'New Task',
152+
controlStr: 'qath',
153+
description: 'New task',
154+
handlingFunction: 'addTaskAnywhere',
155+
icons: [{ className: 'fa-regular fa-hexagon-plus', position: 'left' }],
156+
},
148157
]
149158
// Now apply the filter with an explicit return type
150159
const otherControlButtons: Array<DialogButtonProps> = initialOtherControlButtons.filter((button): boolean => (isDesktop ? true : !buttonsToHideOnMobile.includes(button.label)))

jgclark.Dashboard/src/types.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @flow
22
//-----------------------------------------------------------------------------
33
// Types for Dashboard code
4-
// Last updated for v2.1.0.a
4+
// Last updated for v2.1.8
55
//-----------------------------------------------------------------------------
66
// Types for Settings
77

@@ -194,6 +194,7 @@ export type TActionType =
194194
| 'addChecklist'
195195
| 'addProgress'
196196
| 'addTask'
197+
| 'addTaskAnywhere'
197198
| 'addTaskToFuture'
198199
| 'cancelProject'
199200
| 'cancelTask'

0 commit comments

Comments
 (0)