From 174efa7f57696e6d9f4b85a6ecd8f2368c1dbd4f Mon Sep 17 00:00:00 2001 From: Ruslan Date: Mon, 20 Jul 2026 20:19:07 +0000 Subject: [PATCH] form: add Select All checkbox to products list in access request form --- app/templates/login.html | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/app/templates/login.html b/app/templates/login.html index 22cdbbe..8423876 100644 --- a/app/templates/login.html +++ b/app/templates/login.html @@ -139,7 +139,13 @@
- +
Загрузка...
@@ -186,6 +192,7 @@ } else { ['am-name','am-company','am-email','am-phone','am-manager'].forEach(function(id){ var el=document.getElementById(id); if(el){el.value='';el.classList.remove('am-invalid');} }); document.querySelectorAll('#am-products input[type=checkbox]').forEach(function(cb){ cb.checked=false; }); + var saBox = document.getElementById('am-select-all'); if (saBox) saBox.checked = false; var err=document.getElementById('am-error'); if(err) err.style.display='none'; var btn=document.getElementById('am-submit'); if(btn){btn.disabled=false;btn.textContent='Запросить доступ';} } @@ -225,6 +232,21 @@ wrap.appendChild(group); } productsLoaded = true; + // Show "select all" checkbox + const saWrap = document.getElementById('am-select-all-wrap'); + if (saWrap) saWrap.style.display = 'flex'; + const saBox = document.getElementById('am-select-all'); + if (saBox) { + saBox.addEventListener('change', function() { + document.querySelectorAll('#am-products input[type=checkbox]').forEach(function(cb){ cb.checked = saBox.checked; }); + }); + // Keep "select all" in sync when individual boxes change + wrap.addEventListener('change', function(e) { + if (e.target === saBox) return; + const all = [...document.querySelectorAll('#am-products input[type=checkbox]')]; + saBox.checked = all.length > 0 && all.every(function(cb){ return cb.checked; }); + }); + } } catch(e) { wrap.innerHTML = '
Не удалось загрузить список
'; }