feat: дисциплины кафедры из календарных графиков
Дисциплины, прикреплённые к календарным графикам, автоматически отображаются на странице кафедры — ручное ведение списка больше не требуется (форма импорта сохранена). - Backend: GET /api/department/subjects/calendar — дисциплины кафедры с прикреплениями к графикам (дисциплина попадает на страницу своей кафедры по subjects.department_id) - Frontend: кабинет кафедры — колонка «Календарный график» с семестрами, фильтр «Все / В календарных графиках / Без графика» - Тесты: backend (группировка, сортировка, пустая кафедра), frontend (контракт, фильтр, группировка семестров) — 239/239 - Документация: API.md, BUSINESS_LOGIC.md
This commit is contained in:
1 parent
97bf3cc50a
commit
91f44c85b4
11 files changed
+414
-31
No files matched your search
@@ -5,26 +5,31 @@ import { addDays, toIsoDate } from '../../shared/dates.js';
|
||||
import { requestCountLabel } from '../admin-service.js';
|
||||
import {
|
||||
DEPARTMENT_REQUEST_TABLE_COLUMNS,
|
||||
SUBJECT_CALENDAR_FILTER_ALL,
|
||||
SUBJECT_CALENDAR_FILTER_OPTIONS,
|
||||
SUBJECT_TABLE_COLUMNS,
|
||||
assignTeacher,
|
||||
assignTeacherError,
|
||||
attachmentGroupLabel,
|
||||
availableTeachers,
|
||||
defaultWorkloadPeriod,
|
||||
departmentOptionLabel,
|
||||
fetchAllTeachers,
|
||||
fetchDepartmentSubjects,
|
||||
fetchDepartmentSubjectCalendar,
|
||||
fetchDepartmentTeacherRequests,
|
||||
fetchDepartmentTeachers,
|
||||
fetchDepartments,
|
||||
fetchSemesters,
|
||||
fetchSubjectComments,
|
||||
fetchTeacherWorkload,
|
||||
filterDepartmentSubjects,
|
||||
formatDateTime,
|
||||
importSubjects,
|
||||
importSubjectsPayload,
|
||||
requestStatusClass,
|
||||
requestStatusLabel,
|
||||
saveSubjectComment,
|
||||
subjectAttachmentGroups,
|
||||
subjectCountLabel,
|
||||
submitTeacherRequest,
|
||||
teacherMetrics,
|
||||
@@ -52,6 +57,7 @@ export function DepartmentWorkspaceTab() {
|
||||
const [workspaceAlert, setWorkspaceAlert] = useState({ text: '', isError: false });
|
||||
|
||||
const [subjects, setSubjects] = useState({ loading: true, items: [], error: '' });
|
||||
const [subjectFilter, setSubjectFilter] = useState(SUBJECT_CALENDAR_FILTER_ALL);
|
||||
const [teachers, setTeachers] = useState({ items: null, error: '' });
|
||||
const [workload, setWorkload] = useState({ items: null, error: '' });
|
||||
const [requests, setRequests] = useState({ items: null, error: '' });
|
||||
@@ -133,7 +139,7 @@ export function DepartmentWorkspaceTab() {
|
||||
async function loadSubjects() {
|
||||
setSubjects({ loading: true, items: [], error: '' });
|
||||
try {
|
||||
const items = await fetchDepartmentSubjects(currentDepartmentId());
|
||||
const items = await fetchDepartmentSubjectCalendar(currentDepartmentId());
|
||||
setSubjects({ loading: false, items: Array.isArray(items) ? items : [], error: '' });
|
||||
} catch (error) {
|
||||
setSubjects({ loading: false, items: [], error: error.message || 'Ошибка загрузки дисциплин' });
|
||||
@@ -333,9 +339,10 @@ export function DepartmentWorkspaceTab() {
|
||||
const requestsCountLabel = requests.error
|
||||
? '0 заявок'
|
||||
: (requests.items === null ? 'Загрузка...' : requestCountLabel(requests.items.length));
|
||||
const visibleSubjects = subjects.error || subjects.loading ? [] : filterDepartmentSubjects(subjects.items, subjectFilter);
|
||||
const subjectsCountLabel = subjects.error
|
||||
? '0 дисциплин'
|
||||
: (subjects.loading ? 'Загрузка...' : subjectCountLabel(subjects.items.length));
|
||||
: (subjects.loading ? 'Загрузка...' : subjectCountLabel(visibleSubjects.length));
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -665,6 +672,20 @@ export function DepartmentWorkspaceTab() {
|
||||
<div className="card-header-row">
|
||||
<h2>Дисциплины кафедры</h2>
|
||||
<span className="muted" id="department-subject-count">{subjectsCountLabel}</span>
|
||||
<div className="form-group form-group--flush" id="department-subject-filter-field">
|
||||
<label className="schedule-section-label schedule-section-label--flush" htmlFor="department-subject-filter">
|
||||
Показывать
|
||||
</label>
|
||||
<select
|
||||
id="department-subject-filter"
|
||||
value={subjectFilter}
|
||||
onChange={event => setSubjectFilter(event.target.value)}
|
||||
>
|
||||
{SUBJECT_CALENDAR_FILTER_OPTIONS.map(option => (
|
||||
<option key={option.value} value={option.value}>{option.label}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div className="table-wrap">
|
||||
<table>
|
||||
@@ -672,7 +693,7 @@ export function DepartmentWorkspaceTab() {
|
||||
<tr>
|
||||
<th>Код</th>
|
||||
<th>Название</th>
|
||||
<th>Описание</th>
|
||||
<th>Календарный график</th>
|
||||
<th>Комментарии</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -689,28 +710,43 @@ export function DepartmentWorkspaceTab() {
|
||||
{subjects.error}
|
||||
</td>
|
||||
</tr>
|
||||
) : subjects.items.length === 0 ? (
|
||||
) : visibleSubjects.length === 0 ? (
|
||||
<tr>
|
||||
<td colSpan={SUBJECT_TABLE_COLUMNS} className="loading-row">
|
||||
Дисциплины не найдены
|
||||
</td>
|
||||
</tr>
|
||||
) : subjects.items.map(subject => (
|
||||
<tr key={subject.id}>
|
||||
<td>{subject.code || '-'}</td>
|
||||
<td>{subject.name || '-'}</td>
|
||||
<td>{subject.description || '-'}</td>
|
||||
<td>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-sm btn-secondary department-comments-open"
|
||||
onClick={() => void openComments(subject.id, subject.name || '')}
|
||||
>
|
||||
Открыть
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
) : visibleSubjects.map(subject => {
|
||||
const attachmentGroups = subjectAttachmentGroups(subject.attachments);
|
||||
return (
|
||||
<tr key={subject.id}>
|
||||
<td>{subject.code || '-'}</td>
|
||||
<td>{subject.name || '-'}</td>
|
||||
<td>
|
||||
{attachmentGroups.length ? (
|
||||
<div className="assignment-subjects">
|
||||
{attachmentGroups.map(group => (
|
||||
<div className="assignment-subject-semester" key={group.calendarId}>
|
||||
<span>{attachmentGroupLabel(group)}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<span className="text-muted">Не прикреплена к графику</span>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-sm btn-secondary department-comments-open"
|
||||
onClick={() => void openComments(subject.id, subject.name || '')}
|
||||
>
|
||||
Открыть
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user