From 589c788b97da36f9d71c2dfd5d30de6b7679f1a6 Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 3 Aug 2026 11:41:00 -0400 Subject: [PATCH] =?UTF-8?q?MSIN-4546=20=E2=80=94=20Implement=20production?= =?UTF-8?q?=20panel=20loading=20via=20AJAX=20on=20first=20click,=20enhanci?= =?UTF-8?q?ng=20user=20experience=20by=20deferring=20content=20loading=20u?= =?UTF-8?q?ntil=20necessary.=20Update=20version=20code=20to=204.72.938.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ajax_bib_range.php | 32 ++++++++++++++++++++++ js/v2/bib-assignments.js | 59 ++++++++++++++++++++++++++++++++++++++++ php/inc_fx_promoteur.php | 31 +++++++++++++++++---- php/inc_settings.php | 2 +- 4 files changed, 117 insertions(+), 7 deletions(-) diff --git a/ajax_bib_range.php b/ajax_bib_range.php index 5ed7ac54..e123515e 100644 --- a/ajax_bib_range.php +++ b/ajax_bib_range.php @@ -53,6 +53,7 @@ $arrBibAjaxActions = [ 'production_fields_save', 'qty_summary', 'race_detail', + 'production_panel', ]; if ($action !== '' && in_array($action, $arrBibAjaxActions, true)) { @@ -1316,6 +1317,37 @@ if ($action == 'anomalies') { exit; } +// MSIN-4546 — Onglet Production (chargé seulement à l'ouverture de l'espace). +if ($action == 'production_panel') { + + $int_eve_id = (int)($_POST['eve_id'] ?? $_GET['eve_id'] ?? 0); + if ($int_eve_id <= 0) { + echo json_encode([ + 'success' => false, + 'message' => fxBibMsg('bib_v4_ajax_epr_invalid'), + ]); + exit; + } + + global $objDatabase; + $tabEpreuves = $objDatabase->fxGetResults( + "SELECT * FROM inscriptions_epreuves e + WHERE e.eve_id = $int_eve_id AND e.epr_actif = 1 + ORDER BY e.epr_id" + ); + if (!is_array($tabEpreuves)) { + $tabEpreuves = []; + } + + $tabShellStats = fxBibCollectEventShellStats($int_eve_id); + + echo json_encode([ + 'success' => true, + 'html' => renderBibProductionPreview($tabEpreuves, $strLangue, $tabShellStats), + ]); + exit; +} + // MSIN-4546 — Détail éditable d'une épreuve (ouverture carte). if ($action == 'race_detail') { diff --git a/js/v2/bib-assignments.js b/js/v2/bib-assignments.js index 1eb18bb3..97a66266 100644 --- a/js/v2/bib-assignments.js +++ b/js/v2/bib-assignments.js @@ -593,6 +593,11 @@ bibSyncWorkspaceTabHighlight(); bibSyncWorkspaceSurfaceVisibility(); + // MSIN-4546 — Charger Production seulement quand on ouvre cet espace. + if (workspaceId === 'production') { + bibEnsureProductionPanelLoaded(); + } + // MSIN-4475 — Modes d'assignation : afficher les choix tout de suite (sans clic tuile). if (workspaceId === 'operations' && options.keepTool !== true) { var autoTool = panel.getAttribute('data-bib-auto-tool'); @@ -602,6 +607,60 @@ } } + var bibProductionLoadPromise = null; + + /** + * MSIN-4546 — Onglet Production = page séparée : AJAX au 1er clic seulement. + */ + function bibEnsureProductionPanelLoaded() { + var panel = moduleBib.querySelector('[data-bib-workspace-panel="production"]'); + var mount = document.getElementById('bib-production-mount'); + if (!panel) { + return Promise.resolve(); + } + // Déjà chargé (mount remplacé par le HTML production). + if (panel.getAttribute('data-production-loaded') === '1' || !mount) { + return Promise.resolve(); + } + if (panel.getAttribute('data-production-deferred') !== '1' + && mount.getAttribute('data-production-deferred') !== '1') { + return Promise.resolve(); + } + if (bibProductionLoadPromise) { + return bibProductionLoadPromise; + } + + bibProductionLoadPromise = bibFetch('/ajax_bib_range.php', { + method: 'POST', + headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, + body: 'action=production_panel' + + '&eve_id=' + encodeURIComponent(moduleBib.dataset.eveId || '') + + bibAjaxLangSuffix() + }, { loader: true }) + .then(function (res) { return res.json(); }) + .then(function (data) { + if (!data || !data.success || !data.html) { + throw new Error((data && data.message) || bibJs('jsErrGeneric') || 'Erreur'); + } + mount.outerHTML = data.html; + panel.removeAttribute('data-production-deferred'); + panel.setAttribute('data-production-loaded', '1'); + initModuleBibTippy(panel); + return panel; + }) + .catch(function (err) { + var msg = (err && err.message) ? err.message : (bibJs('jsServerError') || 'Erreur serveur'); + mount.innerHTML = '
' + + bibTippyEscapeHtml(msg) + + '
'; + }) + .finally(function () { + bibProductionLoadPromise = null; + }); + + return bibProductionLoadPromise; + } + /** MSIN-4512 — PDF ouvert : ne pas laisser l’onglet workspace allumé en parallèle. */ function bibSyncWorkspaceTabHighlight() { var highlightWorkspace = (bibActiveTool === 'dist_print') ? null : bibActiveWorkspace; diff --git a/php/inc_fx_promoteur.php b/php/inc_fx_promoteur.php index 40abeda5..68ba793d 100644 --- a/php/inc_fx_promoteur.php +++ b/php/inc_fx_promoteur.php @@ -5454,6 +5454,25 @@ function renderBibProductionFieldSideRow($intEprId, $strKey, $strLabel, $strSele } /** MSIN-4467 / MSIN-4469 / MSIN-4515 — Production physique et fichier officiel Excel. */ +/** + * MSIN-4546 — Coquille onglet Production (aucun catalogue Face/Endos au 1er paint). + */ +function renderBibProductionPreviewShell($intEveId, $strLangue = 'fr') { + $intEveId = (int)$intEveId; + ob_start(); + ?> +
+
+

+
+
+ - -
-
- -
-
+