Réparer les scripts intégrés aux vues

This commit is contained in:
Alexandre NOEL 2026-09-03 23:08:03 +02:00
commit 64ce1285aa
12 changed files with 112 additions and 97 deletions

View file

@ -138,9 +138,9 @@ $today = date('Y-m-d');
select.required = !opening;
name.required = opening;
button.setAttribute('aria-expanded', opening ? 'true' : 'false');
button.textContent = opening ? < ? = json_encode(t('common.choose_from_list'),
JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ? > : '+ ' + < ? = json_encode(t(
'common.add'), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ? > ;
button.textContent = opening ? <?= json_encode(t('common.choose_from_list'),
JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?> : '+ ' + <?= json_encode(t(
'common.add'), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?> ;
if (opening) name.focus();
});
});
@ -746,10 +746,10 @@ $today = date('Y-m-d');
const kind = sterilizedCheckbox.form.querySelector('select[name="kind"]');
const reason = document.getElementById('medicalReason');
if (kind) kind.value = 'acte';
if (reason && reason.value.trim() === '') reason.value = < ? = json_encode(t(
'animal.sterilization_label'), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ? > ;
if (reason && reason.value.trim() === '') reason.value = <?= json_encode(t(
'animal.sterilization_label'), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?> ;
});
const animalId = < ? = (int) $animal['id'] ? > ;
const animalId = <?= (int) $animal['id'] ?> ;
const legacyKey = 'animal_show_active_tab_' + animalId;
// L'ancien comportement mémorisait le dernier onglet par animal. Une
// ouverture normale doit désormais toujours revenir sur Identité.
@ -822,8 +822,8 @@ $today = date('Y-m-d');
select = document.getElementById('labTemplate');
if (!body) return;
const presets = {};
const references = < ? = json_encode($labReferenceSets ?? [], JSON_UNESCAPED_UNICODE |
JSON_UNESCAPED_SLASHES) ? > ;
const references = <?= json_encode($labReferenceSets ?? [], JSON_UNESCAPED_UNICODE |
JSON_UNESCAPED_SLASHES) ?> ;
Object.entries(references).forEach(([key, set]) => presets['ref:' + key] = (set.parameters || []).map(p => [
p.code + ' — ' + p.name, p.unit, p.min, p.max
]));
@ -882,16 +882,16 @@ $today = date('Y-m-d');
pointRadius: 4,
tension: .2
}, {
label: < ? = json_encode(t('medical_document.reference_min'),
JSON_UNESCAPED_UNICODE) ? > ,
label: <?= json_encode(t('medical_document.reference_min'),
JSON_UNESCAPED_UNICODE) ?> ,
data: points.map(p => p.min),
borderColor: '#74c0fc',
borderDash: [5, 5],
pointRadius: 0,
spanGaps: true
}, {
label: < ? = json_encode(t('medical_document.reference_max'),
JSON_UNESCAPED_UNICODE) ? > ,
label: <?= json_encode(t('medical_document.reference_max'),
JSON_UNESCAPED_UNICODE) ?> ,
data: points.map(p => p.max),
borderColor: '#ffa8a8',
borderDash: [5, 5],
@ -921,7 +921,7 @@ $today = date('Y-m-d');
x: {
title: {
display: true,
text: < ? = json_encode(t('chart.date'), JSON_UNESCAPED_UNICODE) ? >
text: <?= json_encode(t('chart.date'), JSON_UNESCAPED_UNICODE) ?>
}
}
}
@ -936,7 +936,7 @@ $today = date('Y-m-d');
const el = document.getElementById('weightChart');
if (!el) return;
const rows = < ? = json_encode($weights ?? [], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) ? > ;
const rows = <?= json_encode($weights ?? [], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) ?> ;
// labels = dates, data = poids
const labels = rows.map(r => (r.measured_at || '').slice(0, 10)); // YYYY-MM-DD
@ -948,7 +948,7 @@ $today = date('Y-m-d');
data: {
labels,
datasets: [{
label: < ? = json_encode(t('chart.weight'), JSON_UNESCAPED_UNICODE) ? > ,
label: <?= json_encode(t('chart.weight'), JSON_UNESCAPED_UNICODE) ?> ,
data,
tension: 0.25,
pointRadius: 2
@ -972,7 +972,7 @@ $today = date('Y-m-d');
x: {
title: {
display: true,
text: < ? = json_encode(t('chart.date'), JSON_UNESCAPED_UNICODE) ? >
text: <?= json_encode(t('chart.date'), JSON_UNESCAPED_UNICODE) ?>
}
}
}
@ -985,14 +985,14 @@ $today = date('Y-m-d');
(function() {
const btn = document.getElementById('btn-icad-refresh');
const body = document.getElementById('icad-card-body');
const tr = < ? = json_encode(['error' => t('animal.icad_error'), 'empty' => t('animal.no_icad'), 'date' =>
const tr = <?= json_encode(['error' => t('animal.icad_error'), 'empty' => t('animal.no_icad'), 'date' =>
t('common.date'), 'recorded' => t('animal.recorded'), 'noEvent' => t('animal.no_event'),
'holder' => t('animal.holder_internal'), 'name' => t('common.name'), 'phone' => t(
'common.phone'), 'email' => t('common.email'), 'icadName' => t('animal.icad_name'),
'microchip' => t('animal.microchip'), 'sex' => t('animal.sex'), 'birth' => t('animal.birth'),
'appearance' => t('animal.appearance'), 'history' => t('animal.icad_history'), 'fetching' => t(
'animal.icad_fetching'), 'fetchError' => t('animal.icad_fetch_error')
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ? > ;
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?> ;
if (!btn || !body) return;
function esc(s) {
@ -1082,7 +1082,7 @@ ${ownerHtml}
body: new URLSearchParams({
id,
force: '1',
csrf: < ? = json_encode(Auth::csrf()) ? >
csrf: <?= json_encode(Auth::csrf()) ?>
})
});
const j = await r.json();