From e5d9f5fa92ac29b7da4166ecb28a91515ca51650 Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Thu, 22 Dec 2022 17:08:01 +1300 Subject: [PATCH] Add select all button Very useful final addition to the multi edit/delete function. Typically a user will search for certain criteria, and then select them all to be removed/edited. For example, if yesterdays sets were all 10x150kg deadlifts, but you review your form video and decide the form sucked, you would want to mass edit them to lower the weight/reps (or maybe delete them). This way you won't have these invalid entries ruining all your progress graphs (showing false progress). --- ListMenu.tsx | 8 ++++++++ PlanList.tsx | 5 +++++ SetList.tsx | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/ListMenu.tsx b/ListMenu.tsx index fc7e51d..dc661b4 100644 --- a/ListMenu.tsx +++ b/ListMenu.tsx @@ -8,12 +8,14 @@ export default function ListMenu({ onCopy, onClear, onDelete, + onSelect, ids, }: { onEdit: () => void onCopy: () => void onClear: () => void onDelete: () => void + onSelect: () => void ids?: number[] }) { const [showMenu, setShowMenu] = useState(false) @@ -41,6 +43,11 @@ export default function ListMenu({ onDelete() } + const select = () => { + setShowMenu(false) + onSelect() + } + return ( }> + { + setIds(plans.map(plan => plan.id)) + }, [plans]) + return ( <> @@ -87,6 +91,7 @@ export default function PlanList() { onDelete={remove} onEdit={edit} ids={ids} + onSelect={select} /> diff --git a/SetList.tsx b/SetList.tsx index f971fcb..9378c70 100644 --- a/SetList.tsx +++ b/SetList.tsx @@ -124,6 +124,10 @@ export default function SetList() { await refresh(term) }, [ids, refresh, term]) + const select = useCallback(() => { + setIds(sets.map(set => set.id)) + }, [sets]) + return ( <> @@ -133,6 +137,7 @@ export default function SetList() { onDelete={remove} onEdit={edit} ids={ids} + onSelect={select} />