feat: колонки шифр/профиль/вид нагрузки + комментарии под строкой
- Таблица дисциплин кафедры: новые колонки «Шифр» (специальность графика), «Профиль» (профиль обучения графика), «Вид нагрузки» (уникальные типы занятий дисциплины из teacher_lesson_types) - Комментарии открываются строкой таблицы под выбранной дисциплиной, а не отдельной карточкой внизу страницы - Селект графиков получил стили дизайн-системы (фон, границы, шрифт) — раньше был нечитаемым - Тесты: backend 5/5, frontend 240/240; проверено в браузере
This commit is contained in:
1 parent
efacac1c59
commit
37665f1aae
13 files changed
+315
-111
No files matched your search
@@ -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,99 +723,110 @@ 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}>
|
||||
<td>{subject.code || '-'}</td>
|
||||
<td>{subject.name || '-'}</td>
|
||||
<td>
|
||||
{attachmentGroups.length === 0 ? (
|
||||
<span className="text-muted">Не прикреплена к графику</span>
|
||||
) : attachmentGroups.length === 1 ? (
|
||||
<span>{attachmentGroupLabel(attachmentGroups[0])}</span>
|
||||
) : (
|
||||
<select
|
||||
className="department-subject-calendar-select"
|
||||
aria-label="Календарные графики дисциплины"
|
||||
defaultValue={String(attachmentGroups[0].calendarId)}
|
||||
<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>
|
||||
) : attachmentGroups.length === 1 ? (
|
||||
<span>{attachmentGroupLabel(attachmentGroups[0])}</span>
|
||||
) : (
|
||||
<select
|
||||
className="department-subject-calendar-select"
|
||||
aria-label="Календарные графики дисциплины"
|
||||
defaultValue={String(attachmentGroups[0].calendarId)}
|
||||
>
|
||||
{attachmentGroups.map(group => (
|
||||
<option key={group.calendarId} value={String(group.calendarId)}>
|
||||
{attachmentGroupLabel(group)}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-sm btn-secondary department-comments-open"
|
||||
onClick={() => void openComments(subject.id, subject.name || '')}
|
||||
>
|
||||
{attachmentGroups.map(group => (
|
||||
<option key={group.calendarId} value={String(group.calendarId)}>
|
||||
{attachmentGroupLabel(group)}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-sm btn-secondary department-comments-open"
|
||||
onClick={() => void openComments(subject.id, subject.name || '')}
|
||||
>
|
||||
Открыть
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
Открыть
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{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">
|
||||
<h3 id="department-comments-title">
|
||||
Комментарии: {comments.subjectName || 'дисциплина'}
|
||||
</h3>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-sm btn-ghost"
|
||||
id="department-comments-close"
|
||||
onClick={() => setComments(null)}
|
||||
>
|
||||
Скрыть
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<form id="department-comment-form" className="form-row" onSubmit={submitComment}>
|
||||
<div className="form-group">
|
||||
<label htmlFor="department-comment-text">Новый комментарий</label>
|
||||
<input
|
||||
type="text"
|
||||
id="department-comment-text"
|
||||
placeholder="Добавьте примечание по дисциплине"
|
||||
value={commentText}
|
||||
onChange={event => setCommentText(event.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<button type="submit" className="btn btn-md btn-primary">Сохранить</button>
|
||||
</form>
|
||||
<div
|
||||
className={`form-alert${commentAlert.text ? (commentAlert.isError ? ' error' : ' success') : ''}`}
|
||||
id="department-comment-alert"
|
||||
role="alert"
|
||||
>
|
||||
{commentAlert.text}
|
||||
</div>
|
||||
<div className="department-comment-list" id="department-comment-list">
|
||||
{comments.items === null ? (
|
||||
'Загрузка...'
|
||||
) : comments.error ? (
|
||||
<div className="loading-row">{comments.error}</div>
|
||||
) : comments.items.length === 0 ? (
|
||||
<div className="loading-row">Комментариев пока нет</div>
|
||||
) : comments.items.map((comment, index) => (
|
||||
<article className="department-comment-item" key={index}>
|
||||
<strong>{comment.authorName || 'Автор не указан'}</strong>
|
||||
<span>{formatDateTime(comment.createdAt)}</span>
|
||||
<p>{comment.comment}</p>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
</Fragment>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{comments && (
|
||||
<div className="card department-workspace-table-card" id="department-comments-card">
|
||||
<div className="card-header-row">
|
||||
<h2 id="department-comments-title">
|
||||
Комментарии: {comments.subjectName || 'дисциплина'}
|
||||
</h2>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-sm btn-ghost"
|
||||
id="department-comments-close"
|
||||
onClick={() => setComments(null)}
|
||||
>
|
||||
Скрыть
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<form id="department-comment-form" className="form-row" onSubmit={submitComment}>
|
||||
<div className="form-group">
|
||||
<label htmlFor="department-comment-text">Новый комментарий</label>
|
||||
<input
|
||||
type="text"
|
||||
id="department-comment-text"
|
||||
placeholder="Добавьте примечание по дисциплине"
|
||||
value={commentText}
|
||||
onChange={event => setCommentText(event.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<button type="submit" className="btn btn-md btn-primary">Сохранить</button>
|
||||
</form>
|
||||
<div
|
||||
className={`form-alert${commentAlert.text ? (commentAlert.isError ? ' error' : ' success') : ''}`}
|
||||
id="department-comment-alert"
|
||||
role="alert"
|
||||
>
|
||||
{commentAlert.text}
|
||||
</div>
|
||||
<div className="department-comment-list" id="department-comment-list">
|
||||
{comments.items === null ? (
|
||||
'Загрузка...'
|
||||
) : comments.error ? (
|
||||
<div className="loading-row">{comments.error}</div>
|
||||
) : comments.items.length === 0 ? (
|
||||
<div className="loading-row">Комментариев пока нет</div>
|
||||
) : comments.items.map((comment, index) => (
|
||||
<article className="department-comment-item" key={index}>
|
||||
<strong>{comment.authorName || 'Автор не указан'}</strong>
|
||||
<span>{formatDateTime(comment.createdAt)}</span>
|
||||
<p>{comment.comment}</p>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -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 — период всё равно начинается с понедельника
|
||||
|
||||
Reference in new issue
Block a user