From 8c326ef06a78dc3f8769afea25f7a7300c9ed131 Mon Sep 17 00:00:00 2001 From: kalugin66 Date: Tue, 14 Apr 2026 11:47:29 +0500 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BB=D0=B5=D0=BB=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/admin.html | 24 ++++++++++++------------ public/admin.js | 16 ++++++++-------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/public/admin.html b/public/admin.html index 914b444..aabc5a6 100644 --- a/public/admin.html +++ b/public/admin.html @@ -71,18 +71,18 @@ diff --git a/public/admin.js b/public/admin.js index 16507f6..a29107a 100644 --- a/public/admin.js +++ b/public/admin.js @@ -174,18 +174,19 @@ function openLessonModal(id = null) { document.getElementById('lessonId').value = ''; document.getElementById('modalTitle').innerText = id ? 'Редактирование урока' : 'Новый урок'; if (id) { - // Загружаем все уроки и находим нужный (можно было бы сделать отдельный запрос, но так проще) fetch(`/api/admin/lessons`).then(res => res.json()).then(lessons => { const lesson = lessons.find(l => l.id == id); if (lesson) { document.getElementById('lessonId').value = lesson.id; - document.getElementById('className').value = lesson.class_name; document.getElementById('parallel').value = lesson.parallel; + // Извлекаем букву из class_name (например, "10А" → "А") + const match = lesson.class_name.match(/[А-Яа-я]+$/); + const classLetter = match ? match[0] : ''; + document.getElementById('classLetter').value = classLetter; document.getElementById('subject').value = lesson.subject; document.getElementById('teacher').value = lesson.teacher; document.getElementById('topic').value = lesson.topic || ''; document.getElementById('maxSlots').value = lesson.max_slots; - // Заполняем дату и время, если они есть, иначе пустые строки document.getElementById('date').value = lesson.date || ''; document.getElementById('time').value = lesson.time || ''; } @@ -198,8 +199,9 @@ function openLessonModal(id = null) { document.getElementById('lessonForm')?.addEventListener('submit', async (e) => { e.preventDefault(); const id = document.getElementById('lessonId').value; - const class_name = document.getElementById('className').value.trim(); const parallel = parseInt(document.getElementById('parallel').value); + const classLetter = document.getElementById('classLetter').value.trim(); + const class_name = parallel + classLetter; // формируем полное имя класса const subject = document.getElementById('subject').value.trim(); const teacher = document.getElementById('teacher').value.trim(); const topic = document.getElementById('topic').value; @@ -207,9 +209,8 @@ document.getElementById('lessonForm')?.addEventListener('submit', async (e) => { const date = document.getElementById('date').value; const time = document.getElementById('time').value; - // Проверяем обязательные поля (дата и время теперь обязательны) - if (!class_name || isNaN(parallel) || !subject || !teacher || isNaN(max_slots) || !date || !time) { - alert('Пожалуйста, заполните все поля: класс, параллель, предмет, учитель, макс. мест, дата и время.'); + if (!class_name || isNaN(parallel) || !classLetter || !subject || !teacher || isNaN(max_slots) || !date || !time) { + alert('Пожалуйста, заполните все поля: параллель, букву класса, предмет, учителя, макс. мест, дату и время.'); return; } @@ -237,7 +238,6 @@ document.getElementById('lessonForm')?.addEventListener('submit', async (e) => { return; } document.getElementById('lessonModal').style.display = 'none'; - // Сбрасываем фильтры, чтобы обновлённый урок точно отобразился resetFilters(); loadLessons(getCurrentFilters()); } catch (err) {