diff --git a/backend/src/main/java/com/magistr/app/controller/DepartmentWorkspaceController.java b/backend/src/main/java/com/magistr/app/controller/DepartmentWorkspaceController.java index e9cf472..ca031e2 100644 --- a/backend/src/main/java/com/magistr/app/controller/DepartmentWorkspaceController.java +++ b/backend/src/main/java/com/magistr/app/controller/DepartmentWorkspaceController.java @@ -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> 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> lessonTypesBySubjectId(List subjectIds) { + if (subjectIds.isEmpty()) { + return Map.of(); + } + Map> lessonTypesBySubject = new LinkedHashMap<>(); + for (Object[] row : teacherSubjectRepository.findLessonTypeNamesBySubjectIds(subjectIds)) { + Long subjectId = ((Number) row[0]).longValue(); + String lessonTypeName = String.valueOf(row[1]); + List lessonTypes = lessonTypesBySubject.computeIfAbsent(subjectId, key -> new ArrayList<>()); + if (!lessonTypes.contains(lessonTypeName)) { + lessonTypes.add(lessonTypeName); + } + } + return lessonTypesBySubject; + } + private DepartmentCalendarSubjectDto toDepartmentCalendarSubjectDto( Subject subject, - Map> attachmentsBySubject) { + Map> attachmentsBySubject, + Map> 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() diff --git a/backend/src/main/java/com/magistr/app/dto/DepartmentCalendarSubjectDto.java b/backend/src/main/java/com/magistr/app/dto/DepartmentCalendarSubjectDto.java index 59b805b..4ed5396 100644 --- a/backend/src/main/java/com/magistr/app/dto/DepartmentCalendarSubjectDto.java +++ b/backend/src/main/java/com/magistr/app/dto/DepartmentCalendarSubjectDto.java @@ -6,18 +6,22 @@ import java.util.List; * Дисциплина кафедры вместе с прикреплениями к календарным графикам. * Прикрепления приходят из academic_calendar_subjects: дисциплина попадает * на страницу той кафедры, за которой она закреплена в справочнике. + * lessonTypes — виды нагрузки (типы занятий) из привязок преподавателей. */ public record DepartmentCalendarSubjectDto( Long id, String code, String name, Long departmentId, + List lessonTypes, List attachments ) { public record CalendarAttachmentDto( Long calendarId, String calendarTitle, + String specialtyCode, + String specialtyProfileName, Long academicYearId, String academicYearTitle, Integer semesterNumber diff --git a/backend/src/main/java/com/magistr/app/repository/AcademicCalendarSubjectRepository.java b/backend/src/main/java/com/magistr/app/repository/AcademicCalendarSubjectRepository.java index 125719c..b112fdc 100644 --- a/backend/src/main/java/com/magistr/app/repository/AcademicCalendarSubjectRepository.java +++ b/backend/src/main/java/com/magistr/app/repository/AcademicCalendarSubjectRepository.java @@ -41,6 +41,7 @@ public interface AcademicCalendarSubjectRepository extends JpaRepository 'ARCHIVED' diff --git a/backend/src/main/java/com/magistr/app/repository/TeacherSubjectRepository.java b/backend/src/main/java/com/magistr/app/repository/TeacherSubjectRepository.java index af4106a..e4200c8 100755 --- a/backend/src/main/java/com/magistr/app/repository/TeacherSubjectRepository.java +++ b/backend/src/main/java/com/magistr/app/repository/TeacherSubjectRepository.java @@ -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 { @@ -47,4 +48,18 @@ public interface TeacherSubjectRepository extends JpaRepository findLessonTypeNamesBySubjectIds(@Param("subjectIds") Collection subjectIds); } diff --git a/backend/src/test/java/com/magistr/app/controller/DepartmentWorkspaceControllerTest.java b/backend/src/test/java/com/magistr/app/controller/DepartmentWorkspaceControllerTest.java index 5dcd7ad..c552874 100644 --- a/backend/src/test/java/com/magistr/app/controller/DepartmentWorkspaceControllerTest.java +++ b/backend/src/test/java/com/magistr/app/controller/DepartmentWorkspaceControllerTest.java @@ -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) diff --git a/docs/API.md b/docs/API.md index 7c29289..2e3c729 100644 --- a/docs/API.md +++ b/docs/API.md @@ -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 diff --git a/docs/BUSINESS_LOGIC.md b/docs/BUSINESS_LOGIC.md index 782d803..b8e964b 100644 --- a/docs/BUSINESS_LOGIC.md +++ b/docs/BUSINESS_LOGIC.md @@ -99,9 +99,11 @@ Bearer-токен проверяется на backend. Frontend-скрытие - На странице кафедры дисциплины показываются вместе с прикреплениями к календарным графикам (`GET /api/department/subjects/calendar`): дисциплина попадает в список той кафедры, за которой она закреплена в справочнике; график относится к кафедре, только если его специальность - используется активными группами этой кафедры. Прикрепления группируются по графику с перечнем - семестров; при нескольких графиках показывается выпадающий список. Фильтр - «В календарных графиках / Без графика» отделяет дисциплины, не входящие ни в один график. + используется активными группами этой кафедры. В таблице — колонки «Шифр» и «Профиль» + (специальность графика), «Вид нагрузки» (уникальные типы занятий дисциплины из привязок + преподавателей). Прикрепления группируются по графику с перечнем семестров; при нескольких + графиках показывается выпадающий список. Комментарии открываются строкой под дисциплиной. + Фильтр «В календарных графиках / Без графика» отделяет дисциплины, не входящие ни в один график. ### Жизненный цикл справочников diff --git a/docs/REACT_MIGRATION.md b/docs/REACT_MIGRATION.md index 532209b..90089fa 100644 --- a/docs/REACT_MIGRATION.md +++ b/docs/REACT_MIGRATION.md @@ -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-модулей). diff --git a/docs/REACT_MIGRATION_RESULT.md b/docs/REACT_MIGRATION_RESULT.md index 1017ffa..c96156e 100644 --- a/docs/REACT_MIGRATION_RESULT.md +++ b/docs/REACT_MIGRATION_RESULT.md @@ -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 ``` diff --git a/frontend/admin/css/components.css b/frontend/admin/css/components.css index 1d51a8d..a05fc67 100755 --- a/frontend/admin/css/components.css +++ b/frontend/admin/css/components.css @@ -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; } \ No newline at end of file diff --git a/frontend/react/admin/department-workspace-service.js b/frontend/react/admin/department-workspace-service.js index 335b57d..92603a4 100644 --- a/frontend/react/admin/department-workspace-service.js +++ b/frontend/react/admin/department-workspace-service.js @@ -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 || []) diff --git a/frontend/react/admin/tabs/DepartmentWorkspaceTab.jsx b/frontend/react/admin/tabs/DepartmentWorkspaceTab.jsx index 70e244f..d9ad3cd 100644 --- a/frontend/react/admin/tabs/DepartmentWorkspaceTab.jsx +++ b/frontend/react/admin/tabs/DepartmentWorkspaceTab.jsx @@ -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() { Код Название + Шифр + Профиль + Вид нагрузки Календарный график Комментарии @@ -718,99 +723,110 @@ export function DepartmentWorkspaceTab() { ) : 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 ( - - {subject.code || '-'} - {subject.name || '-'} - - {attachmentGroups.length === 0 ? ( - Не прикреплена к графику - ) : attachmentGroups.length === 1 ? ( - {attachmentGroupLabel(attachmentGroups[0])} - ) : ( - + {attachmentGroups.map(group => ( + + ))} + + )} + + + - - + Открыть + + + + {comments && comments.subjectId === subject.id && ( + + +
+
+

+ Комментарии: {comments.subjectName || 'дисциплина'} +

+ +
+ +
+
+ + setCommentText(event.target.value)} + /> +
+ +
+ +
+ {comments.items === null ? ( + 'Загрузка...' + ) : comments.error ? ( +
{comments.error}
+ ) : comments.items.length === 0 ? ( +
Комментариев пока нет
+ ) : comments.items.map((comment, index) => ( +
+ {comment.authorName || 'Автор не указан'} + {formatDateTime(comment.createdAt)} +

{comment.comment}

+
+ ))} +
+
+ + + )} + ); })} - - {comments && ( -
-
-

- Комментарии: {comments.subjectName || 'дисциплина'} -

- -
- -
-
- - setCommentText(event.target.value)} - /> -
- -
- -
- {comments.items === null ? ( - 'Загрузка...' - ) : comments.error ? ( -
{comments.error}
- ) : comments.items.length === 0 ? ( -
Комментариев пока нет
- ) : comments.items.map((comment, index) => ( -
- {comment.authorName || 'Автор не указан'} - {formatDateTime(comment.createdAt)} -

{comment.comment}

-
- ))} -
-
- )} ); } diff --git a/frontend/tests/react-admin-tabs.test.mjs b/frontend/tests/react-admin-tabs.test.mjs index dd1b46d..6da225b 100644 --- a/frontend/tests/react-admin-tabs.test.mjs +++ b/frontend/tests/react-admin-tabs.test.mjs @@ -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 — период всё равно начинается с понедельника