Save and load task notes
This commit is contained in:
@@ -33,13 +33,16 @@ export default function Router({
|
||||
switch (entity.type) {
|
||||
case "todo": {
|
||||
const createTask = (statusId: string) => {
|
||||
const now = new Date().getTime();
|
||||
const task: Task = {
|
||||
id: id("task"),
|
||||
title: "New task",
|
||||
statusId,
|
||||
tagIds: [],
|
||||
createdAt: new Date().getTime(),
|
||||
updatedAt: new Date().getTime(),
|
||||
// initialize empty rich document notes
|
||||
doc: { version: "2.28.0", time: now, blocks: [] },
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
};
|
||||
|
||||
updateEntity(entityId, (e) => ({
|
||||
|
||||
@@ -26,11 +26,16 @@ export default function DocDialog({
|
||||
tags: Record<TagId, Tag>;
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
const [doc, setDoc] = useState<OutputData>({
|
||||
version: "2.28.0",
|
||||
time: Date.now(),
|
||||
blocks: [],
|
||||
});
|
||||
// if there is an existing document on the task use it, otherwise start with a blank one
|
||||
const doc = task.doc || { version: "2.28.0", time: Date.now(), blocks: [] };
|
||||
|
||||
const handleDocChange = (newDoc: OutputData) => {
|
||||
setTask({
|
||||
...task,
|
||||
doc: newDoc,
|
||||
updatedAt: Date.now(),
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog>
|
||||
@@ -62,7 +67,7 @@ export default function DocDialog({
|
||||
</DialogHeader>
|
||||
|
||||
<ScrollArea className="h-[60vh]">
|
||||
<DocView key={0} doc={doc} setDoc={setDoc} />
|
||||
<DocView key={task.id} doc={doc} setDoc={handleDocChange} />
|
||||
</ScrollArea>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
Reference in New Issue
Block a user