diff --git a/CHANGELOG.md b/CHANGELOG.md index b9d98fe..05e26eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ Each step of the development plan (specification § 23) is one or more pull requ ### Fixed +- Entry follow-up (races with several bibs): ticked children stay ticked and listed on top while searching for the next one (also after a data refresh); the keyboard "search" key (or Enter) ticks a single match; only the list is redrawn while typing, so the phone keyboard keeps its numeric mode. - Configuration errors name the place in words ("Ateliers › Saut en longueur (senior) › Type de mesure") instead of the file path; after a refused save, the page scrolls to the first error or warning and focuses it. - Email deliverability, after the hosting's antispam filter blocked legitimate emails: links always in https (`/status` checks APP_URL), `Message-ID` on the sender's domain, `Reply-To` to the edition's contact, `Auto-Submitted` header, plainer separator in bilingual emails; imports send at most 30 confirmation emails, paced over one connection, and name the families left out; addresses whose domain receives no email are refused (warning in imports). - Registration forms (child card, new registration, public form) no longer rely on the browser's own checks, which could block saving without any message: the server explains every missing or invalid field, and the page scrolls to the messages (#23). diff --git a/config.example/i18n/en.toml b/config.example/i18n/en.toml index ae1e960..e62186b 100644 --- a/config.example/i18n/en.toml +++ b/config.example/i18n/en.toml @@ -988,6 +988,7 @@ event = "Event" best = "Best" no_match = "No child matches \"{query}\"." race_hint = "Tick up to {count} child(ren) to start their race." +race_search_hint = "Search a bib or a first name, then press Enter to tick it: ticked children stay on the list." start_race = "Start the race" [entry.tracking.tab] diff --git a/config.example/i18n/fr.toml b/config.example/i18n/fr.toml index a72feeb..896397f 100644 --- a/config.example/i18n/fr.toml +++ b/config.example/i18n/fr.toml @@ -988,6 +988,7 @@ event = "Épreuve" best = "Meilleur" no_match = "Aucun enfant ne correspond à « {query} »." race_hint = "Cochez jusqu'à {count} enfant(s) pour lancer leur course." +race_search_hint = "Cherchez un dossard ou un prénom puis appuyez sur Entrée pour le cocher : les enfants cochés restent affichés." start_race = "Lancer la course" [entry.tracking.tab] diff --git a/public/assets/css/app.css b/public/assets/css/app.css index aa736e8..a2762b5 100644 --- a/public/assets/css/app.css +++ b/public/assets/css/app.css @@ -876,6 +876,11 @@ pre.details { } /* ---------- Workshop follow-up (spec § 8.6) ---------- */ +/* Children ticked for the next race stay highlighted on top of the list. */ +.entry-tracking-race tr.selected { + background: var(--color-highlight); +} + .tracking-race-actions { position: sticky; bottom: 0; diff --git a/public/assets/js/entry/app.js b/public/assets/js/entry/app.js index fa07db1..4a347a9 100644 --- a/public/assets/js/entry/app.js +++ b/public/assets/js/entry/app.js @@ -32,6 +32,7 @@ import { queueView, raceView, TRACKING_TABS, + trackingResults, trackingView, warningList, } from './views.js'; @@ -551,63 +552,103 @@ export const initEntryApp = () => { .sort((a, b) => a.child.bib - b.child.bib); let trackingQuery = ''; + // Children ticked for a race: kept while searching for the next one. + let raceSelection = []; const showTracking = (tab) => { const all = trackingRows(); const counts = Object.fromEntries( TRACKING_TABS.map((name) => [name, all.filter((row) => row.tabs.includes(name)).length]), ); - const query = searchKey(trackingQuery); - const rows = query - ? all.filter( - (row) => String(row.child.bib) === query || searchKey(row.child.name).startsWith(query), - ) - : all.filter((row) => row.tabs.includes(tab)); const race = pack.workshop.timed && isOpen() ? pack.workshop.bibsPerRace : 0; - view.innerHTML = trackingView({ - rows, - tab, - counts, - query: trackingQuery, - tx, - format, - race, - }); + const canRace = (row) => row.used < row.variant.attempts; + raceSelection = race + ? raceSelection.filter((bib) => + all.some((row) => String(row.child.bib) === bib && canRace(row)), + ) + : []; + view.innerHTML = trackingView({ tab, counts, query: trackingQuery, tx, race }); + const results = view.querySelector('.entry-tracking-results'); const search = view.querySelector('.entry-tracking-search'); - search.addEventListener('submit', (event) => event.preventDefault()); - search.querySelector('input').addEventListener('input', (event) => { - trackingQuery = event.target.value; - const caret = event.target.selectionStart; - showTracking(tab); - const input = view.querySelector('.entry-tracking-search input'); - input.focus(); - input.setSelectionRange(caret, caret); - }); - - const form = view.querySelector('.entry-tracking-race'); - if (race && form) { + const input = search.querySelector('input'); + + const matching = () => { + const query = searchKey(trackingQuery); + return query + ? all.filter( + (row) => String(row.child.bib) === query || searchKey(row.child.name).startsWith(query), + ) + : all.filter((row) => row.tabs.includes(tab)); + }; + + // Only the list is redrawn: the search field keeps its focus and the keyboard its mode. + const renderResults = () => { + const selected = all.filter((row) => raceSelection.includes(String(row.child.bib))); + const rows = [ + ...selected, + ...matching().filter((row) => !raceSelection.includes(String(row.child.bib))), + ]; + results.innerHTML = trackingResults({ + rows, + tab, + query: trackingQuery, + tx, + format, + race, + selected: raceSelection, + }); + const form = results.querySelector('.entry-tracking-race'); + if (!race || !form) { + return; + } const boxes = [...form.querySelectorAll('input[type="checkbox"]')]; const start = form.querySelector('button[type="submit"]'); const update = () => { - const ticked = boxes.filter((box) => box.checked).length; for (const box of boxes) { - box.disabled = !box.checked && ticked >= race; + box.disabled = !box.checked && raceSelection.length >= race; } - start.disabled = ticked === 0; + start.disabled = raceSelection.length === 0; }; for (const box of boxes) { - box.addEventListener('change', update); + box.addEventListener('change', () => { + raceSelection = box.checked + ? [...raceSelection.filter((bib) => bib !== box.value), box.value] + : raceSelection.filter((bib) => bib !== box.value); + update(); + }); } form.addEventListener('submit', (event) => { event.preventDefault(); - const ticked = boxes.filter((box) => box.checked).map((box) => box.value); - if (ticked.length > 0) { - location.hash = `race/${ticked[0]}/${ticked[1] ?? '-'}/timer`; + if (raceSelection.length > 0) { + const [first, second] = raceSelection; + raceSelection = []; + trackingQuery = ''; + location.hash = `race/${first}/${second ?? '-'}/timer`; } }); update(); - } + }; + + input.addEventListener('input', () => { + trackingQuery = input.value; + renderResults(); + }); + // "Search" key of the phone keyboard (or Enter): a single free match is ticked + // and the field is cleared, ready for the next bib. + search.addEventListener('submit', (event) => { + event.preventDefault(); + const free = matching().filter( + (row) => canRace(row) && !raceSelection.includes(String(row.child.bib)), + ); + if (race && trackingQuery !== '' && free.length === 1 && raceSelection.length < race) { + raceSelection = [...raceSelection, String(free[0].child.bib)]; + trackingQuery = ''; + input.value = ''; + renderResults(); + } + }); + renderResults(); }; const showHelp = () => { diff --git a/public/assets/js/entry/views.js b/public/assets/js/entry/views.js index ed42a9a..5e8602f 100644 --- a/public/assets/js/entry/views.js +++ b/public/assets/js/entry/views.js @@ -289,7 +289,7 @@ export const TRACKING_TABS = ['todo', 'started', 'finished', 'absent', 'all']; * it works without network. On a time workshop, ticking 1 or 2 children starts * their race. */ -export const trackingView = ({ rows, tab, counts, query, tx, format, race }) => ` +export const trackingView = ({ tab, counts, query, tx, race }) => `

← ${h(tx('entry.back_to_entry'))}

${h(tx('entry.tracking.title'))}

- ${ - rows.length === 0 - ? `

${h(query ? tx('entry.tracking.no_match', { query }) : tx(`entry.tracking.empty.${tab}`))}

` - : `
- ${race ? `

${h(tx('entry.tracking.race_hint', { count: race }))}

` : ''} + ${race ? `

${h(tx('entry.tracking.race_hint', { count: race }))} ${h(tx('entry.tracking.race_search_hint'))}

` : ''} +
`; + +/** + * List part of the follow-up, redrawn alone while typing in the search so + * that the field (and the phone keyboard mode) stays as it is. + */ +export const trackingResults = ({ rows, tab, query, tx, format, race, selected = [] }) => + rows.length === 0 + ? `

${h(query ? tx('entry.tracking.no_match', { query }) : tx(`entry.tracking.empty.${tab}`))}

` + : `
${race ? '' : ''} @@ -316,8 +322,14 @@ export const trackingView = ({ rows, tab, counts, query, tx, format, race }) => ${rows .map( - ({ child, variant, used, best, toCheck }) => ` - ${race ? `` : ''} + ({ + child, + variant, + used, + best, + toCheck, + }) => ` + ${race ? `` : ''}
${used < variant.attempts ? `` : ''}${used < variant.attempts ? `` : ''}${h(child.bib)} ${h(child.name)} ${child.present ? '' : `${h(tx('entry.not_checked_in'))}`} @@ -330,8 +342,7 @@ export const trackingView = ({ rows, tab, counts, query, tx, format, race }) => .join('')}
${race ? `
` : ''} -
` - }`; + `; /** Help of the workshop, kept on the phone (spec § 8.7). */ export const helpView = ({ pack, tx }) => ` diff --git a/src/Application/EntryPack.php b/src/Application/EntryPack.php index 9fa24f5..c519997 100644 --- a/src/Application/EntryPack.php +++ b/src/Application/EntryPack.php @@ -48,7 +48,7 @@ final class EntryPack 'entry.offline.status_pending', 'entry.offline.status_rejected', 'entry.offline.status_closed', 'entry.offline.remove', 'entry.offline.confirm_remove', 'entry.offline.needs_network', 'entry.offline.updated_at', 'entry.tracking.title', 'entry.tracking.search', 'entry.tracking.best', 'entry.tracking.no_match', - 'entry.tracking.race_hint', 'entry.tracking.start_race', 'entry.tracking.tab.todo', 'entry.tracking.tab.started', + 'entry.tracking.race_hint', 'entry.tracking.race_search_hint', 'entry.tracking.start_race', 'entry.tracking.tab.todo', 'entry.tracking.tab.started', 'entry.tracking.tab.finished', 'entry.tracking.tab.absent', 'entry.tracking.tab.all', 'entry.tracking.empty.todo', 'entry.tracking.empty.started', 'entry.tracking.empty.finished', 'entry.tracking.empty.absent', 'entry.tracking.empty.all', 'entry.attempts_done', 'entry.to_check', 'entry.back_to_entry', 'entry.help', 'check_in.child',