создал систему календарного учебного графика
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { initMultiSelect } from '../utils.js';
|
||||
|
||||
export function initAuditoriumWorkload() {
|
||||
// Initialize date input with current date
|
||||
// Дата по умолчанию — текущий день.
|
||||
const dateInput = document.getElementById('workload-date');
|
||||
if (dateInput) {
|
||||
const today = new Date();
|
||||
@@ -11,20 +11,20 @@ export function initAuditoriumWorkload() {
|
||||
dateInput.value = `${yyyy}-${mm}-${dd}`;
|
||||
}
|
||||
|
||||
// Initialize Multi-Selects
|
||||
// Инициализация мультиселектов.
|
||||
initMultiSelect('building-box', 'building-menu', 'building-text', 'building-checkboxes');
|
||||
initMultiSelect('capacity-box', 'capacity-menu', 'capacity-text', 'capacity-checkboxes');
|
||||
initMultiSelect('equipment-box', 'equipment-menu', 'equipment-text', 'equipment-checkboxes');
|
||||
|
||||
// Populate Filters with Mock/Initial Data
|
||||
// Заполнение фильтров начальными данными.
|
||||
populateFilters();
|
||||
|
||||
// Render Mock Data for the Grid based on the UI requested layout
|
||||
// Отрисовка mock-данных в нужной ориентации сетки.
|
||||
renderMockGrid();
|
||||
}
|
||||
|
||||
function populateFilters() {
|
||||
// Buildings
|
||||
// Корпуса.
|
||||
const buildingsContainer = document.getElementById('building-checkboxes');
|
||||
const buildings = [
|
||||
{ id: 1, name: "Корпус 1 (Главный)" },
|
||||
@@ -39,7 +39,7 @@ function populateFilters() {
|
||||
</label>
|
||||
`).join('');
|
||||
|
||||
// Capacities
|
||||
// Вместимость.
|
||||
const capacityContainer = document.getElementById('capacity-checkboxes');
|
||||
const capacities = [
|
||||
{ id: 'small', name: "До 30 мест" },
|
||||
@@ -55,7 +55,7 @@ function populateFilters() {
|
||||
</label>
|
||||
`).join('');
|
||||
|
||||
// Equipment
|
||||
// Оборудование.
|
||||
const equipmentContainer = document.getElementById('equipment-checkboxes');
|
||||
const equipmentList = [
|
||||
{ id: 1, name: "Проектор" },
|
||||
@@ -73,7 +73,7 @@ function populateFilters() {
|
||||
}
|
||||
|
||||
function renderMockGrid() {
|
||||
// In future this will be loaded from API
|
||||
// В будущем данные будут загружаться из API.
|
||||
const timeslots = [
|
||||
"8:00-9:30",
|
||||
"9:40-11:10",
|
||||
@@ -89,7 +89,7 @@ function renderMockGrid() {
|
||||
"201", "202", "204", "205", "206", "207", "208"
|
||||
];
|
||||
|
||||
// Mock schedule data mapped by room and time
|
||||
// Mock-расписание по аудитории и времени.
|
||||
// Ключ: "roomId_timeSlotId", значение: объект занятия
|
||||
const mockSchedule = {
|
||||
"201_8:00-9:30": { subject: "Физика", group: "ИБ-41м", teacher: "Атлетов А.Р." },
|
||||
@@ -105,37 +105,43 @@ function renderMockGrid() {
|
||||
"205_9:40-11:10": { subject: "Организация аудита ИБ", group: "ИБ-41м", teacher: "Таныгин М.О." },
|
||||
};
|
||||
|
||||
// Render Headers
|
||||
// В столбцах отображаются временные слоты, в строках — аудитории.
|
||||
const headerRow = document.getElementById('workload-header-row');
|
||||
// Start after the first fixed cell (which is already in HTML)
|
||||
headerRow.innerHTML = `
|
||||
<th class="top-left-cell">
|
||||
<span class="top-label">Время</span>
|
||||
<span class="bottom-label">Аудитория</span>
|
||||
</th>
|
||||
`;
|
||||
|
||||
auditoriums.forEach(room => {
|
||||
timeslots.forEach(time => {
|
||||
const th = document.createElement('th');
|
||||
th.textContent = room;
|
||||
th.textContent = time;
|
||||
headerRow.appendChild(th);
|
||||
});
|
||||
|
||||
// Render Body Rows
|
||||
// Строки таблицы.
|
||||
const tbody = document.getElementById('workload-tbody');
|
||||
tbody.innerHTML = '';
|
||||
|
||||
timeslots.forEach((time) => {
|
||||
auditoriums.forEach((room) => {
|
||||
const tr = document.createElement('tr');
|
||||
|
||||
// Add Time Cell
|
||||
const tdTime = document.createElement('td');
|
||||
tdTime.className = 'time-cell';
|
||||
tdTime.textContent = time;
|
||||
tr.appendChild(tdTime);
|
||||
// Ячейка аудитории.
|
||||
const tdRoom = document.createElement('td');
|
||||
tdRoom.className = 'axis-cell';
|
||||
tdRoom.textContent = room;
|
||||
tr.appendChild(tdRoom);
|
||||
|
||||
// Add Room Cells for this Time
|
||||
auditoriums.forEach(room => {
|
||||
// Ячейки временных слотов для аудитории.
|
||||
timeslots.forEach(time => {
|
||||
const td = document.createElement('td');
|
||||
|
||||
const scheduleKey = `${room}_${time}`;
|
||||
const lesson = mockSchedule[scheduleKey];
|
||||
|
||||
if (lesson) {
|
||||
// Render lesson card
|
||||
// Карточка занятия.
|
||||
td.innerHTML = `
|
||||
<div class="lesson-card">
|
||||
<div class="lesson-subject">${lesson.subject}</div>
|
||||
|
||||
Reference in New Issue
Block a user