style: 系统化待办多人姓名逐行展示 #692

Merged
yueyang merged 1 commits from feature/yueyang-systemization-people-lines into main 2026-10-27 16:25:28 +08:00
2 changed files with 78 additions and 2 deletions

View File

@ -70,6 +70,9 @@
.sys-todo-table__inline-actions .sys-todo-table__inline-add { margin-top:.3rem; }
.sys-todo-table__progress-notes { white-space:normal; }
.sys-todo-table__progress-notes-content { display:flex; min-width:0; flex-direction:column; gap:.35rem; }
.sys-todo-table__people { white-space:normal; }
.sys-todo-table__people-list { display:grid; min-width:0; gap:.08rem; }
.sys-todo-table__person { display:block; min-width:0; line-height:1.45; overflow-wrap:anywhere; }
.sys-todo-table__detail { display:grid; min-width:0; gap:.15rem; }
.sys-todo-table__detail-label { color:#856632; font-size:.66rem; font-weight:600; }
.sys-todo-table__detail-text { display:block; min-width:0; white-space:pre-line; overflow-wrap:anywhere; line-height:1.6; }
@ -389,6 +392,16 @@
(string) $value,
));
};
$personNames = static function (?string $value): array {
$parts = preg_split('/[、,,;;\/]+/u', trim((string) $value)) ?: [];
return collect($parts)
->map(static fn (string $name): string => trim($name))
->filter(static fn (string $name): bool => $name !== '' && $name !== '—')
->unique()
->values()
->all();
};
$sectionLabels = $items
->map(static fn ($groupItem): string => trim((string) $groupItem->section_display))
->all();
@ -586,8 +599,30 @@
@endif
</div>
</td>
<td>{{ $item->owner ?: '—' }}</td>
<td>{{ $item->assignee ?: '—' }}</td>
@php($ownerNames = $personNames($item->owner))
<td class="sys-todo-table__people">
@if ($ownerNames === [])
—
@else
<span class="sys-todo-table__people-list">
@foreach ($ownerNames as $ownerName)
<span class="sys-todo-table__person">{{ $ownerName }}</span>
@endforeach
</span>
@endif
</td>
@php($assigneeNames = $personNames($item->assignee))
<td class="sys-todo-table__people">
@if ($assigneeNames === [])
—
@else
<span class="sys-todo-table__people-list">
@foreach ($assigneeNames as $assigneeName)
<span class="sys-todo-table__person">{{ $assigneeName }}</span>
@endforeach
</span>
@endif
</td>
<td>{{ $item->start_date?->format('Y-m-d') ?: ($item->start_note ?: '—') }}</td>
<td>{{ $item->due_date?->format('Y-m-d') ?: ($item->due_note ?: '—') }}</td>
<td><span class="sys-todo-table__reminder is-{{ $item->reminder_tone }}">{{ $item->reminder_label }}</span></td>

View File

@ -216,6 +216,47 @@ class SystemizationTodosTest extends FeatureTestCase
);
}
public function test_multi_person_owners_and_assignees_render_one_name_per_line(): void
{
$this->loginAs();
$this->createTodo(
'收入',
'多人责任人展示',
'检查多人姓名换行',
'2026-11-30',
1,
'晨曦、人参',
'人参、秋香、常仪',
);
$response = $this->get(route('business.pages.show', [
'section' => 'other',
'page' => 'systemization-todos',
]))->assertOk();
$html = (string) $response->getContent();
$this->assertStringContainsString(
'<span class="sys-todo-table__people-list">',
$html,
);
$this->assertMatchesRegularExpression(
'/<td class="sys-todo-table__people">\s*<span class="sys-todo-table__people-list">\s*'
. '<span class="sys-todo-table__person">晨曦<\/span>\s*'
. '<span class="sys-todo-table__person">人参<\/span>\s*'
. '<\/span>\s*<\/td>/s',
$html,
);
$this->assertMatchesRegularExpression(
'/<td class="sys-todo-table__people">\s*<span class="sys-todo-table__people-list">\s*'
. '<span class="sys-todo-table__person">人参<\/span>\s*'
. '<span class="sys-todo-table__person">秋香<\/span>\s*'
. '<span class="sys-todo-table__person">常仪<\/span>\s*'
. '<\/span>\s*<\/td>/s',
$html,
);
}
public function test_can_insert_a_todo_at_a_selected_sequence_and_shift_existing_items(): void
{
$this->loginAs();