Merge pull request 'Доделал модалку на создание занятий. Добавил поля выбора аудитории, типа и формата занятий.' (#6) from Create-Lesson into main
All checks were successful
Build and Push Docker Images / build-and-push-backend (push) Successful in 12s
Build and Push Docker Images / build-and-push-frontend (push) Successful in 11s
Build and Push Docker Images / deploy-to-k8s (push) Successful in 1m13s

Reviewed-on: #6
This commit was merged in pull request #6.
This commit is contained in:
2026-03-11 09:45:46 +00:00
2 changed files with 65 additions and 1 deletions

View File

@@ -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 = '<option value="">Выберите группу</option>' +
@@ -75,6 +89,11 @@ export async function initUsers() {
subjects.map(s => `<option value="${s.id}">${escapeHtml(s.name)}</option>`).join('');
}
function renderClassroomsOptions() {
lessonClassroomSelect.innerHTML = '<option value="">Выберите аудиторию</option>' +
classrooms.map(c => `<option value="${c.id}">${escapeHtml(c.name)}</option>`).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 = '<option value="">Сначала выберите день</option>';
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()]);
}

View File

@@ -68,6 +68,13 @@
</select>
</div>
<div class="form-group" style="margin-top: 1rem;">
<label for="lesson-classroom">Аудитория</label>
<select id="lesson-classroom" required>
<option value="">Выберите аудиторию</option>
</select>
</div>
<div class="form-row" style="margin-top: 1rem;">
<div class="form-group" style="flex: 1;">
<label for="lesson-day">День недели</label>
@@ -96,6 +103,31 @@
</div>
</div>
<div class="form-row" style="margin-top: 1rem;">
<div class="form-group" style="flex: 1;">
<label for="lesson-type">Тип занятия</label>
<select id="lesson-type" required>
<option value="">Выберите тип занятия</option>
<option value="Практическая работа">Практическая работа</option>
<option value="Лекция">Лекция</option>
<option value="Лабораторная работа">Лабораторная работа</option>
</select>
</div>
<div class="form-group" style="flex: 1;">
<label>Формат занятия</label>
<div style="display: flex; gap: 0.5rem;">
<label class="btn-checkbox">
<input type="radio" name="lessonFormat" value="Очно" id="format-offline" checked>
<span class="checkbox-btn">Очно</span>
</label>
<label class="btn-checkbox">
<input type="radio" name="lessonFormat" value="Онлайн" id="format-online">
<span class="checkbox-btn">Онлайн</span>
</label>
</div>
</div>
</div>
<div class="form-group" style="margin-top: 1rem;">
<label for="lesson-time">Время занятия</label>
<select id="lesson-time" required disabled>