From 0f7a78876b6545447912bf9cdcbd66d6906859d7 Mon Sep 17 00:00:00 2001 From: spacebares <57186372+spacebares@users.noreply.github.com> Date: Fri, 16 Dec 2022 18:46:06 -0800 Subject: [PATCH 1/4] Show All and Solo selection buttons for MultiSelect. Similar to previous behavior of viewing events for single camera with 1 click, or All. * Fix visual bug with MultiSelect when selecting similar named options. eg. options like frontdoor, frontside, backdoor, etc --- web/src/components/MultiSelect.jsx | 41 ++++++++++++++++++++---------- web/src/routes/Events.jsx | 8 ++++++ 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/web/src/components/MultiSelect.jsx b/web/src/components/MultiSelect.jsx index 0e41a0503b..03c8d55ca0 100644 --- a/web/src/components/MultiSelect.jsx +++ b/web/src/components/MultiSelect.jsx @@ -3,15 +3,16 @@ import { useRef, useState } from 'preact/hooks'; import Menu from './Menu'; import { ArrowDropdown } from '../icons/ArrowDropdown'; import Heading from './Heading'; +import Button from './Button'; -export default function MultiSelect({ className, title, options, selection, onToggle }) { +export default function MultiSelect({ className, title, options, selection, onToggle, onShowAll, onSolo }) { const popupRef = useRef(null); const [state, setState] = useState({ showMenu: false, }); - + return (
{state.showMenu ? ( setState({ showMenu: false })}> - {title} +
+ {title} + +
{options.map((item) => ( - +
+ +
+ +
+
))}
): null}
); -} \ No newline at end of file +} diff --git a/web/src/routes/Events.jsx b/web/src/routes/Events.jsx index f259c31af5..b61bda7599 100644 --- a/web/src/routes/Events.jsx +++ b/web/src/routes/Events.jsx @@ -301,6 +301,8 @@ export default function Events({ path, ...props }) { options={filterValues.cameras} selection={searchParams.cameras} onToggle={(item) => onToggleNamedFilter("cameras", item)} + onShowAll={() => onFilter("cameras", ["all"])} + onSolo={(item) => onFilter("cameras", item)} /> onToggleNamedFilter("labels", item) } + onShowAll={() => onFilter("labels", ["all"])} + onSolo={(item) => onFilter("labels", item)} /> onToggleNamedFilter("zones", item) } + onShowAll={() => onFilter("zones", ["all"])} + onSolo={(item) => onFilter("zones", item)} /> { filterValues.sub_labels.length > 0 && ( @@ -324,6 +330,8 @@ export default function Events({ path, ...props }) { options={filterValues.sub_labels} selection={searchParams.sub_labels} onToggle={(item) => onToggleNamedFilter("sub_labels", item) } + onShowAll={() => onFilter("sub_labels", ["all"])} + onSolo={(item) => onFilter("sub_labels", item)} /> )}
From 0356e33fe04f4d4d0bb61b167239ca6b4dfdd1ad Mon Sep 17 00:00:00 2001 From: spacebares <57186372+spacebares@users.noreply.github.com> Date: Sat, 17 Dec 2022 06:15:54 -0800 Subject: [PATCH 2/4] fix key prop for lint * Change MultiSelect onSolo to onSelectSingle --- web/src/components/MultiSelect.jsx | 10 ++++------ web/src/routes/Events.jsx | 8 ++++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/web/src/components/MultiSelect.jsx b/web/src/components/MultiSelect.jsx index 03c8d55ca0..d700f5dae9 100644 --- a/web/src/components/MultiSelect.jsx +++ b/web/src/components/MultiSelect.jsx @@ -5,14 +5,13 @@ import { ArrowDropdown } from '../icons/ArrowDropdown'; import Heading from './Heading'; import Button from './Button'; -export default function MultiSelect({ className, title, options, selection, onToggle, onShowAll, onSolo }) { +export default function MultiSelect({ className, title, options, selection, onToggle, onShowAll, onSelectSingle }) { const popupRef = useRef(null); const [state, setState] = useState({ showMenu: false, }); - return (
{options.map((item) => ( -
+