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

Class StatusContextMenu

src/components/StatusContextMenu.ts:17–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15}
16
17export class StatusContextMenu {
18 private menu: ContextMenu;
19 private options: StatusContextMenuOptions;
20 private targetDoc: Document = activeDocument;
21
22 constructor(options: StatusContextMenuOptions) {
23 this.menu = new ContextMenu();
24 this.options = options;
25 this.buildMenu();
26 }
27
28 private buildMenu(): void {
29 const statusOptions = this.getStatusOptions();
30
31 statusOptions.forEach((option, index) => {
32 this.menu.addItem((item) => {
33 let title = option.label;
34
35 // Use custom icon if configured, otherwise default to circle
36 item.setIcon(option.icon || "circle");
37
38 // Highlight current selection with visual indicator
39 if (option.value === this.options.currentValue) {
40 title = `✓ ${option.label}`;
41 }
42
43 item.setTitle(title);
44
45 item.onClick(async () => {
46 this.options.onSelect(option.value);
47 });
48 });
49 });
50 }
51
52 private getStatusOptions(): StatusOption[] {
53 const statusConfigs = this.options.plugin.settings.customStatuses;
54 const statusOptions: StatusOption[] = [];
55
56 // Use only the user-defined statuses from settings
57 if (statusConfigs && statusConfigs.length > 0) {
58 // Sort by order property
59 const sortedStatuses = [...statusConfigs].sort((a, b) => a.order - b.order);
60
61 sortedStatuses.forEach((status) => {
62 statusOptions.push({
63 label: status.label,
64 value: status.value,
65 color: status.color,
66 icon: status.icon,
67 });
68 });
69 }
70
71 return statusOptions;
72 }
73
74 private capitalizeFirst(str: string): string {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected