diff --git a/app/templates/patching_import.html b/app/templates/patching_import.html index 95a46df..8d8780a 100644 --- a/app/templates/patching_import.html +++ b/app/templates/patching_import.html @@ -124,17 +124,17 @@ 0 sélectionné(s)
{% if can_import %} - - - {% endif %} - @@ -239,12 +239,18 @@ const allVisibleChecked = visibleCb.length > 0 && Array.from(visibleCb).every(cb => cb.checked); selAll.checked = allVisibleChecked; selAllHead.checked = allVisibleChecked; + // Boutons toujours cliquables : si rien de sélectionné on alerte au clic + // (au lieu de griser un bouton qu'on ne peut pas atteindre). + // Atténuation visuelle quand pas de sélection pour donner un feedback : const hasSel = checked > 0; - if (btnAddElig) btnAddElig.disabled = !hasSel; - if (btnReport) btnReport.disabled = !hasSel; - if (btnUnset) btnUnset.disabled = !hasSel; - // Pré-patching : actif uniquement si au moins 1 row éligible sélectionnée - btnPre.disabled = eligibleSelected === 0; + const dimIfEmpty = (btn, active) => { + if (!btn) return; + btn.classList.toggle('opacity-50', !active); + }; + dimIfEmpty(btnAddElig, hasSel); + dimIfEmpty(btnReport, hasSel); + dimIfEmpty(btnUnset, hasSel); + dimIfEmpty(btnPre, eligibleSelected > 0); } function getSelectedRowIds(){ @@ -410,13 +416,13 @@ if (btnAddElig) btnAddElig.addEventListener('click', async () => { const ids = getSelectedRowIds(); - if (!ids.length) return; + if (!ids.length) { alert('Veuillez sélectionner au moins un serveur.'); return; } if (!confirm('Marquer ' + ids.length + ' ligne(s) comme éligibles au patching ?')) return; if (await postAction({row_ids: ids, action: 'eligible'})) await reloadCurrentSheet(); }); if (btnReport) btnReport.addEventListener('click', async () => { const ids = getSelectedRowIds(); - if (!ids.length) return; + if (!ids.length) { alert('Veuillez sélectionner au moins un serveur.'); return; } const target = (prompt('Reporter vers quelle semaine ? (ex: S23)') || '').trim(); if (!target) return; if (!/^S\d{1,2}$/i.test(target)) { alert('Format attendu : Sxx (ex S23)'); return; } @@ -425,7 +431,7 @@ }); if (btnUnset) btnUnset.addEventListener('click', async () => { const ids = getSelectedRowIds(); - if (!ids.length) return; + if (!ids.length) { alert('Veuillez sélectionner au moins un serveur.'); return; } if (!confirm('Annuler éligibilité ET report sur ' + ids.length + ' ligne(s) ?')) return; if (await postAction({row_ids: ids, action: 'unset_eligible'})) { await postAction({row_ids: ids, action: 'unset_report'}); @@ -433,11 +439,15 @@ } }); btnPre.addEventListener('click', () => { - const ids = Array.from(tbody.querySelectorAll('input.row-cb:checked')) + const checkedAny = Array.from(tbody.querySelectorAll('input.row-cb:checked')); + if (!checkedAny.length) { alert('Veuillez sélectionner au moins un serveur.'); return; } + const ids = checkedAny .filter(cb => cb.dataset.eligible === '1') .map(cb => cb.dataset.id); - if (!ids.length) { alert('Aucune ligne éligible sélectionnée.'); return; } - // Étape B : workflow iexec à brancher + if (!ids.length) { + alert('Aucun serveur sélectionné n\'est éligible. Marque-les d\'abord avec "+ Ajouter au patching".'); + return; + } window.location.href = '/patching/iexec?row_ids=' + ids.join(','); }); })();