From 73b76ad7a2d83c0ba4b72b7282584610a47ee375 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Wed, 18 Sep 2024 12:51:15 -0500 Subject: [PATCH] filter instructions --- web/src/components/input/InputWithTags.tsx | 78 ++++++++++++++++------ web/src/utils/dateUtil.ts | 12 ++++ 2 files changed, 70 insertions(+), 20 deletions(-) diff --git a/web/src/components/input/InputWithTags.tsx b/web/src/components/input/InputWithTags.tsx index 3bb73f239..3249fa045 100644 --- a/web/src/components/input/InputWithTags.tsx +++ b/web/src/components/input/InputWithTags.tsx @@ -22,13 +22,21 @@ import { CommandGroup, CommandItem, } from "@/components/ui/command"; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "@/components/ui/popover"; import { cn } from "@/lib/utils"; import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip"; import { TooltipPortal } from "@radix-ui/react-tooltip"; import { usePersistence } from "@/hooks/use-persistence"; import { SaveSearchDialog } from "./SaveSearchDialog"; import { DeleteSearchDialog } from "./DeleteSearchDialog"; -import { convertLocalDateToTimestamp } from "@/utils/dateUtil"; +import { + convertLocalDateToTimestamp, + getIntlDateFormat, +} from "@/utils/dateUtil"; import { toast } from "sonner"; type InputWithTagsProps = { @@ -489,25 +497,55 @@ export default function InputWithTags({ )} - - - 0 - ? "text-selected" - : "text-secondary-foreground", - )} - /> - - - - Filters{" "} - {Object.keys(filters).length > 0 ? "active" : "inactive"} - - - + + + + + +
+

How to use text filters

+

+ Filters help you narrow down your search results. Here's how + to use them: +

+
    +
  • + Type a filter name followed by a colon (e.g., "cameras:"). +
  • +
  • + Select a value from the suggestions or type your own. +
  • +
  • + Use multiple filters by adding them one after another. +
  • +
  • + Date filters (before: and after:) use{" "} + {getIntlDateFormat()} format. +
  • +
  • Remove filters by clicking the 'x' next to them.
  • +
+

+ Example:{" "} + + cameras:front_door label:person before:01012024 + +

+
+
+
{inputFocused ? ( { return timestamp; }; + +export function getIntlDateFormat() { + return new Intl.DateTimeFormat() + .formatToParts(new Date()) + .reduce((acc, part) => { + if (part.type === "day") acc.push("DD"); + if (part.type === "month") acc.push("MM"); + if (part.type === "year") acc.push("YYYY"); + return acc; + }, [] as string[]) + .join(""); +}