Reprise dans le répertoire de production du travail mené dans le worktree ux-service-enfance : - tableau de bord Service Enfance (dashboard.php) et navigation regroupée ; - guide d'utilisation (faq.php) accessible depuis toute la navigation ; - éditeur de semaine type mis en avant sur l'écran de saisie ; - droit à l'enveloppe de formation par agent, en remplacement de la case « formation déjà prévue dans la répartition annuelle » ; - correctif de « [object Object] » sur les cartes de quota du PTA ; - motif de travail par défaut à la saisie, heures travaillées complètes dans les PDF. Le docker-compose.yml de production est conservé : celui du worktree décrit une pile de test (conteneurs et volume suffixés « test », ports 9080/9081), qui aurait fait redémarrer l'application sur un volume MariaDB vide. Les migrations database/migration_v7_9*.sql sont obligatoires ; le service db-migrate les applique au déploiement. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
121 lines
4.7 KiB
JavaScript
121 lines
4.7 KiB
JavaScript
(() => {
|
|
'use strict';
|
|
|
|
const PTA = window.PTA;
|
|
if (!PTA) return;
|
|
|
|
const page = window.PTA_PAGE_CONFIG || {};
|
|
const modules = Array.isArray(page.modules) ? page.modules : [];
|
|
const params = page.params || {};
|
|
|
|
modules.forEach((name) => PTA.modules[name]?.init?.());
|
|
|
|
async function initialisePlanning() {
|
|
const planning = PTA.modules.planning;
|
|
if (!planning) return;
|
|
|
|
const { structureSelect, agentSelect, weekInput, validateButton } = PTA.elements;
|
|
|
|
// Un lien profond qui désigne une semaine précise (file de validation,
|
|
// tableau de bord, vue annuelle) doit ouvrir la saisie semaine par
|
|
// semaine, et non l'éditeur de semaine type proposé par défaut.
|
|
if (params.week || params.focus) {
|
|
PTA.modules.weekTemplateEditor?.setMode?.('week');
|
|
}
|
|
|
|
if (params.structureId && structureSelect) {
|
|
structureSelect.value = String(params.structureId);
|
|
await planning.loadAgents();
|
|
if (params.structureLocked) structureSelect.disabled = true;
|
|
}
|
|
if (params.agentId && agentSelect) {
|
|
agentSelect.value = String(params.agentId);
|
|
if (weekInput) weekInput.disabled = false;
|
|
}
|
|
if (params.week && weekInput) {
|
|
weekInput.disabled = !agentSelect?.value;
|
|
weekInput.value = params.week;
|
|
if (agentSelect?.value) await planning.handleWeekSelection();
|
|
}
|
|
if (params.notice) PTA.utils.showMessage(params.notice, 'info');
|
|
if (params.focus === 'validation') {
|
|
window.setTimeout(() => {
|
|
document.querySelector('#editor-view .actions-bar')?.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
validateButton?.focus({ preventScroll: true });
|
|
}, 150);
|
|
}
|
|
}
|
|
|
|
async function initialiseStructureOverview() {
|
|
if (!params.structureId) return;
|
|
const select = document.querySelector('#overview-structure');
|
|
if (select) {
|
|
select.value = String(params.structureId);
|
|
if (params.structureLocked) select.disabled = true;
|
|
}
|
|
await PTA.modules.structureOverview?.load?.();
|
|
}
|
|
|
|
async function initialiseAgentOverview() {
|
|
if (params.agentId) {
|
|
const select = document.querySelector('#overview-agent');
|
|
if (select) {
|
|
select.value = String(params.agentId);
|
|
if (params.agentLocked) select.disabled = true;
|
|
}
|
|
}
|
|
if (params.month) {
|
|
const input = document.querySelector('#agent-overview-month');
|
|
if (input) input.value = params.month;
|
|
}
|
|
if (params.agentId) await PTA.modules.agentOverview?.load?.();
|
|
}
|
|
|
|
function initialiseCoverage() {
|
|
if (!params.structureId) return;
|
|
const select = document.querySelector('#coverage-structure-filter');
|
|
if (select) {
|
|
select.value = String(params.structureId);
|
|
if (params.structureLocked) select.disabled = true;
|
|
PTA.modules.coverage?.refresh?.();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Pastille « À valider » de la barre de navigation.
|
|
*
|
|
* Elle n'était alimentée que sur la page « À valider » elle-même, donc
|
|
* invisible là où elle sert : depuis n'importe quel écran, le service voit
|
|
* maintenant si des brouillons attendent. La requête est volontairement
|
|
* réduite à un compteur, et son échec est silencieux — une commodité ne
|
|
* doit jamais empêcher une page de fonctionner.
|
|
*/
|
|
async function refreshNavigationCounters() {
|
|
const badge = document.querySelector('#pending-validation-tab-badge');
|
|
if (!badge) return;
|
|
// Les écrans qui chargent déjà ce compteur s'en chargent eux-mêmes.
|
|
if (PTA.modules.pendingValidation || PTA.modules.dashboard) return;
|
|
if (!PTA.config?.permissions?.can_view_pending) return;
|
|
|
|
try {
|
|
const response = await fetch('api/dashboard_summary.php?scope=badges', {
|
|
headers: { Accept: 'application/json' },
|
|
});
|
|
if (!response.ok) return;
|
|
const data = await PTA.utils.readJsonResponse(response);
|
|
const count = Number(data?.validation?.count || 0);
|
|
badge.textContent = String(count);
|
|
badge.hidden = count === 0;
|
|
badge.setAttribute('aria-label', `${count} planning${count > 1 ? 's' : ''} en attente de validation`);
|
|
} catch (error) {
|
|
badge.hidden = true;
|
|
}
|
|
}
|
|
|
|
initialisePlanning();
|
|
initialiseStructureOverview();
|
|
initialiseAgentOverview();
|
|
initialiseCoverage();
|
|
refreshNavigationCounters();
|
|
})();
|