Merge !72: Exercise picker: the "+" adds now instead of opening the detail sheet
# Conflicts: # frontend/src/views/RoutineEdit.jsx
This commit is contained in:
commit
d8130443a9
3 files changed
+29
-6
No files matched your search
@@ -1,11 +1,12 @@
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useStore } from '../store/useStore.js'
|
||||
import { useUI } from '../store/useUI.js'
|
||||
import { exOr } from '../lib/exercises.js'
|
||||
import { activeProfile, exAvailable } from '../lib/equipment.js'
|
||||
import { uid } from '../lib/format.js'
|
||||
import { t, exerciseNameFor } from '../lib/i18n.js'
|
||||
import { supersetUnits, moveSupersetUnit, cleanupSg, exLine } from '../lib/history.js'
|
||||
import { supersetUnits, moveSupersetUnit, cleanupSg, exLine, defaultConfig } from '../lib/history.js'
|
||||
import { Thumb } from '../components/Media.jsx'
|
||||
import { glyphPicker, exercisePicker, exConfigSheet, confirmSheet } from '../sheets.jsx'
|
||||
import Icon from '../components/Icon.jsx'
|
||||
@@ -306,6 +307,7 @@ export default function RoutineEdit() {
|
||||
const { id } = useParams()
|
||||
const S = useStore(s => s.S)
|
||||
const update = useStore(s => s.update)
|
||||
const toast = useUI(s => s.toast)
|
||||
const r = S.routines.find(x => x.id === id)
|
||||
useEffect(() => { if (!r) nav('/plan') }, [!!r])
|
||||
// Editing here has no explicit "save" — every field change persists immediately. A single
|
||||
@@ -424,7 +426,14 @@ export default function RoutineEdit() {
|
||||
})()}
|
||||
|
||||
<div className="small dim row" style={{ margin: '10px 2px', gap: 5 }}><Icon name="link" style={{ fontSize: 13 }} />{t('Tap the link button on an exercise to superset it with the one above — you’ll do them back-to-back.')}</div>
|
||||
<Button variant="primary" onClick={() => exercisePicker(ex => exConfigSheet(ex, null, cfg => edit(x => { x.push({ id: ex.id, ...cfg }) }), null, r))} icon="plus">{t('Add exercise')}</Button>
|
||||
<Button variant="primary" onClick={() => exercisePicker((ex, quick) => {
|
||||
if (quick) {
|
||||
edit(x => x.push({ id: ex.id, ...defaultConfig(ex.id) }))
|
||||
toast(t('“{0}” added to {1}', exerciseNameFor(ex), r.name))
|
||||
} else {
|
||||
exConfigSheet(ex, null, cfg => edit(x => { x.push({ id: ex.id, ...cfg }) }), null, r)
|
||||
}
|
||||
})} icon="plus">{t('Add exercise')}</Button>
|
||||
<div style={{ height: 10 }} />
|
||||
<Button onClick={() => {
|
||||
const copy = copyRoutine(r, t('Copy'))
|
||||
|
||||
@@ -689,14 +689,14 @@ function ActiveWorkout() {
|
||||
<Button trailingIcon="chevronRight" disabled={unitIdx < 0 || unitIdx >= units.length - 1} onClick={() => navigateUnit(1)}>{t('Next')}</Button>
|
||||
</div>
|
||||
<div style={{ height: 10 }} />
|
||||
<Button onClick={() => exercisePicker(ex => {
|
||||
<Button onClick={() => exercisePicker((ex, quick) => {
|
||||
const routine = S.routines.find(r => r.id === A.routineId)
|
||||
const freestyle = !A.routineId
|
||||
// Freestyle has no routine prescription to apply: show the last target in the config
|
||||
// sheet and carry its completed rows forward. A planned session uses its configured
|
||||
// target when progression is off, while progression-enabled sessions keep their path.
|
||||
const seed = freestyle ? freestyleConfig(S, { id: ex.id, ...defaultConfig(ex.id) }) : null
|
||||
exConfigSheet(ex, null, cfg => update(s => {
|
||||
const commit = cfg => update(s => {
|
||||
const full = { ...cfg, id: ex.id }
|
||||
const plan = freestyle ? null : nextPrescription(s, full, s.routines.find(r => r.id === s.active.routineId))
|
||||
const sets = buildSets(s, full, {
|
||||
@@ -709,7 +709,14 @@ function ActiveWorkout() {
|
||||
s.active.entries.splice(insertAt, 0, { id: ex.id, target: { ...cfg }, plan, sets: applyIntensifierPlan(progressed, full) })
|
||||
s.active.cur = insertAt
|
||||
useUI.getState().shiftRestOwner(insertAt, 1)
|
||||
}), null, routine, seed)
|
||||
})
|
||||
// The "+" on a picker row reads as "add this now" — routed through the same detail
|
||||
// sheet before, so it added nothing until you'd scrolled past it and found the real
|
||||
// button. Quick-add commits with the same default (or, freestyle, last-session) config
|
||||
// the sheet would have opened with; tapping the row still opens that sheet for anyone
|
||||
// who wants to set sets/reps first.
|
||||
if (quick) { commit(seed || defaultConfig(ex.id)); useUI.getState().toast(t('“{0}” added to {1}', exerciseNameFor(ex), routine ? routine.name : t('Freestyle'))) }
|
||||
else exConfigSheet(ex, null, commit, null, routine, seed)
|
||||
})} icon="plus">{t('Add exercise')}</Button>
|
||||
{A.entries.length > 0 && <>
|
||||
<div style={{ height: 6 }} />
|
||||
|
||||
Reference in new issue
Block a user