From cc81acce5b6d43eddf6bd61566cef6e24c74ae4d Mon Sep 17 00:00:00 2001 From: LeRatierBretonnier Date: Thu, 30 Jul 2026 21:23:25 +0200 Subject: [PATCH] fix(appv2): correction sauvegarde champs description HTML - Remplacer les balises brutes par {{formInput}} pour les champs HTMLField (biographie, notes, description) - Onglets passent en basculement CSS sans re-render - Ajout de systemFields au contexte des feuilles d'acteur --- AGENTS.md | 51 +++++++++++++++++++ .../applications/sheets/base-actor-sheet.mjs | 4 +- templates/actor/parts/tabs/actor-biodata.hbs | 8 +-- .../actor/parts/tabs/horde-description.hbs | 4 +- .../actor/parts/tabs/vehicle-description.hbs | 4 +- 5 files changed, 58 insertions(+), 13 deletions(-) create mode 100644 AGENTS.md diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..b454324 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,51 @@ +# BoL — FoundryVTT Game System + +FoundryVTT game system for Barbarians of Lemuria (French edition, Ludospherik). System id `bol`. Compatible Foundry v13–v14. + +## Commands + +| Command | Action | +|---------|--------| +| `npm run css` | Compile LESS → `css/bol.css` (one-shot) | +| `npm run watch` / `npm start` | Watch `styles/**/*.less`, recompile on change | + +No test or lint scripts exist. + +## Entry Point & Architecture + +`module/bol.js` — wires everything in `Hooks.once('init', ...)` and `Hooks.once('ready', ...)`. + +| Path | Role | +|------|------| +| `module/bol.js` | System init, sheet/data model registration, socket setup | +| `module/system/config.js` | `BOL` constants, `System.debugMode` flag | +| `module/system/bol-utility.js` | Static helpers, settings (`bol` namespace), socket handler (`system.bol`) | +| `module/controllers/bol-rolls.js` | All roll logic — `BoLRoll` static methods | +| `module/models/` | DataModel classes (`.mjs`) for Actor/Item types | +| `module/applications/sheets/` | **AppV2 sheets** (`ActorSheetV2`/`ItemSheetV2` + `HandlebarsApplicationMixin`) | +| `styles/` | LESS sources → compiled to `css/bol.css` | +| `templates/` | Handlebars `.hbs` partials | +| `lang/` | `fr.json`, `en.json`, `de.json`, `es.json` | + +## Key Conventions + +- **AppV2 sheets** — base classes are `foundry.applications.sheets.ActorSheetV2` / `ItemSheetV2` mixed with `HandlebarsApplicationMixin`. Do NOT use `foundry.appv1.sheets.*`. +- **`game.bol`** — system exposes `BoLActor`, `BoLItem`, `BoLRoll`, `BoLUtility`, `Macros`, `BOL` config, `models`, `sheets` on this namespace after init. +- **i18n prefix** — all keys start with `BOL.`; use `game.i18n.localize("BOL.xxx")`. +- **FR-first** — `fr.json` is most complete. EN compendium translation requires [Babele](https://gitlab.com/riccisi/foundryvtt-babele) module. A warning fires at startup if EN is selected without Babele. +- **`System.debugMode = true`** in `module/system/config.js:8` — set to `false` before release. +- **LESS only** — never edit `css/bol.css` directly. Edit `.less` files under `styles/`, recompile with `npm run css`. +- **Data models** — `template.json` defines schema via `Actor.types` (character, encounter, horde, vehicle) and `Item.types` (item, feature). All data lives under `.system`. +- **Sheet partials** — registered in `module/system/templates.js`. Add new partials there. +- **Static classes** — `BoLRoll` and `BoLUtility` are purely static; never instantiate. +- **`template.json.SAVED`** in root is the data model reference; the actual `template.json` may need regeneration. +- **`package.json` and lockfile are in `.gitignore`** — npm is dev-only for LESS compilation. Not needed to run the system in Foundry. +- **`{{formInput}}` for HTML fields** — always use `{{formInput fieldDef enriched=x value=y name="system.path" toggled=isEditable}}` for `HTMLField` in AppV2 sheets. Never use raw `` elements; they break form submission. +- **Tab switching** — use CSS-only toggle (no `this.render()`) to preserve ProseMirror editor state. See `base-item-sheet.mjs` pattern. + +## CI & Release + +- CI triggers **only on release publish** (`.gitea/workflows/main.yml`). +- Release zips: `system.json template.json README.md LICENSE assets/ compendiums/ css/ fonts/ images/ lang/ module/ packs/ styles/ templates/ ui/`. +- Version/URL manifest/download are substituted in `system.json` during CI. +- Published to Foundry package registry via `foundryvtt-publish-package-action`. diff --git a/module/applications/sheets/base-actor-sheet.mjs b/module/applications/sheets/base-actor-sheet.mjs index 0041624..4d4e076 100644 --- a/module/applications/sheets/base-actor-sheet.mjs +++ b/module/applications/sheets/base-actor-sheet.mjs @@ -49,6 +49,7 @@ export default class BoLBaseActorSheet extends HandlebarsApplicationMixin(foundr return { actor, system: actor.system, + systemFields: actor.system.schema.fields, config: game.bol.config, isGM: game.user.isGM, isEditable: this.isEditable, @@ -112,7 +113,8 @@ export default class BoLBaseActorSheet extends HandlebarsApplicationMixin(foundr link.addEventListener("click", (event) => { event.preventDefault() this.tabGroups[group] = tab - this.render() + nav.querySelectorAll("[data-tab]").forEach(l => l.classList.toggle("active", l.dataset.tab === tab)) + this.element.querySelectorAll(`[data-group="${group}"][data-tab]`).forEach(c => c.classList.toggle("active", c.dataset.tab === tab)) }) }) diff --git a/templates/actor/parts/tabs/actor-biodata.hbs b/templates/actor/parts/tabs/actor-biodata.hbs index 7e08aef..99e9493 100644 --- a/templates/actor/parts/tabs/actor-biodata.hbs +++ b/templates/actor/parts/tabs/actor-biodata.hbs @@ -95,9 +95,7 @@ - - {{{biography}}} - +{{formInput systemFields.details.fields.biography enriched=biography value=system.details.biography name="system.details.biography" toggled=isEditable}} {{#if (eq charType "player")}}
    @@ -158,6 +156,4 @@
- - {{{notes}}} - \ No newline at end of file +{{formInput systemFields.details.fields.notes enriched=notes value=system.details.notes name="system.details.notes" toggled=isEditable}} \ No newline at end of file diff --git a/templates/actor/parts/tabs/horde-description.hbs b/templates/actor/parts/tabs/horde-description.hbs index d9288c1..a6b0037 100644 --- a/templates/actor/parts/tabs/horde-description.hbs +++ b/templates/actor/parts/tabs/horde-description.hbs @@ -5,7 +5,5 @@ - - {{{description}}} - +{{formInput systemFields.details.fields.biography enriched=description value=system.details.biography name="system.details.biography" toggled=isEditable}} diff --git a/templates/actor/parts/tabs/vehicle-description.hbs b/templates/actor/parts/tabs/vehicle-description.hbs index 6dff23b..ab10a16 100644 --- a/templates/actor/parts/tabs/vehicle-description.hbs +++ b/templates/actor/parts/tabs/vehicle-description.hbs @@ -5,7 +5,5 @@ - - {{{description}}} - +{{formInput systemFields.description enriched=description value=system.description name="system.description" toggled=isEditable}}