fix(admin): keep ticket internal notes compact

Show only the latest three notes and fold older ones into a details
toggle, collapse the note composer to one line until focused, and cap
the sidebar height to the dialog body so its controls stay reachable.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
kate522andClaude Fable 5 committed 2026-10-31 12:21:53 +08:00
1 parent a9709377bb
commit 7b65b3c6d8
3 files changed
+41 -10

No files matched your search

+17 -5
View File
@@ -62,7 +62,7 @@ html.aksrt-ticket-modal-open { overflow: hidden; scrollbar-gutter: stable; }
.aksrt-ticket-dialog__foot > .aksrt-ticket-hint { margin-right: auto; }
.aksrt-ticket-dialog [hidden] { display: none !important; }
.aksrt-ticket-dialog textarea { box-sizing: border-box; width: 100%; min-height: 64px; resize: vertical; line-height: 1.65; }
.aksrt-ticket-dialog :is(input, select, textarea, button, a):focus-visible,
.aksrt-ticket-dialog :is(input, select, textarea, button, a, summary):focus-visible,
.aksrt-ticket-conversation__scroll:focus-visible { outline: 2px solid var(--an-primary); outline-offset: 2px; box-shadow: none; }
.aksrt-ticket-dialog button:disabled { cursor: default; opacity: .6; }
.aksrt-ticket-feedback { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 24px; color: #176b3d; background: var(--an-primary-soft); border-bottom: 1px solid color-mix(in srgb, var(--an-primary) 18%, transparent); font-size: 13px; }
@@ -74,7 +74,8 @@ html.aksrt-ticket-modal-open { overflow: hidden; scrollbar-gutter: stable; }
.aksrt-ticket-detail { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.aksrt-ticket-detail__main,
.aksrt-ticket-detail__side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.aksrt-ticket-detail__side { position: sticky; top: 0; }
/* 侧栏不超过弹窗正文可视高度(变量由脚本按正文尺寸写入,减去上下内边距),超出时栏内滚动。 */
.aksrt-ticket-detail__side { position: sticky; top: 0; max-height: calc(var(--aksrt-ticket-panel-height, calc(100dvh - 160px)) - 32px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.aksrt-ticket-conversation,
.aksrt-ticket-composer--reply,
.aksrt-ticket-detail__card { background: var(--an-card); border: 1px solid var(--an-border); border-radius: var(--an-radius); }
@@ -118,7 +119,6 @@ html.aksrt-ticket-modal-open { overflow: hidden; scrollbar-gutter: stable; }
.aksrt-ticket-composer--reply { padding: 14px 16px 16px; }
.aksrt-ticket-composer__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 8px; }
.aksrt-ticket-composer__head label { color: var(--an-text); font-size: 14px; font-weight: 600; }
.aksrt-ticket-composer--note .aksrt-ticket-composer__head label { font-size: 13px; font-weight: 500; }
.aksrt-ticket-composer__box { background: var(--an-card); border: 1px solid var(--an-border); border-radius: var(--an-radius-sm); transition: border-color .15s, box-shadow .15s; }
.aksrt-ticket-composer__box:focus-within { border-color: var(--an-primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--an-primary) 18%, transparent); }
.aksrt-native .aksrt-ticket-composer__box textarea { display: block; padding: 10px 12px; background: transparent; border: 0; border-radius: var(--an-radius-sm) var(--an-radius-sm) 0 0; box-shadow: none; }
@@ -147,15 +147,27 @@ html.aksrt-ticket-modal-open { overflow: hidden; scrollbar-gutter: stable; }
.aksrt-ticket-detail__private { background: #fffbf0; border-color: #f3e2b6; }
.aksrt-ticket-detail__private .aksrt-ticket-section-head { margin-bottom: 4px; }
.aksrt-ticket-detail__private > .aksrt-ticket-hint { margin: 0 0 12px; color: #a26b07; }
.aksrt-ticket-detail__notes { display: flex; flex-direction: column; gap: 8px; max-height: 240px; margin: 0 0 12px; padding: 0; overflow-y: auto; list-style: none; }
.aksrt-ticket-detail__notes { max-height: 240px; margin: 0 0 12px; overflow-y: auto; overscroll-behavior: contain; }
.aksrt-ticket-detail__notes ol { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.aksrt-ticket-detail__notes-older { margin-bottom: 8px; }
.aksrt-ticket-detail__notes-older > summary { display: flex; align-items: center; gap: 6px; padding: 2px 0; color: #a26b07; font-size: 12px; cursor: pointer; list-style: none; }
.aksrt-ticket-detail__notes-older > summary::-webkit-details-marker { display: none; }
.aksrt-ticket-detail__notes-older > summary::before { content: ""; flex: none; width: 5px; height: 5px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
.aksrt-ticket-detail__notes-older[open] > summary::before { transform: rotate(45deg); }
.aksrt-ticket-detail__notes-older > summary:hover { color: #7a5005; }
.aksrt-ticket-detail__notes-older > ol { margin-top: 8px; }
.aksrt-ticket-detail__notes li { margin: 0; padding: 8px 10px; background: var(--an-card); border: 1px solid #f3e2b6; border-radius: var(--an-radius-sm); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.aksrt-ticket-detail__note-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px; margin-bottom: 4px; font-size: 12px; }
.aksrt-ticket-detail__note-head time { color: var(--an-muted); font-variant-numeric: tabular-nums; }
.aksrt-ticket-detail__private .aksrt-ticket-composer__box { border-color: #f3e2b6; }
/* 备注输入平时收成一行;聚焦或已有内容时展开为多行并显示提交栏。卡片标题已说明用途,标签仅供读屏。 */
.aksrt-ticket-composer--note .aksrt-ticket-composer__head { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.aksrt-ticket-composer--note:not(:focus-within):has(textarea:placeholder-shown) textarea { height: 42px; min-height: 0; resize: none; overflow: hidden; }
.aksrt-ticket-composer--note:not(:focus-within):has(textarea:placeholder-shown) .aksrt-ticket-composer__bar { display: none; }
@media (max-width: 960px) {
.aksrt-ticket-detail { grid-template-columns: minmax(0, 1fr); }
.aksrt-ticket-detail__side { position: static; }
.aksrt-ticket-detail__side { position: static; max-height: none; overflow: visible; }
}
@media (max-width: 600px) {
.aksrt-ticket-dialog,
+8
View File
@@ -202,6 +202,8 @@
updateUrl(id, data.page);
setupForms(panel, restore);
showLatest(false);
var notes = panel.querySelector('.aksrt-ticket-detail__notes');
if (notes) notes.scrollTop = notes.scrollHeight;
stale = false;
savedDrafts = {};
savedMessage = '';
@@ -405,6 +407,12 @@
// scroll 不冒泡,用捕获监听会话容器。
panel.addEventListener('scroll', syncLatest, true);
// 把正文可视高度写给 CSS,用于限制右侧栏高度。
if (typeof ResizeObserver === 'function') {
new ResizeObserver(function () {
panel.style.setProperty('--aksrt-ticket-panel-height', panel.clientHeight + 'px');
}).observe(panel);
}
window.addEventListener('beforeunload', function (event) {
if (!saving && !dirty()) return;
+16 -5
View File
@@ -175,21 +175,32 @@ trait UsersMenusTicketsDetail {
return $options;
}
/** 默认只展示最新 3 条备注,更早的收进原生 <details>,避免历史备注撑满侧栏。 */
private function ticket_notes_card(int $id): string {
$notes = TicketNoteService::for_ticket($id);
$visible = 3;
$html = '<section class="aksrt-ticket-detail__card aksrt-ticket-detail__private"><div class="aksrt-ticket-section-head"><h3>' . esc_html__('内部备注', 'aksrt');
if ($notes !== []) {
$html .= ' <span class="aksrt-ticket-pill">' . count($notes) . '</span>';
}
$html .= '</h3></div><p class="aksrt-ticket-hint">' . esc_html__('仅管理员可见,不会发送给用户。', 'aksrt') . '</p>';
if ($notes !== []) {
$html .= '<ol class="aksrt-ticket-detail__notes">';
foreach ($notes as $note) {
$html .= '<li><div class="aksrt-ticket-detail__note-head"><strong>' . esc_html((string) $note['admin_name']) . '</strong><time>' . esc_html((string) $note['created_at']) . '</time></div><div>' . nl2br(esc_html((string) $note['content'])) . '</div></li>';
$older = array_slice($notes, 0, -$visible);
$html .= '<div class="aksrt-ticket-detail__notes">';
if ($older !== []) {
$html .= '<details class="aksrt-ticket-detail__notes-older"><summary>' . esc_html(sprintf(__('更早的 %d 条备注', 'aksrt'), count($older))) . '</summary>' . $this->ticket_notes_list($older) . '</details>';
}
$html .= '</ol>';
$html .= $this->ticket_notes_list(array_slice($notes, -$visible)) . '</div>';
}
return $html . $this->ticket_composer('note', $id, 'aksrt-ticket-note-' . $id, __('添加备注', 'aksrt'), '', __('记录处理进展、排查结论…', 'aksrt'), 2, '', __('添加内部备注', 'aksrt'), false) . '</section>';
return $html . $this->ticket_composer('note', $id, 'aksrt-ticket-note-' . $id, __('添加备注', 'aksrt'), '', __('记录处理进展、排查结论…', 'aksrt'), 3, '', __('添加内部备注', 'aksrt'), false) . '</section>';
}
private function ticket_notes_list(array $notes): string {
$html = '<ol>';
foreach ($notes as $note) {
$html .= '<li><div class="aksrt-ticket-detail__note-head"><strong>' . esc_html((string) $note['admin_name']) . '</strong><time>' . esc_html((string) $note['created_at']) . '</time></div><div>' . nl2br(esc_html((string) $note['content'])) . '</div></li>';
}
return $html . '</ol>';
}
private function ticket_attachments_html(array $urls): string {