Fix routine move controls for grouped exercises

This commit is contained in:
Space_Hermes committed 2026-08-27 19:40:49 +02:00
1 parent 5314b342ff
commit 933891ee99
17 files changed
+223 -5

No files matched your search

+16
View File
@@ -421,6 +421,22 @@ export function supersetUnits(items) {
})
return units
}
// Move the selected occurrence's complete display unit by one neighbouring unit. Returning a
// new array keeps this helper pure; the caller decides how to persist it. Index identity matters
// here because the same exercise id may appear more than once with different setup.
export function moveSupersetUnit(items, index, direction) {
if (!Array.isArray(items) || (direction !== -1 && direction !== 1)) return null
const units = supersetUnits(items)
const source = units.findIndex(unit => unit.includes(index))
const target = source + direction
if (source < 0 || target < 0 || target >= units.length) return null
const reordered = [...units]
const selected = reordered[source]
reordered[source] = reordered[target]
reordered[target] = selected
return reordered.flat().map(i => items[i])
}
export function unitOf(units, idx) { return units.find(u => u.includes(idx)) || [idx] }
export function streakWeeks(S) {
+1 -1
View File
@@ -27,7 +27,7 @@ describe('Brazilian Portuguese locale', () => {
.sort(byCodeUnit)
const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex')
expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(291)
expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(293)
expect(inherited).toHaveLength(449)
// If this fails, review the changed keys and wording before accepting a new hash. From
// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list