feat: колонки шифр/профиль/вид нагрузки + комментарии под строкой

- Таблица дисциплин кафедры: новые колонки «Шифр» (специальность графика),
  «Профиль» (профиль обучения графика), «Вид нагрузки» (уникальные типы
  занятий дисциплины из teacher_lesson_types)
- Комментарии открываются строкой таблицы под выбранной дисциплиной,
  а не отдельной карточкой внизу страницы
- Селект графиков получил стили дизайн-системы (фон, границы, шрифт) —
  раньше был нечитаемым
- Тесты: backend 5/5, frontend 240/240; проверено в браузере
This commit is contained in:
dipatrik10 committed 2026-10-04 20:00:25 +03:00
1 parent efacac1c59
commit 37665f1aae
13 files changed
+242 -38

No files matched your search

@@ -15,6 +15,7 @@ import com.magistr.app.repository.SubjectCommentRepository;
import com.magistr.app.repository.SubjectRepository;
import com.magistr.app.repository.TeacherCreationRequestRepository;
import com.magistr.app.repository.TeacherDepartmentAssignmentRepository;
import com.magistr.app.repository.TeacherSubjectRepository;
import com.magistr.app.repository.UserRepository;
import com.magistr.app.service.ScheduleQueryService;
import com.magistr.app.service.SubjectImportService;
@@ -27,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -47,6 +49,7 @@ public class DepartmentWorkspaceController {
private final TeacherDepartmentAssignmentRepository teacherDepartmentAssignmentRepository;
private final TeacherCreationRequestRepository teacherCreationRequestRepository;
private final AcademicCalendarSubjectRepository calendarSubjectRepository;
private final TeacherSubjectRepository teacherSubjectRepository;
private final ScheduleQueryService scheduleQueryService;
private final TeacherDepartmentService teacherDepartmentService;
private final SubjectImportService subjectImportService;
@@ -59,13 +62,14 @@ public class DepartmentWorkspaceController {
TeacherDepartmentAssignmentRepository teacherDepartmentAssignmentRepository,
TeacherCreationRequestRepository teacherCreationRequestRepository,
AcademicCalendarSubjectRepository calendarSubjectRepository,
TeacherSubjectRepository teacherSubjectRepository,
ScheduleQueryService scheduleQueryService,
TeacherDepartmentService teacherDepartmentService,
SubjectImportService subjectImportService) {
this(subjectRepository, subjectCommentRepository, userRepository, departmentRepository,
teacherDepartmentAssignmentRepository, teacherCreationRequestRepository,
calendarSubjectRepository, scheduleQueryService, teacherDepartmentService,
subjectImportService,
calendarSubjectRepository, teacherSubjectRepository, scheduleQueryService,
teacherDepartmentService, subjectImportService,
BusinessTimeService.systemDefault());
}
@@ -77,6 +81,7 @@ public class DepartmentWorkspaceController {
TeacherDepartmentAssignmentRepository teacherDepartmentAssignmentRepository,
TeacherCreationRequestRepository teacherCreationRequestRepository,
AcademicCalendarSubjectRepository calendarSubjectRepository,
TeacherSubjectRepository teacherSubjectRepository,
ScheduleQueryService scheduleQueryService,
TeacherDepartmentService teacherDepartmentService,
SubjectImportService subjectImportService,
@@ -88,6 +93,7 @@ public class DepartmentWorkspaceController {
this.teacherDepartmentAssignmentRepository = teacherDepartmentAssignmentRepository;
this.teacherCreationRequestRepository = teacherCreationRequestRepository;
this.calendarSubjectRepository = calendarSubjectRepository;
this.teacherSubjectRepository = teacherSubjectRepository;
this.scheduleQueryService = scheduleQueryService;
this.teacherDepartmentService = teacherDepartmentService;
this.subjectImportService = subjectImportService;
@@ -151,19 +157,44 @@ public class DepartmentWorkspaceController {
Collectors.mapping(this::toCalendarAttachmentDto, Collectors.toList())
));
Map<Long, List<String>> lessonTypesBySubject = lessonTypesBySubjectId(
subjects.stream().map(Subject::getId).toList());
return subjects.stream()
.map(subject -> toDepartmentCalendarSubjectDto(subject, attachmentsBySubject))
.map(subject -> toDepartmentCalendarSubjectDto(subject, attachmentsBySubject, lessonTypesBySubject))
.toList();
}
/**
* Виды нагрузки дисциплин: уникальные типы занятий из привязок
* преподавателей (teacher_lesson_types), без повторов от разных педагогов.
*/
private Map<Long, List<String>> lessonTypesBySubjectId(List<Long> subjectIds) {
if (subjectIds.isEmpty()) {
return Map.of();
}
Map<Long, List<String>> lessonTypesBySubject = new LinkedHashMap<>();
for (Object[] row : teacherSubjectRepository.findLessonTypeNamesBySubjectIds(subjectIds)) {
Long subjectId = ((Number) row[0]).longValue();
String lessonTypeName = String.valueOf(row[1]);
List<String> lessonTypes = lessonTypesBySubject.computeIfAbsent(subjectId, key -> new ArrayList<>());
if (!lessonTypes.contains(lessonTypeName)) {
lessonTypes.add(lessonTypeName);
}
}
return lessonTypesBySubject;
}
private DepartmentCalendarSubjectDto toDepartmentCalendarSubjectDto(
Subject subject,
Map<Long, List<DepartmentCalendarSubjectDto.CalendarAttachmentDto>> attachmentsBySubject) {
Map<Long, List<DepartmentCalendarSubjectDto.CalendarAttachmentDto>> attachmentsBySubject,
Map<Long, List<String>> lessonTypesBySubject) {
return new DepartmentCalendarSubjectDto(
subject.getId(),
subject.getCode(),
subject.getName(),
subject.getDepartmentId(),
lessonTypesBySubject.getOrDefault(subject.getId(), List.of()),
attachmentsBySubject.getOrDefault(subject.getId(), List.of())
);
}
@@ -175,6 +206,8 @@ public class DepartmentWorkspaceController {
return new DepartmentCalendarSubjectDto.CalendarAttachmentDto(
calendar.getId(),
calendar.getTitle(),
calendar.getSpeciality() == null ? null : calendar.getSpeciality().getSpecialityCode(),
calendar.getSpecialtyProfile() == null ? null : calendar.getSpecialtyProfile().getName(),
academicYear == null ? null : academicYear.getId(),
academicYear == null ? null : academicYear.getTitle(),
calendarSubject.getSemesterNumber()
@@ -6,18 +6,22 @@ import java.util.List;
* Дисциплина кафедры вместе с прикреплениями к календарным графикам.
* Прикрепления приходят из academic_calendar_subjects: дисциплина попадает
* на страницу той кафедры, за которой она закреплена в справочнике.
* lessonTypes — виды нагрузки (типы занятий) из привязок преподавателей.
*/
public record DepartmentCalendarSubjectDto(
Long id,
String code,
String name,
Long departmentId,
List<String> lessonTypes,
List<CalendarAttachmentDto> attachments
) {
public record CalendarAttachmentDto(
Long calendarId,
String calendarTitle,
String specialtyCode,
String specialtyProfileName,
Long academicYearId,
String academicYearTitle,
Integer semesterNumber
@@ -41,6 +41,7 @@ public interface AcademicCalendarSubjectRepository extends JpaRepository<Academi
join fetch calendarSubject.academicCalendar calendar
join fetch calendar.academicYear academicYear
join fetch calendar.speciality speciality
join fetch calendar.specialtyProfile specialtyProfile
join fetch calendarSubject.subject subject
where subject.departmentId = :departmentId
and subject.status <> 'ARCHIVED'
@@ -6,6 +6,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.Collection;
import java.util.List;
public interface TeacherSubjectRepository extends JpaRepository<TeacherSubject, TeacherSubjectId> {
@@ -47,4 +48,18 @@ public interface TeacherSubjectRepository extends JpaRepository<TeacherSubject,
@Param("subjectId") Long subjectId,
@Param("lessonTypeId") Long lessonTypeId
);
/**
* Виды нагрузки дисциплин (типы занятий из привязок преподавателей)
* для сводной колонки на странице кафедры. Один тип от разных
* преподавателей не дублируется — уникальность собирает контроллер.
*/
@Query(value = """
select link.subject_id, type.name
from teacher_lesson_types link
join lesson_types type on type.id = link.lesson_type_id
where link.subject_id in (:subjectIds)
order by link.subject_id, type.name
""", nativeQuery = true)
List<Object[]> findLessonTypeNamesBySubjectIds(@Param("subjectIds") Collection<Long> subjectIds);
}
@@ -10,6 +10,8 @@ import com.magistr.app.model.AcademicYear;
import com.magistr.app.model.Department;
import com.magistr.app.model.LifecycleEntity;
import com.magistr.app.model.Role;
import com.magistr.app.model.Speciality;
import com.magistr.app.model.SpecialtyProfile;
import com.magistr.app.model.Subject;
import com.magistr.app.model.TeacherDepartmentAssignment;
import com.magistr.app.model.User;
@@ -19,6 +21,7 @@ import com.magistr.app.repository.SubjectRepository;
import com.magistr.app.repository.DepartmentRepository;
import com.magistr.app.repository.TeacherCreationRequestRepository;
import com.magistr.app.repository.TeacherDepartmentAssignmentRepository;
import com.magistr.app.repository.TeacherSubjectRepository;
import com.magistr.app.repository.UserRepository;
import com.magistr.app.service.BusinessTimeService;
import com.magistr.app.service.ScheduleQueryService;
@@ -69,6 +72,7 @@ class DepartmentWorkspaceControllerTest {
mock(TeacherDepartmentAssignmentRepository.class),
mock(TeacherCreationRequestRepository.class),
mock(AcademicCalendarSubjectRepository.class),
mock(TeacherSubjectRepository.class),
mock(ScheduleQueryService.class),
mock(TeacherDepartmentService.class),
mock(SubjectImportService.class)
@@ -97,6 +101,7 @@ class DepartmentWorkspaceControllerTest {
assignmentRepository,
mock(TeacherCreationRequestRepository.class),
mock(AcademicCalendarSubjectRepository.class),
mock(TeacherSubjectRepository.class),
mock(ScheduleQueryService.class),
teacherDepartmentService,
mock(SubjectImportService.class),
@@ -127,6 +132,7 @@ class DepartmentWorkspaceControllerTest {
assignmentRepository,
mock(TeacherCreationRequestRepository.class),
mock(AcademicCalendarSubjectRepository.class),
mock(TeacherSubjectRepository.class),
mock(ScheduleQueryService.class),
mock(TeacherDepartmentService.class),
mock(SubjectImportService.class)
@@ -149,12 +155,20 @@ class DepartmentWorkspaceControllerTest {
void subjectCalendarAttachmentsSortByNameAndGroupAttachments() {
SubjectRepository subjectRepository = mock(SubjectRepository.class);
AcademicCalendarSubjectRepository calendarSubjectRepository = mock(AcademicCalendarSubjectRepository.class);
TeacherSubjectRepository teacherSubjectRepository = mock(TeacherSubjectRepository.class);
Subject databases = new Subject(10L, "Базы данных", "DB201", 1L);
Subject crypto = new Subject(11L, "Криптография", "KR101", 1L);
// порядок из репозитория намеренно не по алфавиту — контроллер сортирует
when(subjectRepository.findByDepartmentIdAndStatusNot(1L, LifecycleEntity.STATUS_ARCHIVED))
.thenReturn(List.of(crypto, databases));
Speciality speciality = new Speciality();
speciality.setId(3L);
speciality.setSpecialityName("Информационная безопасность");
speciality.setSpecialityCode("10.03.01");
SpecialtyProfile specialtyProfile = new SpecialtyProfile();
specialtyProfile.setId(4L);
specialtyProfile.setName("Без профиля");
AcademicYear year = new AcademicYear();
year.setId(1L);
year.setTitle("2026/2027");
@@ -164,11 +178,20 @@ class DepartmentWorkspaceControllerTest {
calendar.setId(2L);
calendar.setTitle("2026/2027 · 10.03.01 Информационная безопасность");
calendar.setAcademicYear(year);
calendar.setSpeciality(speciality);
calendar.setSpecialtyProfile(specialtyProfile);
AcademicCalendarSubject link = new AcademicCalendarSubject();
link.setAcademicCalendar(calendar);
link.setSemesterNumber(3);
link.setSubject(databases);
when(calendarSubjectRepository.findBySubjectDepartmentId(1L)).thenReturn(List.of(link));
// один и тот же тип занятия от двух преподавателей не дублируется
when(teacherSubjectRepository.findLessonTypeNamesBySubjectIds(List.of(10L, 11L)))
.thenReturn(List.of(
new Object[]{10L, "Лабораторные занятия"},
new Object[]{10L, "Лекции"},
new Object[]{10L, "Лекции"}
));
DepartmentWorkspaceController controller = new DepartmentWorkspaceController(
subjectRepository,
@@ -178,6 +201,7 @@ class DepartmentWorkspaceControllerTest {
mock(TeacherDepartmentAssignmentRepository.class),
mock(TeacherCreationRequestRepository.class),
calendarSubjectRepository,
teacherSubjectRepository,
mock(ScheduleQueryService.class),
mock(TeacherDepartmentService.class),
mock(SubjectImportService.class)
@@ -192,10 +216,16 @@ class DepartmentWorkspaceControllerTest {
DepartmentCalendarSubjectDto.CalendarAttachmentDto attachment = result.get(0).attachments().get(0);
assertThat(attachment.calendarId()).isEqualTo(2L);
assertThat(attachment.calendarTitle()).isEqualTo("2026/2027 · 10.03.01 Информационная безопасность");
assertThat(attachment.specialtyCode()).isEqualTo("10.03.01");
assertThat(attachment.specialtyProfileName()).isEqualTo("Без профиля");
assertThat(attachment.academicYearTitle()).isEqualTo("2026/2027");
assertThat(attachment.semesterNumber()).isEqualTo(3);
// дисциплина без прикреплений получает пустой список, а не null
// виды нагрузки дисциплины: уникальные типы занятий по алфавиту
assertThat(result.get(0).lessonTypes())
.containsExactly("Лабораторные занятия", "Лекции");
// дисциплина без прикреплений и без типов получает пустые списки, а не null
assertThat(result.get(1).attachments()).isEmpty();
assertThat(result.get(1).lessonTypes()).isEmpty();
}
@Test
@@ -208,6 +238,7 @@ class DepartmentWorkspaceControllerTest {
mock(TeacherDepartmentAssignmentRepository.class),
mock(TeacherCreationRequestRepository.class),
mock(AcademicCalendarSubjectRepository.class),
mock(TeacherSubjectRepository.class),
mock(ScheduleQueryService.class),
mock(TeacherDepartmentService.class),
mock(SubjectImportService.class)
+6
View File
@@ -1274,6 +1274,9 @@ payload обрабатываются один раз, используется
специальностей в прикрепления не попадают. Роль `DEPARTMENT` видит только свою
кафедру, `ADMIN` может передать `departmentId`. Элемент `attachments` может быть пустым —
такая дисциплина на странице кафедры помечается «Не прикреплена к графику».
`lessonTypes` — уникальные виды нагрузки дисциплины (типы занятий из привязок
преподавателей `teacher_lesson_types`); у прикрепления `specialtyCode` и
`specialtyProfileName` — шифр и профиль специальности графика.
```json
[
@@ -1282,10 +1285,13 @@ payload обрабатываются один раз, используется
"code": "DB201",
"name": "Базы данных",
"departmentId": 1,
"lessonTypes": ["Лекции", "Лабораторные занятия"],
"attachments": [
{
"calendarId": 2,
"calendarTitle": "2026/2027 · 10.03.01 Информационная безопасность · Очная",
"specialtyCode": "10.03.01",
"specialtyProfileName": "Без профиля",
"academicYearId": 1,
"academicYearTitle": "2026/2027",
"semesterNumber": 3
+5 -3
View File
@@ -99,9 +99,11 @@ Bearer-токен проверяется на backend. Frontend-скрытие
- На странице кафедры дисциплины показываются вместе с прикреплениями к календарным графикам
(`GET /api/department/subjects/calendar`): дисциплина попадает в список той кафедры, за которой
она закреплена в справочнике; график относится к кафедре, только если его специальность
используется активными группами этой кафедры. Прикрепления группируются по графику с перечнем
семестров; при нескольких графиках показывается выпадающий список. Фильтр
«В календарных графиках / Без графика» отделяет дисциплины, не входящие ни в один график.
используется активными группами этой кафедры. В таблице — колонки «Шифр» и «Профиль»
(специальность графика), «Вид нагрузки» (уникальные типы занятий дисциплины из привязок
преподавателей). Прикрепления группируются по графику с перечнем семестров; при нескольких
графиках показывается выпадающий список. Комментарии открываются строкой под дисциплиной.
Фильтр «В календарных графиках / Без графика» отделяет дисциплины, не входящие ни в один график.
### Жизненный цикл справочников
+1 -1
View File
@@ -651,7 +651,7 @@ legacy-файл вкладки. Последними (волна 6) — `schedul
загрузка 84 857 байт gzip (лимит 90 000), общие chunk 79 217 байт gzip
(лимит 85 000), lazy-вкладки 128 571 байт gzip в 25 chunk'ах (лимит 150 000,
загружаются по одной) — лимиты не поднимались;
- `npm run check`: 239 тестов пройдено (обновлены импорты тестов с legacy-модулей
- `npm run check`: 240 тестов пройдено (обновлены импорты тестов с legacy-модулей
на React-сервисы, добавлены payload-валидация, DOM-рендер конструктора
и контроль разрешения lazy-вкладок; проверки `LegacyTabView`/`legacy-views`
заменены на контроль отсутствия legacy-модулей).
+2 -2
View File
@@ -53,7 +53,7 @@
### Качество и надёжность
- **239 тестов** проходят (`npm run check`), против ~170 на момент начала этапа 5:
- **240 тестов** проходят (`npm run check`), против ~170 на момент начала этапа 5:
контракты API, payload-валидация, DOM-рендер каждой вкладки, бюджеты bundle, CSP,
разрешение всех lazy-вкладок (регрессия на React error #306 поймана и закрыта тестом).
- Логика вынесена в **чистые сервисы** (`*-service.js`) — тестируются в Node без браузера
@@ -97,5 +97,5 @@
cd frontend
npm ci
npm run build
npm run check # 239/239 тестов, бюджеты, CSP
npm run check # 240/240 тестов, бюджеты, CSP
```
+65 -13
View File
@@ -686,6 +686,58 @@
color: var(--text-primary);
}
/* ===== Кабинет кафедры: селект графиков и строка комментариев ===== */
.department-subject-calendar-select {
display: block;
width: 100%;
max-width: 360px;
min-width: 0;
padding: 0.45rem 0.65rem;
background: var(--bg-input);
border: 1px solid var(--bg-card-border);
border-radius: var(--radius-sm);
color: var(--text-primary);
font-family: inherit;
font-size: 0.85rem;
line-height: 1.35;
}
.department-subject-calendar-select:focus {
outline: none;
background: var(--bg-input-focus);
border-color: var(--accent);
box-shadow: 0 0 0 3px var(--accent-glow);
}
.department-comments-row > td {
padding: 0.9rem 0.8rem 1rem;
background: var(--bg-input);
border-bottom: 1px solid var(--bg-card-border);
}
.department-comments-card {
display: flex;
flex-direction: column;
align-items: stretch;
gap: 0.75rem;
text-align: left;
}
.department-comments-card .card-header-row {
margin-bottom: 0;
}
.department-comments-card .card-header-row h3 {
margin: 0;
font-size: 1rem;
color: var(--text-primary);
}
.department-comments-card .department-comment-list {
margin-top: 0;
}
.schedule-section-label {
display: block;
font-size: 0.78rem;
@@ -4187,9 +4239,9 @@ tbody tr:hover {
.project-dialog-field textarea { width: 100%; resize: vertical; }
.project-dialog-error { min-height: 1.3rem; margin-top: 0.35rem; color: var(--danger, #dc2626); font-size: 0.85rem; }
/* ===== Классы этапа 5 (волна 1): замена inline-стилей перенесённых вкладок ===== */
/* ===== ������ ����� 5 (����� 1): ������ inline-������ ����������� ������� ===== */
/* Заголовок карточки с действием справа (аудитории) */
/* ��������� �������� � ��������� ������ (���������) */
.card-toolbar {
display: flex;
justify-content: space-between;
@@ -4203,7 +4255,7 @@ tbody tr:hover {
margin: 0;
}
/* Строки и группы форм */
/* ������ � ������ ���� */
.form-row--spacing {
margin-top: 1rem;
}
@@ -4234,7 +4286,7 @@ tbody tr:hover {
margin-bottom: 0;
}
/* Ячейки таблиц */
/* ������ ������ */
.th-actions {
text-align: right;
}
@@ -4258,7 +4310,7 @@ tbody tr:hover {
font-size: 0.75rem;
}
/* Модальные окна перенесённых вкладок */
/* ��������� ���� ����������� ������� */
.modal-content--medium {
max-width: 600px;
width: 90%;
@@ -4287,7 +4339,7 @@ tbody tr:hover {
margin-top: 0;
}
/* Состояние загрузки lazy-вкладки */
/* ��������� �������� lazy-������� */
.tab-loading {
display: flex;
align-items: center;
@@ -4297,7 +4349,7 @@ tbody tr:hover {
color: var(--text-secondary);
}
/* Дашборд: метрики и мониторинг */
/* �������: ������� � ���������� */
.dashboard-metric-label {
font-size: 0.85rem;
color: var(--text-secondary);
@@ -4350,7 +4402,7 @@ tbody tr:hover {
border: 1px solid rgba(16, 185, 129, 0.2);
}
/* Дашборд: центр предупреждений (Red Zone) */
/* �������: ����� �������������� (Red Zone) */
.red-zone-card {
border-top: 4px solid var(--error, #ef4444);
}
@@ -4390,9 +4442,9 @@ tbody tr:hover {
color: var(--text-secondary);
}
/* ===== Этап 5 (волна 2): классы inline-стилей перенесённых вкладок ===== */
/* ===== ���� 5 (����� 2): ������ inline-������ ����������� ������� ===== */
/* Широкие модальные окна (подгруппы, профили, календарные графики) */
/* ������� ��������� ���� (���������, �������, ����������� �������) */
.modal-content--wide {
max-width: 700px;
width: 90%;
@@ -4408,7 +4460,7 @@ tbody tr:hover {
width: 90%;
}
/* Форма профиля на вкладке структуры вуза */
/* ����� ������� �� ������� ��������� ���� */
.profile-form-spec {
flex: 1;
min-width: 200px;
@@ -4424,13 +4476,13 @@ tbody tr:hover {
min-width: 250px;
}
/* Ряд кнопок формы, выровненных по нижней кромке */
/* ��� ������ �����, ����������� �� ������ ������ */
.form-actions-row {
display: flex;
gap: 0.5rem;
align-items: flex-end;
}
/* Волна 3 (этап 5): замена inline-стиля из legacy department-workspace.html */
/* ����� 3 (���� 5): ������ inline-����� �� legacy department-workspace.html */
.schedule-section-label--flush {
margin: 0;
}
@@ -2,7 +2,7 @@ import { apiClient } from '../shared/api-client.js';
import { defaultSchedulePeriod } from '../../admin/js/schedule-period.js';
import { toIsoDate } from '../shared/dates.js';
export const SUBJECT_TABLE_COLUMNS = 4;
export const SUBJECT_TABLE_COLUMNS = 7;
export const DEPARTMENT_REQUEST_TABLE_COLUMNS = 6;
// --- Справочники и период ---
@@ -109,6 +109,19 @@ export function attachmentGroupLabel(group) {
return `${title} — ${semesterNumbersLabel(group.semesterNumbers)}`;
}
// Уникальные значения поля прикреплений для сводных колонок (шифр, профиль).
export function uniqueAttachmentValues(attachments, field) {
const values = new Set();
(attachments || []).forEach(attachment => {
if (attachment && attachment[field]) values.add(attachment[field]);
});
return Array.from(values).sort((left, right) => left.localeCompare(right, 'ru'));
}
export function listValuesLabel(values) {
return (values || []).join(', ');
}
export function importSubjectsPayload(rows, departmentId) {
if (!departmentId) return { error: 'Выберите кафедру' };
const payload = (rows || [])
@@ -1,4 +1,4 @@
import { useEffect, useRef, useState } from 'react';
import { Fragment, useEffect, useRef, useState } from 'react';
import { getSession } from '../../../admin/js/api.js';
import { addDays, toIsoDate } from '../../shared/dates.js';
@@ -26,6 +26,7 @@ import {
formatDateTime,
importSubjects,
importSubjectsPayload,
listValuesLabel,
requestStatusClass,
requestStatusLabel,
saveSubjectComment,
@@ -35,6 +36,7 @@ import {
teacherMetrics,
teacherOptionLabel,
teacherRequestPayload,
uniqueAttachmentValues,
workloadLabel
} from '../department-workspace-service.js';
@@ -693,6 +695,9 @@ export function DepartmentWorkspaceTab() {
<tr>
<th>Код</th>
<th>Название</th>
<th>Шифр</th>
<th>Профиль</th>
<th>Вид нагрузки</th>
<th>Календарный график</th>
<th>Комментарии</th>
</tr>
@@ -718,10 +723,17 @@ export function DepartmentWorkspaceTab() {
</tr>
) : visibleSubjects.map(subject => {
const attachmentGroups = subjectAttachmentGroups(subject.attachments);
const specialtyCode = listValuesLabel(uniqueAttachmentValues(subject.attachments, 'specialtyCode'));
const specialtyProfile = listValuesLabel(uniqueAttachmentValues(subject.attachments, 'specialtyProfileName'));
const lessonTypes = listValuesLabel(subject.lessonTypes);
return (
<tr key={subject.id}>
<Fragment key={subject.id}>
<tr>
<td>{subject.code || '-'}</td>
<td>{subject.name || '-'}</td>
<td>{specialtyCode || '-'}</td>
<td>{specialtyProfile || '-'}</td>
<td>{lessonTypes || '-'}</td>
<td>
{attachmentGroups.length === 0 ? (
<span className="text-muted">Не прикреплена к графику</span>
@@ -751,19 +763,14 @@ export function DepartmentWorkspaceTab() {
</button>
</td>
</tr>
);
})}
</tbody>
</table>
</div>
</div>
{comments && (
<div className="card department-workspace-table-card" id="department-comments-card">
{comments && comments.subjectId === subject.id && (
<tr className="department-comments-row" id="department-comments-row">
<td colSpan={SUBJECT_TABLE_COLUMNS}>
<div className="department-comments-card" id="department-comments-card">
<div className="card-header-row">
<h2 id="department-comments-title">
<h3 id="department-comments-title">
Комментарии: {comments.subjectName || 'дисциплина'}
</h2>
</h3>
<button
type="button"
className="btn btn-sm btn-ghost"
@@ -810,7 +817,16 @@ export function DepartmentWorkspaceTab() {
))}
</div>
</div>
</td>
</tr>
)}
</Fragment>
);
})}
</tbody>
</table>
</div>
</div>
</>
);
}
+31
View File
@@ -127,6 +127,7 @@ import {
formatDateTime,
importSubjects,
importSubjectsPayload,
listValuesLabel,
requestStatusClass,
requestStatusLabel,
semesterNumbersLabel,
@@ -137,6 +138,7 @@ import {
teacherOptionLabel,
teacherRequestPayload,
teacherWorkloadEndpoint,
uniqueAttachmentValues,
workloadLabel
} from '../react/admin/department-workspace-service.js';
import {
@@ -1432,6 +1434,9 @@ test('вкладка кабинета кафедры рендерит формы
assert.match(markup, /Все дисциплины/);
assert.match(markup, /В календарных графиках/);
assert.match(markup, /Без графика/);
assert.match(markup, /Шифр/);
assert.match(markup, /Профиль/);
assert.match(markup, /Вид нагрузки/);
assert.match(markup, /Календарный график/);
assert.match(markup, /Загрузка\.\.\./);
assert.doesNotMatch(markup, /style="/);
@@ -1481,6 +1486,32 @@ test('прикрепления дисциплины группируются п
assert.deepEqual(subjectAttachmentGroups([]), []);
});
test('сводные колонки дисциплин собирают уникальные шифры и профили', () => {
const attachments = [
{ calendarId: 2, specialtyCode: '10.03.01', specialtyProfileName: 'Без профиля' },
{ calendarId: 5, specialtyCode: '09.03.01', specialtyProfileName: 'Без профиля' },
{ calendarId: 2, specialtyCode: '10.03.01', specialtyProfileName: 'Без профиля' }
];
assert.deepEqual(
uniqueAttachmentValues(attachments, 'specialtyCode'),
['09.03.01', '10.03.01']
);
assert.deepEqual(
uniqueAttachmentValues(attachments, 'specialtyProfileName'),
['Без профиля']
);
assert.equal(listValuesLabel(uniqueAttachmentValues(attachments, 'specialtyCode')), '09.03.01, 10.03.01');
assert.equal(listValuesLabel(uniqueAttachmentValues(attachments, 'specialtyProfileName')), 'Без профиля');
// без прикреплений колонки пустые
assert.deepEqual(uniqueAttachmentValues([], 'specialtyCode'), []);
assert.deepEqual(uniqueAttachmentValues(null, 'specialtyCode'), []);
assert.equal(listValuesLabel([]), '');
assert.equal(listValuesLabel(null), '');
// виды нагрузки дисциплины выводятся списком через запятую
assert.equal(listValuesLabel(['Лекции', 'Лабораторные занятия']), 'Лекции, Лабораторные занятия');
});
test('двухнедельный период загруженности считается по локальному времени', () => {
assert.deepEqual(twoWeekRange('2026-09-28'), { startDate: '2026-09-28', endDate: '2026-10-11' });
// среда 30.09 — период всё равно начинается с понедельника