(submenu: Menu, task: TaskInfo, plugin: TaskNotesPlugin)
| 1665 | } |
| 1666 | |
| 1667 | private addStatusOptions(submenu: Menu, task: TaskInfo, plugin: TaskNotesPlugin): void { |
| 1668 | const statusOptions = this.getStatusOptions(task, plugin); |
| 1669 | |
| 1670 | statusOptions.forEach((option, index) => { |
| 1671 | submenu.addItem((item) => { |
| 1672 | const label = toMenuTitle(option.label, option.value); |
| 1673 | let title = label; |
| 1674 | |
| 1675 | // Use custom icon if configured, otherwise default to circle |
| 1676 | item.setIcon(option.icon || "circle"); |
| 1677 | |
| 1678 | // Highlight current selection with visual indicator |
| 1679 | if (option.value === task.status) { |
| 1680 | title = this.t("contextMenus.task.statusSelected", { label }); |
| 1681 | } |
| 1682 | |
| 1683 | item.setTitle(title); |
| 1684 | |
| 1685 | item.onClick(async () => { |
| 1686 | try { |
| 1687 | await plugin.updateTaskProperty(task, "status", option.value); |
| 1688 | this.options.onUpdate?.(); |
| 1689 | } catch (error) { |
| 1690 | const errorMessage = error instanceof Error ? error.message : String(error); |
| 1691 | tasknotesLogger.error("Error updating task status:", { |
| 1692 | category: "persistence", |
| 1693 | operation: "updating-task-status", |
| 1694 | details: { taskPath: task.path }, |
| 1695 | error: errorMessage, |
| 1696 | }); |
| 1697 | new Notice(`Failed to update task status: ${errorMessage}`); |
| 1698 | } |
| 1699 | }); |
| 1700 | |
| 1701 | // Apply color directly to this item |
| 1702 | const optionColor = option.color; |
| 1703 | if (optionColor) { |
| 1704 | window.setTimeout(() => { |
| 1705 | const itemEl = getMenuItemElement(item); |
| 1706 | if (itemEl) { |
| 1707 | const iconEl = itemEl.querySelector(".menu-item-icon"); |
| 1708 | if (iconEl) { |
| 1709 | (iconEl as HTMLElement).style.color = optionColor; |
| 1710 | } |
| 1711 | } |
| 1712 | }, 10); |
| 1713 | } |
| 1714 | }); |
| 1715 | }); |
| 1716 | } |
| 1717 | |
| 1718 | private addPriorityOptions(submenu: Menu, task: TaskInfo, plugin: TaskNotesPlugin): void { |
| 1719 | const priorityOptions = plugin.priorityManager.getPrioritiesByWeight(); |
no test coverage detected