| 5 | import { ContextMenu } from "./ContextMenu"; |
| 6 | |
| 7 | export class ReminderContextMenu { |
| 8 | private plugin: TaskNotesPlugin; |
| 9 | private task: TaskInfo; |
| 10 | private triggerElement: HTMLElement; |
| 11 | private onUpdate: (task: TaskInfo) => void; |
| 12 | |
| 13 | constructor( |
| 14 | plugin: TaskNotesPlugin, |
| 15 | task: TaskInfo, |
| 16 | triggerElement: HTMLElement, |
| 17 | onUpdate: (task: TaskInfo) => void |
| 18 | ) { |
| 19 | this.plugin = plugin; |
| 20 | this.task = task; |
| 21 | this.triggerElement = triggerElement; |
| 22 | this.onUpdate = onUpdate; |
| 23 | } |
| 24 | |
| 25 | show(event: UIEvent): void { |
| 26 | const menu = new ContextMenu(); |
| 27 | |
| 28 | // Quick Add sections |
| 29 | this.addQuickRemindersSection( |
| 30 | menu, |
| 31 | "due", |
| 32 | this.plugin.i18n.translate("components.reminderContextMenu.remindBeforeDue") |
| 33 | ); |
| 34 | this.addQuickRemindersSection( |
| 35 | menu, |
| 36 | "scheduled", |
| 37 | this.plugin.i18n.translate("components.reminderContextMenu.remindBeforeScheduled") |
| 38 | ); |
| 39 | |
| 40 | menu.addSeparator(); |
| 41 | |
| 42 | // Manage reminders |
| 43 | menu.addItem((item) => { |
| 44 | item.setTitle( |
| 45 | this.plugin.i18n.translate("components.reminderContextMenu.manageAllReminders") |
| 46 | ) |
| 47 | .setIcon("settings") |
| 48 | .onClick(() => { |
| 49 | this.openReminderModal(); |
| 50 | }); |
| 51 | }); |
| 52 | |
| 53 | // Clear reminders (if any exist) |
| 54 | if (this.task.reminders && this.task.reminders.length > 0) { |
| 55 | menu.addItem((item) => { |
| 56 | item.setTitle( |
| 57 | this.plugin.i18n.translate("components.reminderContextMenu.clearAllReminders") |
| 58 | ) |
| 59 | .setIcon("trash") |
| 60 | .onClick(async () => { |
| 61 | await this.clearAllReminders(); |
| 62 | }); |
| 63 | }); |
| 64 | } |
nothing calls this directly
no outgoing calls
no test coverage detected