diff --git a/frontend/admin/js/views/users.js b/frontend/admin/js/views/users.js index b680515..921991b 100755 --- a/frontend/admin/js/views/users.js +++ b/frontend/admin/js/views/users.js @@ -14,6 +14,10 @@ export async function initUsers() { const addLessonForm = document.getElementById('add-lesson-form'); const lessonGroupSelect = document.getElementById('lesson-group'); const lessonDisciplineSelect = document.getElementById('lesson-discipline'); + const lessonClassroomSelect = document.getElementById('lesson-classroom'); + const lessonTypeSelect = document.getElementById('lesson-type'); + const lessonOnlineFormat = document.getElementById('format-online'); + const lessonOfflineFormat = document.getElementById('format-offline'); const lessonUserId = document.getElementById('lesson-user-id'); const lessonDaySelect = document.getElementById('lesson-day'); const weekUpper = document.getElementById('week-upper'); @@ -24,6 +28,7 @@ export async function initUsers() { // Переменные для хранения загруженных данных let groups = []; let subjects = []; + let classrooms = []; // NEW: массивы с временными слотами const weekdaysTimes = [ @@ -63,6 +68,15 @@ export async function initUsers() { } } + async function loadClassrooms() { + try { + classrooms = await api.get('/api/classrooms'); + renderClassroomsOptions(); + } catch (e) { + console.error('Ошибка загрузки аудиторий:', e); + } + } + // Заполнение select группами function renderGroupOptions() { lessonGroupSelect.innerHTML = '' + @@ -75,6 +89,11 @@ export async function initUsers() { subjects.map(s => ``).join(''); } + function renderClassroomsOptions() { + lessonClassroomSelect.innerHTML = '' + + classrooms.map(c => ``).join(''); + } + // NEW: функция обновления списка времени в зависимости от дня function updateTimeOptions(dayValue) { let times = []; @@ -124,6 +143,8 @@ export async function initUsers() { if (weekUpper) weekUpper.checked = false; if (weekLower) weekLower.checked = false; // NEW: сбрасываем селект времени + if (lessonOfflineFormat) lessonOfflineFormat.checked = true; + if (lessonOnlineFormat) lessonOnlineFormat.checked = false; lessonTimeSelect.innerHTML = ''; lessonTimeSelect.disabled = true; hideAlert('add-lesson-alert'); @@ -146,9 +167,13 @@ export async function initUsers() { const userId = lessonUserId.value; const groupId = lessonGroupSelect.value; const subjectId = lessonDisciplineSelect.value; + const classroomId = lessonClassroomSelect.value; + const lessonType = lessonTypeSelect.value; const dayOfWeek = lessonDaySelect.value; const timeSlot = lessonTimeSelect.value; // NEW: получаем выбранное время + const lessonFormat = document.querySelector('input[name="lessonFormat"]:checked')?.value; + // Проверка обязательных полей if (!groupId) { showAlert('add-lesson-alert', 'Выберите группу', 'error'); @@ -158,6 +183,10 @@ export async function initUsers() { showAlert('add-lesson-alert', 'Выберите дисциплину', 'error'); return; } + if (!classroomId) { + showAlert('add-lesson-alert', 'Выберите аудиторию', 'error') + return; + } if (!dayOfWeek) { showAlert('add-lesson-alert', 'Выберите день недели', 'error'); return; @@ -186,6 +215,9 @@ export async function initUsers() { teacherId: parseInt(userId), groupId: parseInt(groupId), subjectId: parseInt(subjectId), + classroomId: parseInt(classroomId), + typeLesson: lessonType, + lessonFormat: lessonFormat, day: dayOfWeek, week: weekType, time: timeSlot // передаём время @@ -265,5 +297,5 @@ export async function initUsers() { } // Загружаем все данные при инициализации - await Promise.all([loadUsers(), loadGroups(), loadSubjects()]); + await Promise.all([loadUsers(), loadGroups(), loadSubjects(), loadClassrooms()]); } \ No newline at end of file diff --git a/frontend/admin/views/users.html b/frontend/admin/views/users.html index 1303153..455f079 100755 --- a/frontend/admin/views/users.html +++ b/frontend/admin/views/users.html @@ -68,6 +68,13 @@ +
+ + +
+
@@ -96,6 +103,31 @@
+
+
+ + +
+
+ +
+ + +
+
+
+