WOD : séance à format, chrono et score (lot 4b, ADR 0010)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
d9604d43ec
commit
ee3f55a515
@@ -8,12 +8,14 @@ import { localDay, longDay, plural } from "../format.js";
|
||||
import { estimatedMinutes } from "../../domain/progression.js";
|
||||
import { actionBar, screenHeader } from "../layout.js";
|
||||
import { href } from "../router.js";
|
||||
import { buildSessionData, completion, createDraft, doneCount, draftMatches, draftTotals, replaceExercise, replaceQuery, setsInOrder, substituteItem } from "../session-draft.js";
|
||||
import { buildSessionData, completion, createDraft, doneCount, draftMatches, draftTotals, replaceExercise, replaceQuery, setsInOrder, substituteItem, wodMissing } from "../session-draft.js";
|
||||
import { clearDraft, loadDraft, saveDraft, takeReopen } from "../draft-storage.js";
|
||||
import { exerciseCard } from "../exercise-card.js";
|
||||
import { warmupCard, warmupSteps } from "../warmup-card.js";
|
||||
import { confirmDialog, toast } from "../feedback.js";
|
||||
import { comboLabel, recordFinish } from "../game.js";
|
||||
import { wodPanel } from "../wod-panel.js";
|
||||
import { formatLabel } from "../../domain/wod.js";
|
||||
|
||||
/**
|
||||
* @param {{store: import("../store.js").Store, key: string, date: string|null, nav: import("../router.js").Navigation, timer: import("../timer.js").Timer}} ctx
|
||||
@@ -45,6 +47,7 @@ export function sessionScreen({ store, key, date, nav, timer }) {
|
||||
const status = h("p", { class: "status", role: "alert" });
|
||||
const totalSets = draft.exercises.reduce((n, ex) => n + ex.sets, 0);
|
||||
const paintProgress = () => {
|
||||
if (draft.wod) return progress.replaceChildren(h("span", null, formatLabel(draft.wod.format)));
|
||||
const done = draft.exercises.reduce((n, ex) => n + doneCount(ex), 0);
|
||||
const combo = comboLabel(setsInOrder(draft));
|
||||
progress.replaceChildren(h("span", null, `${done}/${totalSets} séries`), combo ? h("span", { class: "combo" }, combo) : "");
|
||||
@@ -112,13 +115,22 @@ export function sessionScreen({ store, key, date, nav, timer }) {
|
||||
cards);
|
||||
});
|
||||
|
||||
// Séance WOD (ADR 0010) : un panneau à la place des cartes de séries.
|
||||
const wod = draft.wod ? wodPanel({ draft, session, store, onChange }) : null;
|
||||
|
||||
const finish = async () => {
|
||||
const c = completion(draft);
|
||||
if (c.doneSets === 0) {
|
||||
if (draft.wod) {
|
||||
const missing = wodMissing(draft.wod);
|
||||
if (missing) {
|
||||
status.textContent = missing;
|
||||
return;
|
||||
}
|
||||
} else if (c.doneSets === 0) {
|
||||
status.textContent = "Aucune série validée : rien à enregistrer.";
|
||||
return;
|
||||
}
|
||||
if (!c.complete) {
|
||||
if (!draft.wod && !c.complete) {
|
||||
const lines = [];
|
||||
if (c.missing.length)
|
||||
lines.push(`${plural(c.missing.length, "exercice")} pas commencé${c.missing.length > 1 ? "s" : ""} : ${c.missing.slice(0, 3).join(", ")}${c.missing.length > 3 ? "…" : "."}`);
|
||||
@@ -155,12 +167,14 @@ export function sessionScreen({ store, key, date, nav, timer }) {
|
||||
dateNotice,
|
||||
h("div", { class: "exercises" },
|
||||
warmup.steps.length > 0 && warmupCard({ plan: warmup, done: draft.warmup, timer, onChange, open: !resumed }),
|
||||
blocks),
|
||||
wod ? wod.node : blocks),
|
||||
status,
|
||||
h("p", { class: "foot" }, "Touche une série pour noter tes répétitions et ton ressenti : le repos démarre tout seul."),
|
||||
h("p", { class: "foot" }, wod
|
||||
? "Lance le chrono, suis les bips, puis note ton score : il restera dans ton historique."
|
||||
: "Touche une série pour noter tes répétitions et ton ressenti : le repos démarre tout seul."),
|
||||
actionBar(progress, h("button", { type: "button", class: "btn btn--primary btn--lg", on: { click: finish } }, "Terminer la séance")));
|
||||
setAccent(node, color, inkOn(color));
|
||||
paintProgress();
|
||||
|
||||
return { node, title: session.name, destroy: () => timer.stop() };
|
||||
return { node, title: session.name, destroy: () => { timer.stop(); wod?.destroy(); } };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user