Много разных изменений
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { api } from '../api.js';
|
||||
import { escapeHtml, hideAlert, showAlert } from '../utils.js';
|
||||
import { AsyncCombobox } from '../async-combobox.js';
|
||||
|
||||
const EDIT_ROLES = new Set(['ADMIN', 'EDUCATION_OFFICE']);
|
||||
const ACTION_LABELS = {
|
||||
@@ -83,7 +84,30 @@ export function createScheduleOverridePanel({ role, dictionaries, getRange, onCh
|
||||
};
|
||||
|
||||
registryButton.hidden = false;
|
||||
fillReferenceSelects();
|
||||
const teacherCombobox = new AsyncCombobox(teacherSelect, {
|
||||
placeholder: 'Найдите преподавателя',
|
||||
optionLabel: teacher => teacher.fullName || teacher.username,
|
||||
optionDescription: teacher => [teacher.jobTitle, teacher.departmentName].filter(Boolean).join(' · '),
|
||||
load: async (query, selectedId) => {
|
||||
const params = new URLSearchParams({ query, limit: '30' });
|
||||
if (selectedId) params.set('selectedId', selectedId);
|
||||
const items = await api.get(`/api/users/teachers/options?${params}`);
|
||||
mergeDictionary('teachers', items);
|
||||
return items;
|
||||
}
|
||||
});
|
||||
const classroomCombobox = new AsyncCombobox(classroomSelect, {
|
||||
placeholder: 'Найдите аудиторию',
|
||||
optionLabel: classroomOptionLabel,
|
||||
optionDescription: room => [room.building, room.floor ? `${room.floor} этаж` : null, room.capacity ? `${room.capacity} мест` : null].filter(Boolean).join(' · '),
|
||||
load: async (query, selectedId) => {
|
||||
const params = new URLSearchParams({ query, limit: '30' });
|
||||
if (selectedId) params.set('selectedId', selectedId);
|
||||
const items = await api.get(`/api/classrooms/options?${params}`);
|
||||
mergeDictionary('classrooms', items);
|
||||
return items;
|
||||
}
|
||||
});
|
||||
bindEvents();
|
||||
renderRegistry();
|
||||
|
||||
@@ -226,15 +250,6 @@ export function createScheduleOverridePanel({ role, dictionaries, getRange, onCh
|
||||
};
|
||||
}
|
||||
|
||||
function fillReferenceSelects() {
|
||||
teacherSelect.innerHTML = (dictionaries.teachers || []).map(teacher =>
|
||||
`<option value="${escapeHtml(teacher.id)}">${escapeHtml(teacher.fullName || teacher.username || `Преподаватель ${teacher.id}`)}</option>`
|
||||
).join('');
|
||||
classroomSelect.innerHTML = (dictionaries.classrooms || []).map(classroom =>
|
||||
`<option value="${escapeHtml(classroom.id)}">${escapeHtml(classroomOptionLabel(classroom))}</option>`
|
||||
).join('');
|
||||
}
|
||||
|
||||
function setEditorValues(existing) {
|
||||
const effectiveTeacherId = existing?.newTeacherId || state.source.teacherId || '';
|
||||
const effectiveClassroomId = existing?.newClassroomId || state.source.classroomId || '';
|
||||
@@ -250,6 +265,8 @@ export function createScheduleOverridePanel({ role, dictionaries, getRange, onCh
|
||||
);
|
||||
teacherSelect.value = String(effectiveTeacherId);
|
||||
classroomSelect.value = String(effectiveClassroomId);
|
||||
teacherCombobox.syncFromSelect();
|
||||
classroomCombobox.syncFromSelect();
|
||||
formatSelect.value = existing?.newLessonFormat || state.source.lessonFormat || 'Очно';
|
||||
commentInput.value = existing?.comment || '';
|
||||
}
|
||||
@@ -515,6 +532,12 @@ export function createScheduleOverridePanel({ role, dictionaries, getRange, onCh
|
||||
const classroom = (dictionaries.classrooms || []).find(item => String(item.id) === String(id));
|
||||
return classroom ? classroomOptionLabel(classroom) : '';
|
||||
}
|
||||
|
||||
function mergeDictionary(key, items) {
|
||||
const current = new Map((dictionaries[key] || []).map(item => [String(item.id), item]));
|
||||
(items || []).forEach(item => current.set(String(item.id), item));
|
||||
dictionaries[key] = [...current.values()];
|
||||
}
|
||||
}
|
||||
|
||||
function renderSemesterCalendar(startDate, endDate, available, selectedDate) {
|
||||
|
||||
Reference in New Issue
Block a user