(
element: HTMLElement,
task: TaskInfo,
plugin: TaskNotesPlugin,
visibleProperties?: string[],
options: Partial<TaskCardOptions> = {}
)
| 284 | * Update an existing task card with new data |
| 285 | */ |
| 286 | export function updateTaskCard( |
| 287 | element: HTMLElement, |
| 288 | task: TaskInfo, |
| 289 | plugin: TaskNotesPlugin, |
| 290 | visibleProperties?: string[], |
| 291 | options: Partial<TaskCardOptions> = {} |
| 292 | ): void { |
| 293 | const opts = { ...DEFAULT_TASK_CARD_OPTIONS, ...options }; |
| 294 | const renderState = buildTaskCardRenderState(task, plugin, opts); |
| 295 | const { targetDate, effectiveStatus, isCompleted, hasDetails } = renderState; |
| 296 | |
| 297 | element.className = renderState.cardClasses.join(" "); |
| 298 | element.dataset.status = effectiveStatus; |
| 299 | if (task.priority) { |
| 300 | element.dataset.priority = task.priority; |
| 301 | } else { |
| 302 | delete element.dataset.priority; |
| 303 | } |
| 304 | element.dataset.hasDetails = hasDetails ? "true" : "false"; |
| 305 | |
| 306 | // Get the main row container |
| 307 | const mainRow = element.querySelector(".task-card__main-row") as HTMLElement; |
| 308 | |
| 309 | applyTaskCardPriorityColor(element, task, plugin); |
| 310 | |
| 311 | // Update checkbox if present |
| 312 | const checkbox = element.querySelector(".task-card__checkbox") as HTMLInputElement; |
| 313 | if (checkbox) { |
| 314 | checkbox.checked = plugin.statusManager.isCompletedStatus(effectiveStatus); |
| 315 | } |
| 316 | |
| 317 | updateStatusIndicator({ |
| 318 | mainRow, |
| 319 | card: element, |
| 320 | task, |
| 321 | plugin, |
| 322 | effectiveStatus, |
| 323 | visibleProperties, |
| 324 | hideStatusIndicator: opts.hideStatusIndicator, |
| 325 | onClick: createStatusCycleHandler({ |
| 326 | task, |
| 327 | plugin, |
| 328 | targetDate, |
| 329 | updateStatusVisuals: (updatedTask, effectiveStatus, isCompleted) => { |
| 330 | const currentStatusDot = |
| 331 | element.querySelector<HTMLElement>(".task-card__status-dot"); |
| 332 | if (currentStatusDot) { |
| 333 | updateTaskCardStatusIndicatorVisuals({ |
| 334 | card: element, |
| 335 | statusDot: currentStatusDot, |
| 336 | plugin, |
| 337 | updatedTask, |
| 338 | effectiveStatus, |
| 339 | isCompleted, |
| 340 | }); |
| 341 | } |
| 342 | }, |
| 343 | }), |
no test coverage detected