MCPcopy
hub / github.com/callumalpass/tasknotes / attachDateClickHandler

Function attachDateClickHandler

src/ui/taskCardProperties.ts:133–179  ·  view source on GitHub ↗
(
	span: HTMLElement,
	task: TaskInfo,
	plugin: TaskNotesPlugin,
	dateType: "due" | "scheduled"
)

Source from the content-addressed store, hash-verified

131}
132
133function attachDateClickHandler(
134 span: HTMLElement,
135 task: TaskInfo,
136 plugin: TaskNotesPlugin,
137 dateType: "due" | "scheduled"
138): void {
139 prepareInteractiveControl(span);
140 span.addEventListener("click", (event) => {
141 event.stopPropagation();
142 const currentValue = dateType === "due" ? task.due : task.scheduled;
143 const menu = new DateContextMenu({
144 currentValue: getDatePart(currentValue || ""),
145 currentTime: getTimePart(currentValue || ""),
146 onSelect: (dateValue, timeValue) => {
147 void (async () => {
148 try {
149 let finalValue: string | undefined;
150 if (!dateValue) {
151 finalValue = undefined;
152 } else if (timeValue) {
153 finalValue = `${dateValue}T${timeValue}`;
154 } else {
155 finalValue = dateValue;
156 }
157 await plugin.updateTaskProperty(task, dateType, finalValue);
158 } catch (error) {
159 const errorMessage = error instanceof Error ? error.message : String(error);
160 tasknotesLogger.error(`Error updating ${dateType} date:`, {
161 category: "persistence",
162 operation: "updating",
163 details: { value: errorMessage },
164 });
165 const noticeKey =
166 dateType === "due"
167 ? "contextMenus.task.notices.updateDueDateFailure"
168 : "contextMenus.task.notices.updateScheduledFailure";
169 new Notice(plugin.i18n.translate(noticeKey, { message: errorMessage }));
170 }
171 })();
172 },
173 dateRole: dateType,
174 plugin,
175 app: plugin.app,
176 });
177 menu.show(event);
178 });
179}
180
181export function getDefaultVisibleProperties(plugin: TaskNotesPlugin): string[] {
182 const internalDefaults = [

Callers 2

renderDueDatePropertyFunction · 0.85

Calls 7

showMethod · 0.95
getDatePartFunction · 0.90
getTimePartFunction · 0.90
updateTaskPropertyMethod · 0.80
errorMethod · 0.80
translateMethod · 0.65

Tested by

no test coverage detected