Filter exercises by equipment (#6)
Adds an equipment filter row under the body-part chips, in both the Exercises library and the exercise picker sheet. The options are derived from the exercises already matching the current body part and search, ordered most-common-first, so the row stays short instead of listing all 28 equipment values (many with a single exercise) and every combination on screen has results behind it. The row hides itself when there is nothing to choose between. Changing the body part clears the equipment filter; a search that narrows the chosen equipment away drops it rather than showing an empty list. All equipment terms were already localized — only the new 'Any equipment' label needed adding across the 11 locale packs. Closes #6
This commit is contained in:
1 parent
33317dac91
commit
fbf125f6a2
15 files changed
+62
-12
No files matched your search
@@ -5,6 +5,15 @@ export const EXIDX = {}
|
||||
EXDB.forEach(e => { EXIDX[e.id] = e })
|
||||
export const BODYPARTS = [...new Set(EXDB.map(e => e.bp))].sort()
|
||||
|
||||
// Equipment options present in a given list of exercises, most common first (issue #6).
|
||||
// Deriving them from the *already filtered* list keeps the chip row short and means
|
||||
// every body-part × equipment combination on screen has results behind it.
|
||||
export function equipmentOf(list) {
|
||||
const c = {}
|
||||
list.forEach(e => { if (e.eq) c[e.eq] = (c[e.eq] || 0) + 1 })
|
||||
return Object.keys(c).sort((a, b) => c[b] - c[a] || (a < b ? -1 : 1))
|
||||
}
|
||||
|
||||
// Custom (user-created) exercises live in synced state S.customEx (issue #11) and are
|
||||
// merged into the id index here so every EXIDX[id] lookup keeps working unchanged.
|
||||
let customIds = []
|
||||
|
||||
Reference in new issue
Block a user