feat(report-card): decorative waves + exclude current entry from student works

This commit is contained in:
dev
2026-10-20 15:36:14 +03:00
parent ea8722b544
commit 451ca278cc
4 changed files with 32 additions and 5 deletions
+10
View File
@@ -1036,7 +1036,11 @@ body[data-page=settings] .page-head{align-items:flex-end}
--sc-media-inset:20px;
--sc-smiley-size:50px;
--sc-smiley-bottom:16px;
--sc-wave-top:#D9EDFF;
--sc-wave-bl:#CFE3FF;
--sc-wave-br:#E4F0FF;
position:relative;
isolation:isolate;
width:100%;
max-width:440px;
background:var(--card);
@@ -1082,6 +1086,9 @@ body[data-page=settings] .page-head{align-items:flex-end}
padding:24px var(--sc-pad-x);
}
.student-card__sparks{position:absolute;top:15px;right:16px;width:104px;color:#E1ECFB;pointer-events:none}
.student-card__wave-top{position:absolute;top:0;left:0;width:125px;height:65px;fill:var(--sc-wave-top);transform:rotate(-8deg);z-index:-1;pointer-events:none}
.student-card__wave-bl{position:absolute;left:0;bottom:0;width:220px;height:100px;fill:var(--sc-wave-bl);z-index:-1;pointer-events:none}
.student-card__wave-br{position:absolute;right:0;bottom:0;width:280px;height:170px;fill:var(--sc-wave-br);z-index:-1;pointer-events:none}
.student-card__name{margin:0 0 8px;font-size:20px;font-weight:750;line-height:1.25;letter-spacing:-.1px;color:var(--sc-text);overflow-wrap:break-word}
.student-card__name[hidden]{display:none}
.student-card__media[hidden]{display:none}
@@ -1275,6 +1282,9 @@ body.report-card-open .report-fields{display:flex}
--sc-smiley-size:40px;
}
.student-card__logo{width:36px;height:36px}
.student-card__wave-br{width:215px;height:130.5px}
.student-card__wave-bl{width:165px;height:75px}
.student-card__wave-top{width:100px;height:52px}
.student-card__badge{font-size:12px;padding:6px 11px}
}
+9
View File
@@ -500,6 +500,9 @@
<div class="modal-overlay report-overlay" id="reportCardModal">
<article class="student-card" aria-labelledby="reportCardName">
<svg class="student-card__wave-top" viewBox="0 0 125 65" aria-hidden="true" focusable="false">
<path d="M0 0H125V9.75A93.75 55.25 0 0 1 31.25 65H0Z"/>
</svg>
<div class="student-card__media" id="reportCardMedia">
<img class="student-card__photo" id="reportCardPhoto" alt="" decoding="async">
<div class="student-card__nophoto" id="reportCardNoPhoto" hidden>
@@ -512,6 +515,12 @@
<img class="student-card__logo" id="reportCardLogo" alt="" decoding="async" hidden>
</div>
<div class="student-card__content">
<svg class="student-card__wave-bl" viewBox="0 0 220 100" aria-hidden="true" focusable="false">
<path d="M0 0C25 35 15 65 55 75C90 85 115 55 155 85C175 100 195 112 220 100L220 100L0 100Z"/>
</svg>
<svg class="student-card__wave-br" viewBox="0 0 280 170" aria-hidden="true" focusable="false">
<path d="M0 170C30 125 55 125 100 120C160 115 180 65 205 30C225 0 255 0 280 0L280 170Z"/>
</svg>
<svg class="student-card__sparks" viewBox="0 0 120 40" aria-hidden="true" focusable="false">
<g fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round">
<path d="M6 30c14-6 30-6 44 0"/>
+4 -3
View File
@@ -293,15 +293,16 @@ async function hydrateReportCardStudentWorks(e) {
if (!box) return;
const name = String(e.student_name || '').trim();
if (!name) { box.remove(); return; }
const cached = studentWorksCache.get(name);
const key = `${name}#${e.id}`;
const cached = studentWorksCache.get(key);
if (cached) { paintReportCardStudentWorks(box, cached, e.id); return; }
box.classList.add('is-loading');
box.innerHTML = '<span class="sc-w__spin" aria-hidden="true"></span>';
try {
const res = await fetch(`${API}/api/students/works-by-name?name=${encodeURIComponent(name)}&limit=3`, { headers: hdr() });
const res = await fetch(`${API}/api/students/works-by-name?name=${encodeURIComponent(name)}&limit=3&exclude_entry=${encodeURIComponent(e.id)}`, { headers: hdr() });
const data = await res.json();
const photos = (data.photos || []).filter(Boolean);
studentWorksCache.set(name, photos);
studentWorksCache.set(key, photos);
if (reportCardEntryId !== e.id) return;
paintReportCardStudentWorks(document.getElementById('reportCardStudentWorks'), photos, e.id);
} catch (err) {
+9 -2
View File
@@ -8210,8 +8210,10 @@ app.get('/api/students/works-by-name', requireAuth, async (req, res) => {
const name = String(req.query.name || '').trim().slice(0, 150);
if (!name) return res.json({ photos: [] });
let limit = 3;
let excludeEntry = null;
try {
limit = optInt(req.query.limit, 1, 24) ?? 3;
excludeEntry = optInt(req.query.exclude_entry, 1, Infinity);
} catch {
return res.status(400).json({ error: 'Неверный limit' });
}
@@ -8223,16 +8225,21 @@ app.get('/api/students/works-by-name', requireAuth, async (req, res) => {
params.push(bs.ids);
branch = ` AND g.branch_id = ANY($${params.length}::int[])`;
}
let excl = '';
if (excludeEntry) {
params.push(excludeEntry);
excl = ` AND e.id <> $${params.length}`;
}
params.push(limit);
const { rows } = await pool.query(
`SELECT path FROM (
SELECT e.photo_path AS path, e.created_at AS ca
FROM entries e JOIN groups g ON g.id = e.group_id
WHERE e.student_name = $1 AND e.deleted_at IS NULL AND e.photo_path IS NOT NULL${branch}
WHERE e.student_name = $1 AND e.deleted_at IS NULL AND e.photo_path IS NOT NULL${branch}${excl}
UNION ALL
SELECT ep.photo_path AS path, e.created_at AS ca
FROM entries e JOIN groups g ON g.id = e.group_id JOIN entry_photos ep ON ep.entry_id = e.id
WHERE e.student_name = $1 AND e.deleted_at IS NULL AND ep.photo_path IS NOT NULL${branch}
WHERE e.student_name = $1 AND e.deleted_at IS NULL AND ep.photo_path IS NOT NULL${branch}${excl}
) u
GROUP BY path
ORDER BY MAX(ca) DESC NULLS LAST