@extends('layouts.app')
@section('title', '活動')
@section('content')
@php
$allTrackers = \App\Models\IssueTracker::asOptions();
$allStatuses = \App\Models\IssueStatus::asOptions();
$trackerColor = [
'bug' => '#c0392b',
'feature' => '#2980b9',
'task' => '#27ae60',
'support' => '#8e44ad',
'doc' => '#e67e22',
];
$today = now()->format('Y-m-d');
$yesterday = now()->subDay()->format('Y-m-d');
@endphp
@include('projects._list_tabs', ['activeTab' => 'activity'])
{{-- 篩選列 --}}
@if($grouped->isEmpty())
此時段內沒有活動記錄。
@else
@foreach($grouped as $date => $items)
@php
$label = $date === $today
? '今天'
: ($date === $yesterday ? '昨天' : $date);
@endphp
{{-- 日期標題 --}}
{{ $label }}
{{ $items->count() }} 筆
{{-- 活動列表 --}}
@foreach($items as $issue)
@php
$tLabel = $allTrackers[$issue->tracker]['label'] ?? $issue->tracker;
$tBs = $allTrackers[$issue->tracker]['color'] ?? 'secondary';
$tColor = $trackerColor[$issue->tracker] ?? '#555';
$sBs = $allStatuses[$issue->status]['color'] ?? 'secondary';
$sLabel = $allStatuses[$issue->status]['label'] ?? $issue->status;
$isNew = $issue->created_at->format('Y-m-d') === $date
&& abs($issue->updated_at->timestamp - $issue->created_at->timestamp) < 60;
$projName = $issue->project->name ?? '—';
$clientName = $issue->project->client->name ?? null;
$displayProj = $clientName ? $clientName . ' · ' . $projName : $projName;
$assignee = $issue->assignee->name ?? ($issue->user->name ?? null);
$timeStr = $issue->updated_at->format('H:i');
@endphp
{{-- 圖示:新建立 vs 更新 --}}
@if($isNew)
@else
@endif
{{ $timeStr }}
{{ $displayProj }}
{{ $tLabel }}
@if($isNew)
新
@endif
{{ $sLabel }}
@if($isNew && $issue->description)
{{ Str::limit(strip_tags($issue->description), 120) }}
@endif
@if($assignee)
{{ $assignee }}
@endif
@endforeach
@endforeach
@endif
@endsection