Доделал модалку на создание занятий. Добавил поля выбора аудитории, типа и формата занятий.
This commit is contained in:
@@ -14,6 +14,10 @@ export async function initUsers() {
|
|||||||
const addLessonForm = document.getElementById('add-lesson-form');
|
const addLessonForm = document.getElementById('add-lesson-form');
|
||||||
const lessonGroupSelect = document.getElementById('lesson-group');
|
const lessonGroupSelect = document.getElementById('lesson-group');
|
||||||
const lessonDisciplineSelect = document.getElementById('lesson-discipline');
|
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 lessonUserId = document.getElementById('lesson-user-id');
|
||||||
const lessonDaySelect = document.getElementById('lesson-day');
|
const lessonDaySelect = document.getElementById('lesson-day');
|
||||||
const weekUpper = document.getElementById('week-upper');
|
const weekUpper = document.getElementById('week-upper');
|
||||||
@@ -24,6 +28,7 @@ export async function initUsers() {
|
|||||||
// Переменные для хранения загруженных данных
|
// Переменные для хранения загруженных данных
|
||||||
let groups = [];
|
let groups = [];
|
||||||
let subjects = [];
|
let subjects = [];
|
||||||
|
let classrooms = [];
|
||||||
|
|
||||||
// NEW: массивы с временными слотами
|
// NEW: массивы с временными слотами
|
||||||
const weekdaysTimes = [
|
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 группами
|
// Заполнение select группами
|
||||||
function renderGroupOptions() {
|
function renderGroupOptions() {
|
||||||
lessonGroupSelect.innerHTML = '<option value="">Выберите группу</option>' +
|
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('');
|
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: функция обновления списка времени в зависимости от дня
|
// NEW: функция обновления списка времени в зависимости от дня
|
||||||
function updateTimeOptions(dayValue) {
|
function updateTimeOptions(dayValue) {
|
||||||
let times = [];
|
let times = [];
|
||||||
@@ -124,6 +143,8 @@ export async function initUsers() {
|
|||||||
if (weekUpper) weekUpper.checked = false;
|
if (weekUpper) weekUpper.checked = false;
|
||||||
if (weekLower) weekLower.checked = false;
|
if (weekLower) weekLower.checked = false;
|
||||||
// NEW: сбрасываем селект времени
|
// NEW: сбрасываем селект времени
|
||||||
|
if (lessonOfflineFormat) lessonOfflineFormat.checked = true;
|
||||||
|
if (lessonOnlineFormat) lessonOnlineFormat.checked = false;
|
||||||
lessonTimeSelect.innerHTML = '<option value="">Сначала выберите день</option>';
|
lessonTimeSelect.innerHTML = '<option value="">Сначала выберите день</option>';
|
||||||
lessonTimeSelect.disabled = true;
|
lessonTimeSelect.disabled = true;
|
||||||
hideAlert('add-lesson-alert');
|
hideAlert('add-lesson-alert');
|
||||||
@@ -146,9 +167,13 @@ export async function initUsers() {
|
|||||||
const userId = lessonUserId.value;
|
const userId = lessonUserId.value;
|
||||||
const groupId = lessonGroupSelect.value;
|
const groupId = lessonGroupSelect.value;
|
||||||
const subjectId = lessonDisciplineSelect.value;
|
const subjectId = lessonDisciplineSelect.value;
|
||||||
|
const classroomId = lessonClassroomSelect.value;
|
||||||
|
const lessonType = lessonTypeSelect.value;
|
||||||
const dayOfWeek = lessonDaySelect.value;
|
const dayOfWeek = lessonDaySelect.value;
|
||||||
const timeSlot = lessonTimeSelect.value; // NEW: получаем выбранное время
|
const timeSlot = lessonTimeSelect.value; // NEW: получаем выбранное время
|
||||||
|
|
||||||
|
const lessonFormat = document.querySelector('input[name="lessonFormat"]:checked')?.value;
|
||||||
|
|
||||||
// Проверка обязательных полей
|
// Проверка обязательных полей
|
||||||
if (!groupId) {
|
if (!groupId) {
|
||||||
showAlert('add-lesson-alert', 'Выберите группу', 'error');
|
showAlert('add-lesson-alert', 'Выберите группу', 'error');
|
||||||
@@ -158,6 +183,10 @@ export async function initUsers() {
|
|||||||
showAlert('add-lesson-alert', 'Выберите дисциплину', 'error');
|
showAlert('add-lesson-alert', 'Выберите дисциплину', 'error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!classroomId) {
|
||||||
|
showAlert('add-lesson-alert', 'Выберите аудиторию', 'error')
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!dayOfWeek) {
|
if (!dayOfWeek) {
|
||||||
showAlert('add-lesson-alert', 'Выберите день недели', 'error');
|
showAlert('add-lesson-alert', 'Выберите день недели', 'error');
|
||||||
return;
|
return;
|
||||||
@@ -186,6 +215,9 @@ export async function initUsers() {
|
|||||||
teacherId: parseInt(userId),
|
teacherId: parseInt(userId),
|
||||||
groupId: parseInt(groupId),
|
groupId: parseInt(groupId),
|
||||||
subjectId: parseInt(subjectId),
|
subjectId: parseInt(subjectId),
|
||||||
|
classroomId: parseInt(classroomId),
|
||||||
|
typeLesson: lessonType,
|
||||||
|
lessonFormat: lessonFormat,
|
||||||
day: dayOfWeek,
|
day: dayOfWeek,
|
||||||
week: weekType,
|
week: weekType,
|
||||||
time: timeSlot // передаём время
|
time: timeSlot // передаём время
|
||||||
@@ -265,5 +297,5 @@ export async function initUsers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Загружаем все данные при инициализации
|
// Загружаем все данные при инициализации
|
||||||
await Promise.all([loadUsers(), loadGroups(), loadSubjects()]);
|
await Promise.all([loadUsers(), loadGroups(), loadSubjects(), loadClassrooms()]);
|
||||||
}
|
}
|
||||||
@@ -68,6 +68,13 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</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-row" style="margin-top: 1rem;">
|
||||||
<div class="form-group" style="flex: 1;">
|
<div class="form-group" style="flex: 1;">
|
||||||
<label for="lesson-day">День недели</label>
|
<label for="lesson-day">День недели</label>
|
||||||
@@ -96,6 +103,31 @@
|
|||||||
</div>
|
</div>
|
||||||
</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;">
|
<div class="form-group" style="margin-top: 1rem;">
|
||||||
<label for="lesson-time">Время занятия</label>
|
<label for="lesson-time">Время занятия</label>
|
||||||
<select id="lesson-time" required disabled>
|
<select id="lesson-time" required disabled>
|
||||||
|
|||||||
Reference in New Issue
Block a user