Remplacer un exercice en séance (lot 3b)
Lien « Machine prise ? » sur la carte, bibliothèque en mode choix (#/bibliotheque?remplacer=A.3), proches d'abord ; replaces dans SessionLogged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
b385c4566b
commit
38e0283f3d
@@ -8,8 +8,8 @@ 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, setsInOrder } from "../session-draft.js";
|
||||
import { clearDraft, loadDraft, saveDraft } from "../draft-storage.js";
|
||||
import { buildSessionData, completion, createDraft, doneCount, draftMatches, draftTotals, replaceExercise, replaceQuery, setsInOrder, substituteItem } 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";
|
||||
@@ -76,18 +76,34 @@ export function sessionScreen({ store, key, date, nav, timer }) {
|
||||
// ---- blocs ---------------------------------------------------------------------
|
||||
const color = sessionColor(session.color);
|
||||
const firstOpen = draft.exercises.findIndex((ex) => doneCount(ex) < ex.sets);
|
||||
// Retour de la bibliothèque après un remplacement : on rouvre cette carte.
|
||||
const reopen = takeReopen();
|
||||
let index = 0;
|
||||
const blocks = groupBlocks(session.exercises).map((block) => {
|
||||
const shown = block.items.map((item, k) => {
|
||||
const ex = draft.exercises[index + k];
|
||||
return ex.replaces ? substituteItem(item, ex.id) : item;
|
||||
});
|
||||
const cards = block.items.map((item, k) => {
|
||||
const i = index++;
|
||||
return exerciseCard({
|
||||
draft, ex: draft.exercises[i], item, sessionKey: session.key, number: String(i + 1),
|
||||
draft, ex: draft.exercises[i], item: shown[k], sessionKey: session.key, number: String(i + 1),
|
||||
letter: block.items.length > 1 ? String.fromCharCode(65 + k) : null,
|
||||
open: resumed && i === firstOpen, store, timer, onChange,
|
||||
open: (resumed && i === firstOpen) || i === reopen, store, timer, onChange,
|
||||
onReplace: () => {
|
||||
// Le brouillon est gardé avant de partir : la bibliothèque le modifie.
|
||||
saveDraft(draft);
|
||||
nav.go(href.library(replaceQuery(session.key, i)));
|
||||
},
|
||||
onRestore: () => {
|
||||
replaceExercise(draft, i, /** @type {{id: string}} */ (draft.exercises[i].replaces).id, item, store.getState());
|
||||
saveDraft(draft);
|
||||
nav.go(location.hash, { replace: true });
|
||||
},
|
||||
});
|
||||
});
|
||||
if (block.items.length === 1) return cards[0];
|
||||
const names = block.items.map((item) => resolveExercise(item).name).join(" + ");
|
||||
const names = shown.map((item) => resolveExercise(item).name).join(" + ");
|
||||
const rounds = Math.max(...block.items.map((item) => item.sets));
|
||||
return h("section", { class: "superset", "aria-label": `Superset : ${names}` },
|
||||
h("div", { class: "superset__head" },
|
||||
|
||||
Reference in New Issue
Block a user