Portage navigateur complet de l'app Android HormoneTrack v1.4.10 : - moteur PK fidèle (Estrannaise tables ODS, Transfem Science V3C, WHSAH fit Mona, Bateman) — paramètres identiques, invariants Android préservés (fixes #19-#23, #35, #52-#62), 121 tests Node épinglés - calibration par période d'ester et par modèle affiché (#60/#61) - UI 6 écrans + éditeur, CurveChart Canvas (zoom/pan fractionnaire, prévision, pics/creux, fuseau configurable), rappels web (Notification API), seuils d'alerte, i18n FR/EN - sauvegarde JSON v2 compatible Android bidirectionnelle (rétrocompat v1) - 100 % local : localStorage, aucun serveur applicatif, aucune télémétrie - processus : scripts/check.sh (syntaxe, i18n, tests, E2E navigateur, smoke HTTP), docs séparées (README + DEVELOPPEMENT + CHANGELOG) - dépôt GIT SÉPARÉ de l'Android : historique 100 % propre, versions alignées sur l'Android porté, changelogs indépendants Non porté (impossible dans un navigateur, documenté §12) : agenda récurrent, notifications onglet fermé, montre.
63 lines
2.8 KiB
JavaScript
63 lines
2.8 KiB
JavaScript
/**
|
||
* ─────────────────────────────────────────────────────────────────────────────
|
||
* Écran Traitements (portage de `ui/screens/TreatmentsScreen.kt`).
|
||
*
|
||
* Cartes (nom, voie, dose, chips ester·modèle / Tmax / ×scale / ⏰ rappel,
|
||
* badge inactif) → tap = éditeur. ⚠️ Le chip modèle passe par modelLabelKey
|
||
* (fix #59 : un ternaire à 2 branches affichait « Estrannaise » pour WHSAH).
|
||
* ─────────────────────────────────────────────────────────────────────────────
|
||
*/
|
||
|
||
import { store } from '../data/store.js';
|
||
import { modelLabelKey, routeLabelKey, treatmentFlags } from '../data/models.js';
|
||
import { t } from '../util/i18n.js';
|
||
import { formatDose } from '../util/format.js';
|
||
import { el, assistChip, fab } from './components.js';
|
||
|
||
/**
|
||
* Rend l'écran Traitements.
|
||
* @param {HTMLElement} container
|
||
* @param {object} ctx { openEditor: (id:number)=>void, openNew: ()=>void }
|
||
*/
|
||
export function renderTreatments(container, ctx) {
|
||
const treatments = store.getTreatments();
|
||
|
||
const col = el('div', {});
|
||
container.appendChild(col);
|
||
|
||
if (treatments.length === 0) {
|
||
col.appendChild(el('p', {}, t('no_data')));
|
||
}
|
||
|
||
for (const tr of treatments) {
|
||
const flags = treatmentFlags(tr); // miroir des getters Kotlin
|
||
const card = el('div', { class: 'card', style: 'cursor:pointer;', onclick: () => ctx.openEditor(tr.id) });
|
||
|
||
const titleRow = el('div', { class: 'row' });
|
||
titleRow.appendChild(el('span', { style: 'font-weight:600;flex:1;' }, tr.name));
|
||
if (!tr.isActive) titleRow.appendChild(el('span', { class: 'small' }, t('inactive')));
|
||
card.appendChild(titleRow);
|
||
|
||
card.appendChild(el('div', { class: 'sub' },
|
||
`${t(routeLabelKey(tr.route))} · ${formatDose(tr.doseAmount)} ${tr.doseUnit}`));
|
||
|
||
const chipRow = el('div', { class: 'chip-row wrap', style: 'margin-top:6px;' });
|
||
if (flags.usesProfileModel) {
|
||
// v1.4.7 (fix #59) : label via modelLabelKey — pas de ternaire à 2 branches
|
||
chipRow.appendChild(assistChip(`${tr.esterType} · ${t(modelLabelKey(tr.pkModel))}`));
|
||
} else {
|
||
chipRow.appendChild(assistChip(`${t('pk_absorption')} ${formatDose(tr.absorptionHours)}h`));
|
||
}
|
||
if (tr.scaleFactor !== 1.0) chipRow.appendChild(assistChip(`×${tr.scaleFactor.toFixed(2)}`));
|
||
if (tr.reminderEnabled) {
|
||
const hh = String(tr.reminderHour ?? 0).padStart(2, '0');
|
||
const mm = String(tr.reminderMinute ?? 0).padStart(2, '0');
|
||
chipRow.appendChild(assistChip(`⏰ ${hh}:${mm}`));
|
||
}
|
||
card.appendChild(chipRow);
|
||
col.appendChild(card);
|
||
}
|
||
|
||
container.appendChild(fab(ctx.openNew));
|
||
}
|