mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 10:22:29 +08:00
feat(tasks): display due date in editable textbox
This commit is contained in:
parent
fcd7b986aa
commit
637ba78100
@ -78,10 +78,10 @@ function buildTasks(tasks: FTask[]) {
|
||||
return html;
|
||||
}
|
||||
|
||||
function buildEditContainer() {
|
||||
function buildEditContainer(task: FTask) {
|
||||
return `\
|
||||
<label>Due date:</label>
|
||||
<input type="date" data-tasks-role="due-date" />
|
||||
<input type="date" data-tasks-role="due-date" value="${task.dueDate ?? ""}" />
|
||||
`;
|
||||
}
|
||||
|
||||
@ -130,18 +130,15 @@ export default class TaskListWidget extends TypeWidget {
|
||||
|
||||
// Add the new edit container.
|
||||
const $editContainer = $target.find(".edit-container");
|
||||
$editContainer.html(buildEditContainer());
|
||||
const task = this.#getCorrespondingTask($target);
|
||||
if (task) {
|
||||
$editContainer.html(buildEditContainer(task));
|
||||
}
|
||||
});
|
||||
|
||||
this.$taskContainer.on("change", "input", async (e) => {
|
||||
const $target = $(e.target);
|
||||
const taskId = $target.closest("li")[0].dataset.taskId;
|
||||
if (!taskId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const task = froca.getTask(taskId);
|
||||
|
||||
const task = this.#getCorrespondingTask($target);
|
||||
if (!task) {
|
||||
return;
|
||||
}
|
||||
@ -159,6 +156,15 @@ export default class TaskListWidget extends TypeWidget {
|
||||
});
|
||||
}
|
||||
|
||||
#getCorrespondingTask($target: JQuery<HTMLElement>) {
|
||||
const taskId = $target.closest("li")[0].dataset.taskId;
|
||||
if (!taskId) {
|
||||
return;
|
||||
}
|
||||
|
||||
return froca.getTask(taskId);
|
||||
}
|
||||
|
||||
async #createNewTask(title: string) {
|
||||
if (!title || !this.noteId) {
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user