MSIN-4526 — Refactor bib assignment logic to eliminate unnecessary AJAX calls for checkbox visibility, enhancing performance. Update version code to 4.72.913.
This commit is contained in:
@ -2997,7 +2997,11 @@
|
||||
}
|
||||
|
||||
function bibCountSelectedRanges(row) {
|
||||
return row.querySelectorAll('.batch-select-range:checked').length;
|
||||
// MSIN-4526 — Ignorer les cases masquées (autre mode).
|
||||
return Array.from(row.querySelectorAll('.batch-select-range:checked')).filter(function (cb) {
|
||||
let wrap = cb.closest('.batch-checkbox');
|
||||
return wrap && !wrap.classList.contains('bib-ui-hidden');
|
||||
}).length;
|
||||
}
|
||||
|
||||
/** MSIN-4436 — Développe un bloc repliable #module-bib. */
|
||||
@ -3667,7 +3671,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
/** MSIN-4379 — Quitte le mode édition auto sans sauver ; recharge les plages (mode assign). */
|
||||
/** MSIN-4379 — Quitte le mode édition auto sans sauver. MSIN-4526 — local, sans refresh_ranges. */
|
||||
function exitAutoMode(row) {
|
||||
|
||||
if (!row) return;
|
||||
@ -3683,27 +3687,14 @@
|
||||
input.removeAttribute('readonly');
|
||||
});
|
||||
|
||||
bibFetch('/ajax_bib_range.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body:
|
||||
'action=refresh_ranges'
|
||||
+ '&epr_id=' + encodeURIComponent(row.dataset.eprId)
|
||||
+ '&mode=assign'
|
||||
+ bibAjaxLangSuffix()
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
row.querySelectorAll('.batch-select-range').forEach(function (cb) {
|
||||
cb.checked = false;
|
||||
});
|
||||
|
||||
if (!data.success) return;
|
||||
|
||||
let bibContainer = setBibContainerFromAjax(row, data);
|
||||
});
|
||||
syncBibUiState(row);
|
||||
}
|
||||
|
||||
/** MSIN-4379 — Ouvre le mode édition : checkboxes, bloc Accepter/Annuler, refresh mode=auto. */
|
||||
/** MSIN-4379 — Ouvre le mode édition auto. MSIN-4526 — local, sans refresh_ranges. */
|
||||
function enterAutoMode(row) {
|
||||
|
||||
if (!row) return;
|
||||
@ -3727,36 +3718,9 @@
|
||||
input.setAttribute('readonly', true);
|
||||
});
|
||||
|
||||
bibSyncModeRangeCheckboxes(row, { precheckAuto: true });
|
||||
updateAutoSelectionInfo(row);
|
||||
syncBibUiState(row);
|
||||
|
||||
bibFetch('/ajax_bib_range.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body:
|
||||
'action=refresh_ranges'
|
||||
+ '&epr_id=' + encodeURIComponent(row.dataset.eprId)
|
||||
+ '&mode=auto'
|
||||
+ bibAjaxLangSuffix()
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
|
||||
if (!data.success) return;
|
||||
|
||||
let bibContainer = setBibContainerFromAjax(row, data);
|
||||
if (!bibContainer) return;
|
||||
|
||||
bibContainer.classList.add('batch-mode');
|
||||
|
||||
row.querySelectorAll('.bib-start, .bib-qty, .bib-end').forEach(input => {
|
||||
input.setAttribute('readonly', true);
|
||||
});
|
||||
|
||||
updateAutoSelectionInfo(row);
|
||||
syncBibUiState(row);
|
||||
});
|
||||
}
|
||||
|
||||
function bibSyncResetAllEprButton(row) {
|
||||
@ -3786,6 +3750,52 @@
|
||||
btn.disabled = hasLock;
|
||||
}
|
||||
|
||||
/**
|
||||
* MSIN-4526 — Affiche/masque les cases séquence selon le mode, sans AJAX.
|
||||
* Assign/auto : dispo > 0. Reset : utilisés > 0.
|
||||
* @param {HTMLElement} row
|
||||
* @param {{precheckAuto?: boolean}} [opts]
|
||||
*/
|
||||
function bibSyncModeRangeCheckboxes(row, opts) {
|
||||
opts = opts || {};
|
||||
if (!row) {
|
||||
return;
|
||||
}
|
||||
|
||||
let modes = bibRowModes(row);
|
||||
let inPickFlow = modes.batch || modes.reset || modes.auto;
|
||||
|
||||
row.querySelectorAll('.bib-range.epr-line').forEach(function (line) {
|
||||
let wrap = line.querySelector('.batch-checkbox');
|
||||
let cb = line.querySelector('.batch-select-range');
|
||||
if (!wrap || !cb) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!inPickFlow || line.dataset.locked === '1') {
|
||||
wrap.classList.add('bib-ui-hidden');
|
||||
cb.checked = false;
|
||||
return;
|
||||
}
|
||||
|
||||
let used = parseInt((line.querySelector('.bib-used')?.textContent || '0'), 10) || 0;
|
||||
let dispo = parseInt((line.querySelector('.bib-dispo')?.textContent || '0'), 10) || 0;
|
||||
let show = modes.reset ? (used > 0) : (dispo > 0);
|
||||
|
||||
if (!show) {
|
||||
wrap.classList.add('bib-ui-hidden');
|
||||
cb.checked = false;
|
||||
return;
|
||||
}
|
||||
|
||||
wrap.classList.remove('bib-ui-hidden');
|
||||
|
||||
if (opts.precheckAuto && modes.auto && line.dataset.bibAuto === '1') {
|
||||
cb.checked = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function syncBibUiState(row) {
|
||||
if (!row) return;
|
||||
|
||||
@ -3820,6 +3830,10 @@
|
||||
bibSetVisible('.batch-config-container', inBatchFlow, row);
|
||||
bibSetVisible('.auto-config-container', inAutoFlow, row);
|
||||
|
||||
bibSyncModeRangeCheckboxes(row);
|
||||
|
||||
hasSelection = bibCountSelectedRanges(row) > 0;
|
||||
|
||||
let showPick = inPickFlow && !hasSelection;
|
||||
let showBatchReady = inBatchFlow && hasSelection;
|
||||
let showAutoReady = inAutoFlow && hasSelection;
|
||||
@ -3988,75 +4002,13 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if (row.dataset.loading === '1') return;
|
||||
// MSIN-4526 — Plus de refresh_ranges à chaque coche (CTE trous + rebuild HTML).
|
||||
let existing = document.querySelector('.epr-row-view');
|
||||
if (existing) existing.remove();
|
||||
row.dataset.loading = '1';
|
||||
|
||||
// 1. garder sélection
|
||||
let selected = [];
|
||||
row.querySelectorAll('.batch-select-range:checked').forEach(el => {
|
||||
selected.push(el.dataset.rangeId);
|
||||
});
|
||||
|
||||
// 2. analyse gauche/droite
|
||||
if (existing) {
|
||||
existing.remove();
|
||||
}
|
||||
updateBatchAnalysis(row);
|
||||
|
||||
// 3. sortir du cycle du change
|
||||
setTimeout(() => {
|
||||
|
||||
bibFetch('/ajax_bib_range.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body:
|
||||
'action=refresh_ranges'
|
||||
+ '&epr_id=' + encodeURIComponent(row.dataset.eprId)
|
||||
+ '&mode=' + encodeURIComponent(row.dataset.mode || 'assign')
|
||||
+ bibAjaxLangSuffix()
|
||||
}, { loader: false })
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
|
||||
if (!data.success) {
|
||||
row.dataset.loading = '0';
|
||||
return;
|
||||
}
|
||||
|
||||
setBibContainerFromAjax(row, data);
|
||||
let container = getBibContainer(row);
|
||||
if (!container) {
|
||||
row.dataset.loading = '0';
|
||||
return;
|
||||
}
|
||||
|
||||
// 4. refresh complet serveur
|
||||
// Re-sync après refresh serveur
|
||||
|
||||
container.classList.add('batch-mode');
|
||||
|
||||
// 5. remettre readonly
|
||||
container.querySelectorAll('.bib-start, .bib-qty, .bib-end').forEach(input => {
|
||||
input.setAttribute('readonly', true);
|
||||
});
|
||||
|
||||
// 6. restaurer checkbox
|
||||
container.querySelectorAll('.batch-select-range').forEach(el => {
|
||||
if (selected.includes(el.dataset.rangeId)) {
|
||||
el.checked = true;
|
||||
}
|
||||
});
|
||||
updateBatchAnalysis(row);
|
||||
|
||||
row.dataset.loading = '0';
|
||||
|
||||
})
|
||||
.catch(() => {
|
||||
row.dataset.loading = '0';
|
||||
});
|
||||
|
||||
}, 0);
|
||||
syncBibUiState(row);
|
||||
});
|
||||
|
||||
moduleBib.querySelectorAll('.epr-row').forEach(syncBibUiState);
|
||||
@ -4654,7 +4606,7 @@
|
||||
}
|
||||
|
||||
// =====================
|
||||
// ON
|
||||
// ON — MSIN-4526 : mode local, pas de refresh_ranges (CTE trous).
|
||||
// =====================
|
||||
row.classList.add('reset-mode');
|
||||
btnReset.textContent = row.dataset.resetCancelLabel || btnReset.textContent;
|
||||
@ -4665,40 +4617,16 @@
|
||||
input.setAttribute('readonly', true);
|
||||
});
|
||||
|
||||
syncBibUiState(row);
|
||||
row.querySelectorAll('.batch-select-range').forEach(function (cb) {
|
||||
cb.checked = false;
|
||||
});
|
||||
|
||||
let goBtn = row.querySelector('.btn-go-batch');
|
||||
if (goBtn) {
|
||||
goBtn.textContent = row.dataset.resetLabel || goBtn.textContent;
|
||||
}
|
||||
|
||||
bibFetch('/ajax_bib_range.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body:
|
||||
'action=refresh_ranges'
|
||||
+ '&epr_id=' + encodeURIComponent(row.dataset.eprId)
|
||||
+ '&mode=reset'
|
||||
+ bibAjaxLangSuffix()
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
|
||||
if (!data.success) return;
|
||||
|
||||
let container = setBibContainerFromAjax(row, data);
|
||||
if (!container) return;
|
||||
|
||||
container.classList.add('batch-mode');
|
||||
|
||||
row.querySelectorAll('.bib-start, .bib-qty, .bib-end').forEach(input => {
|
||||
input.setAttribute('readonly', true);
|
||||
});
|
||||
|
||||
syncBibUiState(row);
|
||||
});
|
||||
syncBibUiState(row);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -8173,7 +8173,8 @@ $tabSpec = fxBibRangeSpecValues($range);
|
||||
data-locked="<?php echo $blnRangeEditLocked ? '1' : '0'; ?>"
|
||||
data-user-locked="<?php echo $blnRangeLocked ? '1' : '0'; ?>"
|
||||
data-production-locked="<?php echo $blnProductionLocked ? '1' : '0'; ?>"
|
||||
data-has-values="<?php echo $tabSpec['has_values'] ? '1' : '0'; ?>">
|
||||
data-has-values="<?php echo $tabSpec['has_values'] ? '1' : '0'; ?>"
|
||||
data-bib-auto="<?php echo ((int)($range['epr_bib_auto'] ?? 0) === 1) ? '1' : '0'; ?>">
|
||||
|
||||
<?php echo fxBibRenderRangeLockButton($range, $epr_id, $blnProductionLocked); ?>
|
||||
<?php echo fxBibRenderProductionRangeLock($blnProductionLocked); ?>
|
||||
@ -8240,42 +8241,18 @@ $tabSpec = fxBibRangeSpecValues($range);
|
||||
<div class="batch-checkbox" style="text-align:center;">
|
||||
|
||||
<?php
|
||||
|
||||
$showCheckbox = false;
|
||||
|
||||
if (!$blnRangeLocked && (
|
||||
$mode === 'assign'
|
||||
&& $mem_dispo > 0
|
||||
&& (int)$range['epr_bib_id'] > 0
|
||||
)) {
|
||||
$showCheckbox = true;
|
||||
}
|
||||
|
||||
if (!$blnRangeLocked && (
|
||||
$mode === 'reset'
|
||||
&& (int)$range['nb_utilises'] > 0
|
||||
&& (int)$range['epr_bib_id'] > 0
|
||||
)) {
|
||||
$showCheckbox = true;
|
||||
}
|
||||
|
||||
// MSIN-4379 — Étape 2 : mode « auto » — séquences avec dossards disponibles seulement.
|
||||
if (!$blnRangeLocked && (
|
||||
$mode === 'auto'
|
||||
&& $mem_dispo > 0
|
||||
&& (int)$range['epr_bib_id'] > 0
|
||||
)) {
|
||||
$showCheckbox = true;
|
||||
}
|
||||
|
||||
// MSIN-4526 — Toujours émettre la case (si séquence sauvée non verrouillée).
|
||||
// Visibilité selon le mode = JS (bibSyncModeRangeCheckboxes) : plus de refresh_ranges
|
||||
// juste pour obtenir les checkboxes reset/auto.
|
||||
$blnShowCheckbox = !$blnRangeLocked && (int)$range['epr_bib_id'] > 0;
|
||||
$blnPrecheckAuto = ($mode === 'auto' && (int)($range['epr_bib_auto'] ?? 0) === 1);
|
||||
?>
|
||||
|
||||
<?php if ($showCheckbox) { ?>
|
||||
<?php if ($blnShowCheckbox) { ?>
|
||||
<input type="checkbox"
|
||||
class="batch-select-range"
|
||||
data-range-id="<?php echo (int)$range['epr_bib_id']; ?>"
|
||||
<?php /* MSIN-4379 — Étape 2 : pré-cocher les séquences déjà en epr_bib_auto = 1. */ ?>
|
||||
<?php if ($mode === 'auto' && (int)($range['epr_bib_auto'] ?? 0) === 1) { ?>checked<?php } ?>>
|
||||
<?php if ($blnPrecheckAuto) { ?>checked<?php } ?>>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
* Constantes *
|
||||
*
|
||||
**************/
|
||||
define('_VERSION_CODE', '4.72.912'); // MSIN-4379 — 1 équipe = 1 dossard : regroupement sur nom d'équipe
|
||||
define('_VERSION_CODE', '4.72.913'); // MSIN-4526 — entrée Réinit/Assign/Auto sans refresh_ranges lourd
|
||||
define('_DATE_CODE', '2026-07-30');
|
||||
//MSIN-4290
|
||||
define('QR_SECRET_KEY', 'ms1_qr_2026_cle_secrete_longue_et_fixe');
|
||||
|
||||
Reference in New Issue
Block a user