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

Method addDateOptions

src/components/TaskContextMenu.ts:1771–1859  ·  view source on GitHub ↗
(
		submenu: Menu,
		currentValue: string | undefined,
		onSelect: (value: string | null) => Promise<void>,
		onCustomDate: () => void,
		options: { pickDateTitle?: string } = {}
	)

Source from the content-addressed store, hash-verified

1769 }
1770
1771 private addDateOptions(
1772 submenu: Menu,
1773 currentValue: string | undefined,
1774 onSelect: (value: string | null) => Promise<void>,
1775 onCustomDate: () => void,
1776 options: { pickDateTitle?: string } = {}
1777 ): void {
1778 const dateContextMenu = new DateContextMenu({
1779 currentValue: currentValue,
1780 onSelect: (value: string | null) => {
1781 void onSelect(value);
1782 },
1783 onCustomDate: onCustomDate,
1784 plugin: this.options.plugin,
1785 app: this.options.plugin.app,
1786 });
1787
1788 const dateOptions = dateContextMenu.getDateOptions();
1789
1790 const incrementOptions = dateOptions.filter((option) => option.category === "increment");
1791 if (incrementOptions.length > 0) {
1792 incrementOptions.forEach((option) => {
1793 submenu.addItem((item) => {
1794 if (option.icon) item.setIcon(option.icon);
1795 item.setTitle(option.label);
1796 item.onClick(() => {
1797 void onSelect(option.value);
1798 });
1799 });
1800 });
1801 submenu.addSeparator();
1802 }
1803
1804 const basicOptions = dateOptions.filter((option) => option.category === "basic");
1805 basicOptions.forEach((option) => {
1806 submenu.addItem((item) => {
1807 if (option.icon) item.setIcon(option.icon);
1808 const isSelected = option.value === currentValue;
1809 const title = isSelected
1810 ? this.t("contextMenus.date.selected", { label: option.label })
1811 : option.label;
1812 item.setTitle(title);
1813 item.onClick(() => {
1814 void onSelect(option.value);
1815 });
1816 });
1817 });
1818
1819 const weekdayOptions = dateOptions.filter((option) => option.category === "weekday");
1820 if (weekdayOptions.length > 0) {
1821 submenu.addSeparator();
1822 submenu.addItem((item) => {
1823 item.setTitle(this.t("contextMenus.date.weekdaysLabel"));
1824 item.setIcon("calendar");
1825 const weekdaySubmenu = getSubmenu(item);
1826 weekdayOptions.forEach((option) => {
1827 weekdaySubmenu.addItem((subItem) => {
1828 const isSelected = option.value === currentValue;

Callers 2

buildMenuMethod · 0.95

Calls 5

getDateOptionsMethod · 0.95
tMethod · 0.95
setIconMethod · 0.80
onClickMethod · 0.80
getSubmenuFunction · 0.70

Tested by

no test coverage detected