Matériel coché dans le profil, bibliothèque « ce que mon matériel permet » (5a)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
938d6cf198
commit
72adffb613
@@ -2,6 +2,7 @@
|
||||
// filtres dans l'adresse (ADR 0009), et la fiche d'un exercice. Calculs du
|
||||
// domaine : domain/library.js.
|
||||
|
||||
import { KIT, canDo, missingKit, requiredKit } from "../../domain/kit.js";
|
||||
import { h, replace } from "../dom.js";
|
||||
import { EXERCISES, FAMILIES, MUSCLES } from "../../domain/exercises.js";
|
||||
import { resolveExercise } from "../../domain/program.js";
|
||||
@@ -84,7 +85,13 @@ export function libraryScreen({ store, nav, query }) {
|
||||
const c = criteria;
|
||||
const muscles = c.zone ? Object.entries(MUSCLES).filter(([, m]) => m.zone === c.zone) : [];
|
||||
const more = !!(c.family || c.equipment);
|
||||
const kit = store.getState().profile.kit;
|
||||
replace(filters,
|
||||
// Le matériel coché du profil (lot 5a) : un seul geste pour ne voir que le faisable.
|
||||
kit && h("button", {
|
||||
type: "button", class: "choice lib-possible", "aria-pressed": String(!!c.possible),
|
||||
on: { click: () => update({ ...c, possible: !c.possible || undefined }) },
|
||||
}, "Seulement ce que mon matériel permet"),
|
||||
h("p", { class: "mini-label" }, "Zone"),
|
||||
segmented("Zone", ZONES.map((z) => [z, ZONE_LABELS[z]]), c.zone, (zone) => update({ ...c, zone: /** @type {any} */ (zone), muscle: undefined })),
|
||||
muscles.length > 1 && [
|
||||
@@ -97,13 +104,13 @@ export function libraryScreen({ store, nav, query }) {
|
||||
h("p", { class: "mini-label" }, "Matériel"),
|
||||
segmented("Matériel", Object.entries(EQUIPMENT_GROUPS).map(([k, v]) => [k, v.label]), c.equipment, (equipment) => update({ ...c, equipment: /** @type {any} */ (equipment) }))));
|
||||
|
||||
const groups = filterLibrary(c);
|
||||
const groups = filterLibrary(c, kit);
|
||||
const count = groups.reduce((n, g) => n + g.items.length, 0);
|
||||
// Les exercices génériques n'ont pas de muscles : ils ne suivent que la recherche.
|
||||
const words = c.q ? fold(c.q).split(/\s+/).filter(Boolean) : [];
|
||||
const generic = c.zone || c.muscle || c.family || c.equipment ? []
|
||||
const generic = c.zone || c.muscle || c.family || c.equipment || c.possible ? []
|
||||
: genericExercises(store.getState()).filter((x) => words.every((w) => fold(x.name).includes(w)));
|
||||
const filtered = !!(c.q || c.zone || c.muscle || c.family || c.equipment);
|
||||
const filtered = !!(c.q || c.zone || c.muscle || c.family || c.equipment || c.possible);
|
||||
replace(results,
|
||||
h("p", { class: "lib-count" }, filtered ? `${plural(count, "exercice")} sur ${total}` : `${total} exercices`,
|
||||
filtered && h("button", { type: "button", class: "btn btn--ghost btn--sm", on: { click: () => { search.value = ""; update({}); } } }, "Tout effacer")),
|
||||
@@ -125,8 +132,9 @@ export function libraryScreen({ store, nav, query }) {
|
||||
paint();
|
||||
const near = pick ? [
|
||||
...(pick.planned.id !== pick.currentId && EXERCISES[pick.planned.id] ? [pick.planned.id] : []),
|
||||
// Pas un exercice déjà dans la séance : on ne remplace pas par un doublon.
|
||||
...similarExercises(pick.planned.id, 12).filter((r) => !pick.draft.exercises.some((x) => x.id === r)).slice(0, 8),
|
||||
// Ni un exercice déjà dans la séance (un doublon), ni un que le matériel coché ne permet pas.
|
||||
...similarExercises(pick.planned.id, 16)
|
||||
.filter((r) => !pick.draft.exercises.some((x) => x.id === r) && canDo(r, store.getState().profile.kit)).slice(0, 8),
|
||||
] : [];
|
||||
const node = h("div", { class: "screen" },
|
||||
pick
|
||||
@@ -181,6 +189,7 @@ export function libraryItemScreen({ store, nav, today, id }) {
|
||||
library && h("ul", { class: "chips", "aria-label": "Muscles" },
|
||||
library.primary.map((m) => h("li", { class: "chip" }, MUSCLES[m].name)),
|
||||
library.secondary.map((m) => h("li", { class: "chip chip--secondary" }, MUSCLES[m].name))),
|
||||
library && kitLine(id, state.profile.kit),
|
||||
|
||||
h("h2", { class: "tape" }, "Dans ton programme"),
|
||||
use.sessions.length
|
||||
@@ -229,6 +238,18 @@ function pickContext(state, query) {
|
||||
}
|
||||
|
||||
/** Ligne d'une liste : matériel et muscles principaux. @param {import("../../domain/exercises.js").LibraryExercise} x */
|
||||
/**
|
||||
* Le matériel que demande l'exercice, et ce qui manque au profil (lot 5a).
|
||||
* @param {string} ref @param {readonly string[]|undefined} kit
|
||||
*/
|
||||
function kitLine(ref, kit) {
|
||||
const needs = requiredKit(ref);
|
||||
if (!needs.length) return null;
|
||||
const missing = missingKit(ref, kit);
|
||||
return h("p", { class: "lib-kit" }, `Matériel : ${needs.map((k) => KIT[k]).join(", ")}.`,
|
||||
missing.length > 0 && h("strong", null, ` Il te manque : ${missing.map((k) => KIT[k].toLowerCase()).join(", ")}.`));
|
||||
}
|
||||
|
||||
const metaOf = (x) => `${EQUIPMENT_LABELS[x.equipment]} · ${x.primary.map((m) => MUSCLES[m].name).join(", ")}`;
|
||||
|
||||
/** @param {string} link @param {string} title @param {string} meta */
|
||||
|
||||
Reference in New Issue
Block a user