Поправил графики

This commit is contained in:
dipatrik10
2026-08-14 23:41:55 +03:00
parent 491e373cc3
commit d384a43aa2
22 changed files with 627 additions and 131 deletions

View File

@@ -1,5 +1,6 @@
import { api, getSession } from '../api.js';
import { escapeHtml, formatLocalDate, showAlert, hideAlert } from '../utils.js';
import { defaultSchedulePeriod } from '../schedule-period.js';
const ROLE_DEPARTMENT = 'DEPARTMENT';
@@ -72,6 +73,7 @@ export async function initDepartmentWorkspace() {
departmentField.hidden = true;
departmentSelect.value = userDepartmentId || '';
}
await selectDefaultWorkloadPeriod(startInput, endInput);
await loadAllTeachers();
renderImportRows([{ code: '', name: '' }]);
await loadWorkspace();
@@ -475,6 +477,20 @@ export async function initDepartmentWorkspace() {
}
}
async function selectDefaultWorkloadPeriod(startInput, endInput) {
try {
const semesters = await api.get('/api/schedule/semesters');
const period = defaultSchedulePeriod(
semesters,
formatLocalDate(new Date())
);
startInput.value = period.startDate;
endInput.value = period.endDate;
} catch (_error) {
// Текущий диапазон остаётся безопасным fallback, если справочник семестров недоступен.
}
}
async function loadDepartments(role, userDepartmentId) {
const departments = await api.get('/api/departments');
fillSelect('department-workspace-department', departments, item => item.id, item => item.departmentName, 'Выберите кафедру');