From 3b51d2cdf5d1389a0c236c11e99adf01784b488d Mon Sep 17 00:00:00 2001 From: dev Date: Sat, 17 Oct 2026 01:12:50 +0300 Subject: [PATCH] feat(feedback): rewrite feedback card layout and author badge --- public/feedback.html | 13 ++++++++++++- public/js/feedback.js | 43 ++++++++++++++++++++++++++++--------------- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/public/feedback.html b/public/feedback.html index c385116..1226495 100644 --- a/public/feedback.html +++ b/public/feedback.html @@ -41,7 +41,14 @@ #fbResidentPhoto .fb-mark-stripe { left:0; right:0; top:0; bottom:0; height:auto; border-radius:50%; pointer-events:none; z-index:3; transition:border-color .25s ease, box-shadow .25s ease; } .fb-mark-stripe[hidden] { display:none; } .fb-card-resident { display:flex; align-items:center; gap:10px; min-width:0; } - .fb-card-info { display:flex; flex-direction:column; gap:3px; min-width:0; } + .fb-card-meta { display:flex; align-items:center; gap:8px; flex-wrap:wrap; min-width:0; } + .fb-card-group-row { display:flex; align-items:center; gap:10px; flex-wrap:wrap; min-width:0; } + .fb-card-group-row .lesson-author { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; } + .fb-card-group-row .lesson-when { margin-left:auto; flex:none; } + .fb-card-group-row .lesson-actions { margin-left:0; flex:none; align-items:center; } + .fb-card-foot { margin-top:auto; display:flex; align-items:center; gap:8px; flex-wrap:wrap; min-width:0; } + .fb-card-foot .fb-author { margin-left:auto; } + .fb-card-info { flex:1 1 auto; display:flex; flex-direction:column; gap:3px; min-width:0; } .fb-card-info .lesson-group, .fb-card-info .lesson-topic { min-width:0; overflow-wrap:anywhere; } .fb-card-photo { position:relative; width:63px; height:63px; flex:none; } .fb-card-photo img { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; } @@ -57,6 +64,10 @@ #fbPromptModal > .edit-modal { margin:auto; } .feedback-item { position:relative; } .feedback-item.fb-ai-made { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 130 100'%3E%3Ctext x='128' y='92' text-anchor='end' font-family='Arial,Helvetica,sans-serif' font-weight='800' font-size='104' fill='%23808080' fill-opacity='0.1'%3EAI%3C/text%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 6px bottom 2px; background-size:auto 148px; } + .fb-author { display:inline-flex; align-items:center; gap:6px; min-width:0; font-size:.78rem; color:var(--muted); border:1px solid var(--border); border-radius:999px; background:rgba(127,127,127,.08); padding:2px 10px 2px 2px; } + .fb-author-name { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:180px; } + .fb-author-av { flex:none; width:20px; height:20px; border-radius:50%; overflow:hidden; background:rgba(37,99,235,.12); color:var(--accent); display:flex; align-items:center; justify-content:center; font-size:.62rem; font-weight:700; user-select:none; } + .fb-author-av img { width:100%; height:100%; object-fit:cover; display:block; } .fb-ai-pop { position:absolute; left:12px; right:12px; top:calc(100% + 6px); z-index:40; display:flex; flex-direction:column; gap:8px; background:var(--card); border:1px solid var(--border); border-radius:var(--radius); box-shadow:0 14px 34px rgba(0,0,0,.28); padding:14px 16px; } .fb-ai-pop[hidden] { display:none; } .fb-ai-row { display:flex; align-items:center; gap:10px; font-size:.85rem; flex-wrap:wrap; } diff --git a/public/js/feedback.js b/public/js/feedback.js index 070590d..fa5ab68 100644 --- a/public/js/feedback.js +++ b/public/js/feedback.js @@ -23,36 +23,49 @@ } } + function fbAuthorHtml(f) { + const name = String(f.author_name || f.author_username || '').trim(); + if (!name) return ''; + const av = f.author_avatar + ? `` + : `${escapeHtml(name.charAt(0).toUpperCase())}`; + return `${av}${escapeHtml(name)}`; + } + function fbItemHtml(f) { const text = (f.text||'').trim(); const del = f.deleted_at ? ' style="opacity:.5"' : ''; const day = fmtDay(f.feedback_date); const hasAiInfo = f.ai_status !== 'none' || !!f.ai_prompt; - const aiMade = f.ai_status === 'done' ? ' fb-ai-made' : ''; - return `
-
- ${escapeHtml(f.group_name||'')} - ${fmtDate(f.feedback_date)}${day ? ` · ${day}` : ''} - ${f.deleted_at ? 'Удалён' : ''} - ${aiBadge(f.ai_status)} - ${f.sent_at ? 'Отправлено' : ''} -
- ${hasAiInfo ? `` : ''} + const aiDone = f.ai_status === 'done'; + const aiMade = aiDone ? ' fb-ai-made' : ''; + const canWrite = !aiDone || f.author_id == null || isAdmin() || Number(f.author_id) === Number(currentUser && currentUser.id); + const actions = canWrite ? `${hasAiInfo ? `` : ''} ${f.ai_status === 'error' ? `` : ''} ${f.deleted_at ? '' : ``} - ${f.deleted_at ? `` : ''} -
-
- ${(f.resident || f.topic) ? `
+ ${f.deleted_at ? `` : ''}` : ''; + return ` ${text ? `
${escapeHtml(text)}
` : ''} +
+ ${aiBadge(f.ai_status)} + ${f.sent_at ? 'Отправлено' : ''} + ${aiMade ? fbAuthorHtml(f) : ''} +
`; }