Unify category autocomplete fields
All checks were successful
Deploy Sokko G / deploy (push) Successful in 17s
All checks were successful
Deploy Sokko G / deploy (push) Successful in 17s
This commit is contained in:
parent
e3d823d0b1
commit
055fb78d60
21 changed files with 739 additions and 168 deletions
|
|
@ -13,7 +13,11 @@ import { useTaskPlannerReorder } from "./useTaskPlannerReorder.js";
|
|||
export function TaskPlannerModule({ toolboxId, moduleId, context, editing, textExchangeOpen }) {
|
||||
const data = context.normalizeTaskPlannerData(context.getModuleData(toolboxId, moduleId, { tasks: [] }));
|
||||
const textContent = context.moduleText?.taskPlanner || {};
|
||||
const taskDraft = useDraftForm({ title: "", type: "daily" });
|
||||
const taskDraft = useDraftForm({ title: "", type: "daily", category: "" });
|
||||
const categoryOptions = useMemo(() => [
|
||||
...data.categoryOrder,
|
||||
...data.tasks.map((task) => task.category).filter(Boolean).filter((category) => !data.categoryOrder.includes(category))
|
||||
], [data.categoryOrder, data.tasks]);
|
||||
const [nowMs, setNowMs] = useState(() => Date.now());
|
||||
const [settingsOpen, setSettingsOpen] = useState(false);
|
||||
const [openDescriptions, setOpenDescriptions] = useState(() => new Set());
|
||||
|
|
@ -45,19 +49,20 @@ export function TaskPlannerModule({ toolboxId, moduleId, context, editing, textE
|
|||
taskDraft.handleSubmit(event, (draft, { reset }) => {
|
||||
const cleanTitle = draft.title.trim();
|
||||
if (!cleanTitle) return;
|
||||
const category = draft.category.trim();
|
||||
const task = {
|
||||
id: context.uid("task"),
|
||||
title: cleanTitle,
|
||||
description: "",
|
||||
type: draft.type,
|
||||
checked: false,
|
||||
checkedAt: 0
|
||||
};
|
||||
if (category) task.category = category;
|
||||
save({
|
||||
...data,
|
||||
tasks: [
|
||||
...data.tasks,
|
||||
{
|
||||
id: context.uid("task"),
|
||||
title: cleanTitle,
|
||||
description: "",
|
||||
type: draft.type,
|
||||
checked: false,
|
||||
checkedAt: 0
|
||||
}
|
||||
]
|
||||
tasks: [...data.tasks, task],
|
||||
categoryOrder: category && !data.categoryOrder.includes(category) ? [...data.categoryOrder, category] : data.categoryOrder
|
||||
});
|
||||
reset();
|
||||
});
|
||||
|
|
@ -171,6 +176,7 @@ export function TaskPlannerModule({ toolboxId, moduleId, context, editing, textE
|
|||
context={context}
|
||||
editing={editing}
|
||||
settingsOpen={settingsOpen}
|
||||
categoryOptions={categoryOptions}
|
||||
taskDraft={taskDraft}
|
||||
textContent={textContent}
|
||||
textExchangeOpen={textExchangeOpen}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue