From 181ff241da5bb2a9118898c2c62659b6367e8c6e Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 6 Aug 2020 12:18:11 +0300 Subject: [PATCH] Tasks: autocomplete from all of the tags options (not just hardcoded). Partially fixes #152. --- src/components/Tasks/Sidebar.tsx | 6 ++++-- src/pim-types.ts | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/Tasks/Sidebar.tsx b/src/components/Tasks/Sidebar.tsx index 677355f..63a8731 100644 --- a/src/components/Tasks/Sidebar.tsx +++ b/src/components/Tasks/Sidebar.tsx @@ -10,7 +10,7 @@ import { setSettings } from "../../store/actions"; import { StoreState } from "../../store"; import { List, ListItem, ListSubheader } from "../../widgets/List"; -import { TaskType } from "../../pim-types"; +import { TaskType, setTaskTags } from "../../pim-types"; interface ListItemPropsType { name: string | null; @@ -49,6 +49,8 @@ export default React.memo(function Sidebar(props: { tasks: TaskType[] }) { tasks.forEach((task) => task.tags.forEach((tag) => { tags.set(tag, (tags.get(tag) ?? 0) + 1); })); + // FIXME: ugly hack to support potential tags. Will be fixed very soon. + setTaskTags(Array.from(tags.keys())); const tagsList = [...tags].sort(([a], [b]) => a.localeCompare(b)).map(([tag, amount]) => ( ); -}); \ No newline at end of file +}); diff --git a/src/pim-types.ts b/src/pim-types.ts index 5bcb29e..3a07fe3 100644 --- a/src/pim-types.ts +++ b/src/pim-types.ts @@ -152,7 +152,11 @@ export enum TaskPriorityType { Low = 9 } -export const TaskTags = ["Work", "Home"]; +export let TaskTags = ["Work", "Home"]; + +export function setTaskTags(tags: string[]) { + TaskTags = tags; +} export class TaskType extends EventType { public static fromVCalendar(comp: ICAL.Component) {