Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ce1a7c055 | ||
|
|
aa42040f55 | ||
|
|
0410ea34be | ||
|
|
0ab0f47259 |
No files matched your search
+3
-2
@@ -26,8 +26,9 @@ self-hosted instance only needs the new web bundle.
|
||||
### Exercise settings
|
||||
|
||||
- 🔢 **Progression steps below one can be typed.** Entering `0.5` used to snap back to the
|
||||
default halfway through, because the field rejected the intermediate `0`. A cleared field
|
||||
still means "use the default". (mflova, !60)
|
||||
default halfway through, because the field rejected the intermediate `0`. Leaving the field
|
||||
empty or at `0` with a progression rule on now marks it red and holds the save, so a step that
|
||||
cannot progress anything can no longer be stored by accident. (mflova, !60)
|
||||
- 📐 **Long values in routine rows no longer squash the title.** The value column is capped
|
||||
instead of reserving space, so a "3 × 12 @ 102.5 kg" row keeps its exercise name readable on a
|
||||
narrow phone. (MokshManral, !37)
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gym-api",
|
||||
"version": "1.2.12",
|
||||
"version": "1.2.13",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "server.js",
|
||||
|
||||
@@ -7,8 +7,8 @@ android {
|
||||
applicationId "ch.duartesantos.opengym"
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 13
|
||||
versionName "1.2.12"
|
||||
versionCode 14
|
||||
versionName "1.2.13"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
aaptOptions {
|
||||
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "opengym-frontend",
|
||||
"version": "1.2.12",
|
||||
"version": "1.2.13",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "opengym-frontend",
|
||||
"version": "1.2.12",
|
||||
"version": "1.2.13",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@capacitor/app": "^7.1.2",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "opengym-frontend",
|
||||
"private": true,
|
||||
"version": "1.2.12",
|
||||
"version": "1.2.13",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -115,13 +115,13 @@ export function Segmented({ options, value, onChange, className = '' }) {
|
||||
|
||||
/* ============================ stepper ============================ */
|
||||
|
||||
export function Stepper({ value, step = 1, onChange, decimal = true, className = '', label, unit }) {
|
||||
export function Stepper({ value, step = 1, onChange, decimal = true, className = '', label, unit, invalid = false }) {
|
||||
const set = v => onChange(Math.max(0, Math.round((v || 0) * 100) / 100))
|
||||
const inner = (
|
||||
<div className={'stp ' + className}>
|
||||
<button onClick={() => set((+value || 0) - step)} aria-label="Decrease"><Icon name="minus" /></button>
|
||||
<span className="val">
|
||||
<NumberField value={value} decimal={decimal} onChange={onChange} />
|
||||
<NumberField value={value} decimal={decimal} onChange={onChange} aria-invalid={invalid ? 'true' : undefined} />
|
||||
{unit && <i>{unit}</i>}
|
||||
</span>
|
||||
<button onClick={() => set((+value || 0) + step)} aria-label="Increase"><Icon name="plus" /></button>
|
||||
|
||||
@@ -530,6 +530,7 @@ h4.sec{
|
||||
-moz-appearance:textfield;appearance:textfield;
|
||||
}
|
||||
.stp .num::-webkit-inner-spin-button{display:none}
|
||||
.stp.invalid{box-shadow:inset 0 0 0 1px var(--red)}
|
||||
|
||||
/* --- slider --- */
|
||||
.sld{position:relative;height:32px;display:flex;align-items:center;cursor:pointer;touch-action:none}
|
||||
|
||||
+16
-3
@@ -559,12 +559,18 @@ export const equipmentProfileSheet = profile => ui().openSheet(close => <Equipme
|
||||
// Progression settings for one exercise (issue #17). Shown inside the config sheet because
|
||||
// "how does this lift go up" belongs next to sets and reps, not in a separate screen. Left
|
||||
// on "follow the routine" it inherits, so most people never touch it.
|
||||
const progressionStepOf = (c, mode, ex, unit) =>
|
||||
c.inc >= 0 ? c.inc : (mode === 'time' ? 5 : defaultIncrement(ex.id, unit))
|
||||
const progressionStepIsValid = (step, policy) =>
|
||||
policy === 'off' || (Number.isFinite(step) && step > 0)
|
||||
|
||||
function ProgressionFields({ ex, mode, c, setC, routine, unit }) {
|
||||
const options = POLICIES_FOR[mode] || ['off']
|
||||
if (options.length < 2) return null
|
||||
const inherited = policyFor({ id: ex.id }, routine, mode)
|
||||
const active = policyFor({ ...c, id: ex.id }, routine, mode)
|
||||
const inc = c.inc >= 0 ? c.inc : (mode === 'time' ? 5 : defaultIncrement(ex.id, unit))
|
||||
const inc = progressionStepOf(c, mode, ex, unit)
|
||||
const invalid = !progressionStepIsValid(inc, active)
|
||||
return <>
|
||||
<h4 className="sec">{t('Progression')}</h4>
|
||||
<div className="sect-b" style={{ marginBottom: 8 }}>
|
||||
@@ -575,10 +581,14 @@ function ProgressionFields({ ex, mode, c, setC, routine, unit }) {
|
||||
<div className="small dim" style={{ marginBottom: active === 'off' ? 18 : 10 }}>{t(POLICY_DESC[active])}</div>
|
||||
{active !== 'off' && <div className="row cfgrow" style={{ marginBottom: 18 }}>
|
||||
<Stepper label={mode === 'time' ? t('Step (seconds)') : t('Step ({0})', unit)} value={inc}
|
||||
step={mode === 'time' ? 5 : 1.25} decimal={mode !== 'time'} onChange={v => setC(x => ({ ...x, inc: v }))} />
|
||||
step={mode === 'time' ? 5 : 1.25} decimal={mode !== 'time'} invalid={invalid} className={invalid ? 'invalid' : ''}
|
||||
onChange={v => setC(x => ({ ...x, inc: v }))} />
|
||||
{active === 'double' && <Stepper label={t('Reps from')} value={c.repsMin || Math.max(1, (c.reps || 10) - 2)}
|
||||
step={1} decimal={false} onChange={v => setC(x => ({ ...x, repsMin: v }))} />}
|
||||
</div>}
|
||||
{invalid && <div className="small" role="alert" style={{ color: 'var(--red)', marginTop: -10, marginBottom: 18 }}>
|
||||
{t('Enter a positive step to use this progression rule.')}
|
||||
</div>}
|
||||
</>
|
||||
}
|
||||
|
||||
@@ -592,9 +602,12 @@ function ExConfig({ ex, existing, onSave, onDelete, close, routine, initial }) {
|
||||
// Both default from the dataset and are then whatever the config says — see isBw.
|
||||
const bw = !cardio && isBw({ ...c, id: ex.id })
|
||||
const perSide = isPerSide(c)
|
||||
const progressionPolicy = policyFor({ ...c, id: ex.id }, routine, mode)
|
||||
const progressionStepInvalid = !progressionStepIsValid(progressionStepOf(c, mode, ex, st.unit), progressionPolicy)
|
||||
// Keep whatever the other mode already had (sets, weight) and fill only what is missing.
|
||||
const setMode = m => setC(x => ({ ...defaultConfig(ex.id, m), ...x, mode: m }))
|
||||
const save = () => {
|
||||
if (progressionStepInvalid) return
|
||||
close()
|
||||
const sets = Math.max(1, Math.round(c.sets) || (cardio ? 1 : 3))
|
||||
// Only carry progression settings that differ from the inherited default, so a plan file
|
||||
@@ -768,7 +781,7 @@ function ExConfig({ ex, existing, onSave, onDelete, close, routine, initial }) {
|
||||
<textarea className="input" rows={3} maxLength={500} style={{ marginBottom: 18 }}
|
||||
placeholder={t('Note (optional) — loading cues, "bar only then +1 plate/side each set", anything worth remembering here')}
|
||||
value={c.note || ''} onChange={e => setC(x => ({ ...x, note: e.target.value }))} />
|
||||
<Button variant="primary" onClick={save}>{existing ? t('Save') : t('Add to routine')}</Button>
|
||||
<Button variant="primary" disabled={progressionStepInvalid} onClick={save}>{existing ? t('Save') : t('Add to routine')}</Button>
|
||||
{ex.custom && <><div style={{ height: 8 }} /><Button icon="pencil" onClick={() => { close(); customExSheet(ex) }}>{t('Edit or delete this exercise')}</Button></>}
|
||||
{onDelete && <><div style={{ height: 8 }} /><Button variant="danger" onClick={() => { close(); onDelete() }}>{t('Remove from routine')}</Button></>}
|
||||
</>
|
||||
|
||||
@@ -51,19 +51,31 @@ describe('exercise configuration progression step', () => {
|
||||
expect(step.value).toBe('0.5')
|
||||
})
|
||||
|
||||
it('persists a positive decimal but omits a cleared progression increment', () => {
|
||||
const positive = renderConfig()
|
||||
act(() => { type(positive.step, '0,5') })
|
||||
const positiveSave = [...positive.host.querySelectorAll('button')]
|
||||
it('blocks saving without a positive progression step but accepts a positive decimal', () => {
|
||||
const config = renderConfig()
|
||||
const save = [...config.host.querySelectorAll('button')]
|
||||
.find(b => /^(save|add to routine)$/i.test(b.textContent.trim()))
|
||||
act(() => { positiveSave.click() })
|
||||
expect(positive.onSave).toHaveBeenCalledWith(expect.objectContaining({ inc: 0.5 }))
|
||||
|
||||
const empty = renderConfig()
|
||||
act(() => { type(empty.step, '') })
|
||||
const emptySave = [...empty.host.querySelectorAll('button')]
|
||||
.find(b => /^(save|add to routine)$/i.test(b.textContent.trim()))
|
||||
act(() => { emptySave.click() })
|
||||
expect(empty.onSave.mock.calls[0][0]).not.toHaveProperty('inc')
|
||||
act(() => { type(config.step, '') })
|
||||
expect(config.step.value).toBe('')
|
||||
expect(config.step.getAttribute('aria-invalid')).toBe('true')
|
||||
expect(save.disabled).toBe(true)
|
||||
expect(config.host.textContent).toContain('Enter a positive step to use this progression rule.')
|
||||
|
||||
act(() => { save.click() })
|
||||
expect(config.onSave).not.toHaveBeenCalled()
|
||||
expect(useUI.getState().sheets).toHaveLength(1)
|
||||
|
||||
act(() => { type(config.step, '0') })
|
||||
expect(save.disabled).toBe(true)
|
||||
|
||||
act(() => { type(config.step, '0,5') })
|
||||
expect(config.step.value).toBe('0.5')
|
||||
expect(config.step.getAttribute('aria-invalid')).not.toBe('true')
|
||||
expect(save.disabled).toBe(false)
|
||||
|
||||
act(() => { save.click() })
|
||||
expect(config.onSave).toHaveBeenCalledWith(expect.objectContaining({ inc: 0.5 }))
|
||||
expect(useUI.getState().sheets).toHaveLength(0)
|
||||
})
|
||||
})
|
||||
+1
-1
@@ -344,7 +344,7 @@ try {
|
||||
</ul>
|
||||
<div class="push">
|
||||
<a class="btn" href="openGym.apk" download>Download for Android</a>
|
||||
<p class="meta">v1.2.12 · 4.4 MB · Android 6.0+ · signed APK. Your browser will ask
|
||||
<p class="meta">v1.2.13 · 4.4 MB · Android 6.0+ · signed APK. Your browser will ask
|
||||
before installing; that is normal outside the Play Store.</p>
|
||||
<p class="meta">Every release is also built and signed by CI and attached to the
|
||||
<a href="https://gitlab.com/DuarteSantos8/opengym/-/releases" rel="noopener">GitLab
|
||||
|
||||
Reference in new issue
Block a user