From 935c12aaa251c0f8e40f095103ea389ce86fe6da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C=20=D0=9D=D0=B0=D0=B4=D0=B5?= =?UTF-8?q?=D0=B8=D0=BD?= Date: Mon, 29 Dec 2025 11:19:50 +0300 Subject: [PATCH] =?UTF-8?q?fix(requests):=20=D1=83=D0=B1=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=D1=8B=20alert=20=D0=B8=20=D0=BD=D0=B5=D0=BC=D0=B5=D0=B4=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BD=D1=8B=D0=B9=20reload=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?approve/reject=20=D0=BD=D0=B0=20=D1=81=D1=82=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=86=D0=B5=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - requestCrudHandler.js: заменены alert+reload на закрытие модального окна + событие - requestList.js: добавлен обработчик события request:updated с отложенной перезагрузкой (500ms) - Улучшен UX: модальное окно плавно закрывается, затем обновляется список - Системное уведомление больше не появляется --- .../js/components/requestCrudHandler.js | 30 ++++++++++++++++--- backend/static/js/pages/requestList.js | 8 +++++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/backend/static/js/components/requestCrudHandler.js b/backend/static/js/components/requestCrudHandler.js index 6359cfce..8e2f8329 100644 --- a/backend/static/js/components/requestCrudHandler.js +++ b/backend/static/js/components/requestCrudHandler.js @@ -320,8 +320,19 @@ export function initRequestCrudHandler(options) { } await response.json(); - alert("Заявление одобрено."); - window.location.reload(); + + // Закрываем модальное окно + const modal = document.getElementById('reqApproveModal'); + if (modal) { + const bsModal = bootstrap.Modal.getInstance(modal); + if (bsModal) bsModal.hide(); + } + + // Отправляем событие для обновления списка + document.dispatchEvent(new CustomEvent('request:updated', { + detail: { action: 'approve', id: reqId } + })); + } catch (error) { alert("Не удалось одобрить заявление: " + error.message); } @@ -351,8 +362,19 @@ export function initRequestCrudHandler(options) { } await response.json(); - alert("Заявление отклонено."); - window.location.reload(); + + // Закрываем модальное окно + const modal = document.getElementById('reqRejectModal'); + if (modal) { + const bsModal = bootstrap.Modal.getInstance(modal); + if (bsModal) bsModal.hide(); + } + + // Отправляем событие для обновления списка + document.dispatchEvent(new CustomEvent('request:updated', { + detail: { action: 'reject', id: reqId } + })); + } catch (error) { alert("Не удалось отклонить заявление: " + error.message); } diff --git a/backend/static/js/pages/requestList.js b/backend/static/js/pages/requestList.js index 4f82b77f..4c0582d9 100644 --- a/backend/static/js/pages/requestList.js +++ b/backend/static/js/pages/requestList.js @@ -112,4 +112,12 @@ export function initRequestListPage(config) { apiDetailBase, headers }); + + // Слушаем события обновления заявлений (approve/reject) + document.addEventListener('request:updated', function(event) { + console.log('Request updated:', event.detail); + // Перезагружаем страницу для обновления списка + // TODO: в будущем можно заменить на AJAX обновление конкретной карточки + setTimeout(() => window.location.reload(), 500); + }); }