From 159360aeb0e69e0664e466c8b542fcc64e5feec4 Mon Sep 17 00:00:00 2001 From: tore Date: Mon, 14 Sep 2026 20:42:59 +0000 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5:=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA?= =?UTF-8?q?=D0=B8=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D1=8E=D1=82=20?= =?UTF-8?q?=E2=80=94=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=87?= =?UTF-8?q?=D0=B8=D0=BA=D0=B8=20=D0=BF=D0=B5=D1=80=D0=B5=D1=81=D0=BE=D0=B7?= =?UTF-8?q?=D0=B4=D0=B0=D1=8E=D1=82=D1=81=D1=8F=20=D0=B2=20updateSelection?= =?UTF-8?q?Panel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 89 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 52 insertions(+), 37 deletions(-) diff --git a/index.html b/index.html index 6c89cf6..7ba5d85 100644 --- a/index.html +++ b/index.html @@ -457,6 +457,56 @@ function updateSelectionPanel() { panel.style.display = 'block'; document.getElementById('selected-count').textContent = count; + + // Пересоздаём обработчики кнопок каждый раз + const btnConfirm = document.getElementById('btn-confirm'); + const btnReject = document.getElementById('btn-reject'); + + // Клонируем кнопки, чтобы сбросить старые обработчики + const newConfirm = btnConfirm.cloneNode(true); + const newReject = btnReject.cloneNode(true); + + btnConfirm.parentNode.replaceChild(newConfirm, btnConfirm); + btnReject.parentNode.replaceChild(newReject, btnReject); + + // Вешаем новые обработчики + newConfirm.addEventListener('click', function() { + if (appState.selectedItems.size === 0) return; + const comment = document.getElementById('group-comment').value || 'Подтверждено пользователем'; + const processedGroups = new Set(); + appState.selectedItems.forEach(key => { + const [groupId, itemIndex] = key.split('-'); + const group = appState.groups.find(g => g.id === groupId); + if (group && group.status === 'new') { + group.status = 'confirmed'; + group.comment = comment; + processedGroups.add(groupId); + } + }); + appState.selectedItems.clear(); + saveState(); + renderGroups(); + document.getElementById('group-comment').value = ''; + }); + + newReject.addEventListener('click', function() { + if (appState.selectedItems.size === 0) return; + const comment = document.getElementById('group-comment').value || 'Отклонено пользователем'; + const processedGroups = new Set(); + appState.selectedItems.forEach(key => { + const [groupId, itemIndex] = key.split('-'); + const group = appState.groups.find(g => g.id === groupId); + if (group && group.status === 'new') { + group.status = 'rejected'; + group.comment = comment; + processedGroups.add(groupId); + } + }); + appState.selectedItems.clear(); + saveState(); + renderGroups(); + document.getElementById('group-comment').value = ''; + }); } // Обработка группы @@ -522,43 +572,8 @@ document.addEventListener('DOMContentLoaded', function() { } }); - document.getElementById('btn-confirm').addEventListener('click', function() { - if (appState.selectedItems.size === 0) return; - const comment = document.getElementById('group-comment').value || 'Подтверждено пользователем'; - const processedGroups = new Set(); - appState.selectedItems.forEach(key => { - const [groupId, itemIndex] = key.split('-'); - const group = appState.groups.find(g => g.id === groupId); - if (group && group.status === 'new') { - group.status = 'confirmed'; - group.comment = comment; - processedGroups.add(groupId); - } - }); - appState.selectedItems.clear(); - saveState(); - renderGroups(); - document.getElementById('group-comment').value = ''; - }); - - document.getElementById('btn-reject').addEventListener('click', function() { - if (appState.selectedItems.size === 0) return; - const comment = document.getElementById('group-comment').value || 'Отклонено пользователем'; - const processedGroups = new Set(); - appState.selectedItems.forEach(key => { - const [groupId, itemIndex] = key.split('-'); - const group = appState.groups.find(g => g.id === groupId); - if (group && group.status === 'new') { - group.status = 'rejected'; - group.comment = comment; - processedGroups.add(groupId); - } - }); - appState.selectedItems.clear(); - saveState(); - renderGroups(); - document.getElementById('group-comment').value = ''; - }); + // Первичная инициализация обработчиков кнопок + updateSelectionPanel(); });