mirror of
https://github.com/brendan-ch/todo-tracker-obsidian.git
synced 2026-04-19 08:10:29 +00:00
Add daily note modal click action
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
import { App, Modal, Setting } from 'obsidian';
|
import { TodoItem } from 'core/types';
|
||||||
|
import { App, Modal, Setting, TFile } from 'obsidian';
|
||||||
|
|
||||||
export class DailyNoteSelectModal extends Modal {
|
export class DailyNoteSelectModal extends Modal {
|
||||||
constructor(app: App, onSubmit: (result: string) => void) {
|
constructor(app: App, todo: TodoItem, file: TFile) {
|
||||||
super(app);
|
super(app);
|
||||||
this.setTitle('Select a daily note');
|
this.setTitle('Select a daily note');
|
||||||
|
|
||||||
@@ -9,7 +10,9 @@ export class DailyNoteSelectModal extends Modal {
|
|||||||
new Setting(this.contentEl)
|
new Setting(this.contentEl)
|
||||||
.setName('Date')
|
.setName('Date')
|
||||||
.addMomentFormat((component) => {
|
.addMomentFormat((component) => {
|
||||||
|
component.onChange((value) => {
|
||||||
|
name = value;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
new Setting(this.contentEl)
|
new Setting(this.contentEl)
|
||||||
@@ -19,7 +22,8 @@ export class DailyNoteSelectModal extends Modal {
|
|||||||
.setCta()
|
.setCta()
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
this.close();
|
this.close();
|
||||||
onSubmit(name);
|
// do some stuff
|
||||||
|
console.debug(name);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,14 @@ export function createTodoItemEl(
|
|||||||
callbacks.onMoveClick(todo);
|
callbacks.onMoveClick(todo);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
menu.addItem((item) => {
|
||||||
|
item
|
||||||
|
.setTitle('Move to daily note...')
|
||||||
|
.setIcon('arrow-right')
|
||||||
|
.onClick(() => {
|
||||||
|
callbacks.onMoveDailyNoteClick(todo);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
menu.showAtMouseEvent(evt);
|
menu.showAtMouseEvent(evt);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -353,7 +353,9 @@ export class TodoSidebarView extends ItemView {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleMoveDailyNoteClick(t: TodoItem, file: TFile): void {
|
private handleMoveDailyNoteClick(todo: TodoItem, file: TFile): void {
|
||||||
|
void import('../modals/daily-note-select-modal').then(({ DailyNoteSelectModal }) => {
|
||||||
|
new DailyNoteSelectModal(this.app, todo, file).open();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user