feat: [pm] 프로젝트 관리 기능 개선
- AdminPmProject 모델: 통계 관련 속성 추가 - ProjectService: 통계 조회 로직 개선 - 프로젝트 목록 뷰: 통계 표시 및 UI 개선 - 프로젝트 테이블 뷰: 진행률 표시 개선
This commit is contained in:
@@ -151,4 +151,25 @@ public function getIssueStatsAttribute(): array
|
||||
'closed' => $this->issues()->where('status', AdminPmIssue::STATUS_CLOSED)->count(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 상태 라벨 (한글)
|
||||
*/
|
||||
public function getStatusLabelAttribute(): string
|
||||
{
|
||||
return self::getStatuses()[$this->status] ?? $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 상태별 색상 클래스
|
||||
*/
|
||||
public function getStatusColorAttribute(): string
|
||||
{
|
||||
return match ($this->status) {
|
||||
self::STATUS_ACTIVE => 'bg-green-100 text-green-800',
|
||||
self::STATUS_COMPLETED => 'bg-blue-100 text-blue-800',
|
||||
self::STATUS_ON_HOLD => 'bg-yellow-100 text-yellow-800',
|
||||
default => 'bg-gray-100 text-gray-800',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ public function changeStatus(int $id, string $status): AdminPmProject
|
||||
*/
|
||||
public function duplicateProject(int $id, ?string $newName = null): AdminPmProject
|
||||
{
|
||||
$original = AdminPmProject::with('tasks')->findOrFail($id);
|
||||
$original = AdminPmProject::with(['tasks.issues'])->findOrFail($id);
|
||||
|
||||
$newProject = $original->replicate();
|
||||
$newProject->name = $newName ?? $original->name.' (복사본)';
|
||||
@@ -223,7 +223,7 @@ public function duplicateProject(int $id, ?string $newName = null): AdminPmProje
|
||||
$newProject->updated_at = now();
|
||||
$newProject->save();
|
||||
|
||||
// 작업 복제
|
||||
// 작업 및 이슈 복제 (task_id 매핑 유지)
|
||||
foreach ($original->tasks as $task) {
|
||||
$newTask = $task->replicate();
|
||||
$newTask->project_id = $newProject->id;
|
||||
@@ -234,8 +234,22 @@ public function duplicateProject(int $id, ?string $newName = null): AdminPmProje
|
||||
$newTask->created_at = now();
|
||||
$newTask->updated_at = now();
|
||||
$newTask->save();
|
||||
|
||||
// 해당 작업의 이슈들 복제
|
||||
foreach ($task->issues as $issue) {
|
||||
$newIssue = $issue->replicate();
|
||||
$newIssue->project_id = $newProject->id;
|
||||
$newIssue->task_id = $newTask->id;
|
||||
$newIssue->status = AdminPmIssue::STATUS_OPEN;
|
||||
$newIssue->created_by = auth()->id();
|
||||
$newIssue->updated_by = null;
|
||||
$newIssue->deleted_by = null;
|
||||
$newIssue->created_at = now();
|
||||
$newIssue->updated_at = now();
|
||||
$newIssue->save();
|
||||
}
|
||||
}
|
||||
|
||||
return $newProject->load('tasks');
|
||||
return $newProject->load('tasks.issues');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,12 +45,19 @@
|
||||
<div class="mt-4">
|
||||
@php
|
||||
$taskTotal = $summary['task_stats']['total'] ?: 1;
|
||||
$donePercent = round(($summary['task_stats']['done'] / $taskTotal) * 100);
|
||||
$taskDone = $summary['task_stats']['done'] ?? 0;
|
||||
$taskInProgress = $summary['task_stats']['in_progress'] ?? 0;
|
||||
$donePercent = round(($taskDone / $taskTotal) * 100);
|
||||
$inProgressPercent = round((($taskDone + $taskInProgress) / $taskTotal) * 100);
|
||||
@endphp
|
||||
<div class="w-full bg-gray-200 rounded-full h-2">
|
||||
<div class="bg-green-500 h-2 rounded-full" style="width: {{ $donePercent }}%"></div>
|
||||
<div class="w-full bg-gray-200 rounded-full h-2 relative overflow-hidden">
|
||||
<div class="absolute h-2 rounded-full bg-blue-400" style="width: {{ $inProgressPercent }}%"></div>
|
||||
<div class="absolute h-2 rounded-full bg-green-500" style="width: {{ $donePercent }}%"></div>
|
||||
</div>
|
||||
<div class="flex justify-between text-xs mt-1">
|
||||
<span class="text-gray-500">진행률 {{ $inProgressPercent }}%</span>
|
||||
<span class="text-gray-400">(완료 {{ $donePercent }}% + 진행 {{ $inProgressPercent - $donePercent }}%)</span>
|
||||
</div>
|
||||
<p class="text-xs text-gray-500 mt-1">완료율 {{ $donePercent }}%</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -115,15 +122,25 @@
|
||||
</div>
|
||||
|
||||
<!-- 진행률 바 -->
|
||||
@php
|
||||
$projTaskStats = $project->task_stats;
|
||||
$projTaskTotal = $projTaskStats['total'] ?? 0;
|
||||
$projTaskDone = $projTaskStats['done'] ?? 0;
|
||||
$projTaskInProgress = $projTaskStats['in_progress'] ?? 0;
|
||||
$projDonePct = $projTaskTotal > 0 ? round(($projTaskDone / $projTaskTotal) * 100) : 0;
|
||||
$projInProgressPct = $projTaskTotal > 0 ? round((($projTaskDone + $projTaskInProgress) / $projTaskTotal) * 100) : 0;
|
||||
@endphp
|
||||
<div class="mb-4">
|
||||
<div class="flex justify-between text-sm text-gray-600 mb-1">
|
||||
<span>진행률</span>
|
||||
<span>{{ $project->progress }}%</span>
|
||||
<span>{{ $projInProgressPct }}%</span>
|
||||
</div>
|
||||
<div class="w-full bg-gray-200 rounded-full h-2">
|
||||
<div class="h-2 rounded-full transition-all duration-300
|
||||
{{ $project->progress >= 80 ? 'bg-green-500' : ($project->progress >= 50 ? 'bg-blue-500' : 'bg-yellow-500') }}"
|
||||
style="width: {{ $project->progress }}%"></div>
|
||||
<div class="w-full bg-gray-200 rounded-full h-2 relative overflow-hidden">
|
||||
<div class="absolute h-2 rounded-full bg-blue-400 transition-all duration-300" style="width: {{ $projInProgressPct }}%"></div>
|
||||
<div class="absolute h-2 rounded-full bg-green-500 transition-all duration-300" style="width: {{ $projDonePct }}%"></div>
|
||||
</div>
|
||||
<div class="flex justify-between text-xs text-gray-400 mt-1">
|
||||
<span>완료 {{ $projDonePct }}% + 진행 {{ $projInProgressPct - $projDonePct }}%</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -131,24 +148,26 @@
|
||||
<div class="flex gap-6 text-sm">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="text-gray-500">작업:</span>
|
||||
<span class="font-medium">{{ $project->tasks_count ?? 0 }}개</span>
|
||||
@php
|
||||
$taskStats = $project->task_status_counts;
|
||||
@endphp
|
||||
@if(!empty($taskStats))
|
||||
<span class="text-xs text-gray-400">
|
||||
(할일 {{ $taskStats['todo'] ?? 0 }} / 진행 {{ $taskStats['in_progress'] ?? 0 }} / 완료 {{ $taskStats['done'] ?? 0 }})
|
||||
</span>
|
||||
@endif
|
||||
<span class="font-medium">{{ $projTaskTotal }}개</span>
|
||||
<div class="flex gap-1 text-xs">
|
||||
<span class="px-1.5 py-0.5 bg-blue-100 text-blue-700 rounded">{{ $projTaskInProgress }}</span>
|
||||
<span class="px-1.5 py-0.5 bg-green-100 text-green-700 rounded">{{ $projTaskDone }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="text-gray-500">이슈:</span>
|
||||
@php
|
||||
$openIssues = $project->issues->filter(fn($i) => in_array($i->status, ['open', 'in_progress']))->count();
|
||||
$issueStats = $project->issue_stats;
|
||||
$openIssues = ($issueStats['open'] ?? 0) + ($issueStats['in_progress'] ?? 0);
|
||||
@endphp
|
||||
<span class="font-medium {{ $openIssues > 0 ? 'text-red-600' : 'text-gray-900' }}">
|
||||
{{ $openIssues }}개 열림
|
||||
</span>
|
||||
<div class="flex gap-1 text-xs">
|
||||
<span class="px-1.5 py-0.5 bg-red-100 text-red-700 rounded">{{ $issueStats['open'] ?? 0 }}</span>
|
||||
<span class="px-1.5 py-0.5 bg-yellow-100 text-yellow-700 rounded">{{ $issueStats['in_progress'] ?? 0 }}</span>
|
||||
<span class="px-1.5 py-0.5 bg-green-100 text-green-700 rounded">{{ $issueStats['resolved'] ?? 0 }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,21 +2,30 @@
|
||||
<table class="min-w-full divide-y divide-gray-200">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th class="px-6 py-3 text-left text-sm font-semibold text-gray-700 uppercase tracking-wider">ID</th>
|
||||
<th class="px-4 py-3 text-center text-sm font-semibold text-gray-700 uppercase tracking-wider w-16">#</th>
|
||||
<th class="px-4 py-3 text-left text-sm font-semibold text-gray-700 uppercase tracking-wider">프로젝트명</th>
|
||||
<th class="px-4 py-3 text-center text-sm font-semibold text-gray-700 uppercase tracking-wider">상태</th>
|
||||
<th class="px-4 py-3 text-center text-sm font-semibold text-gray-700 uppercase tracking-wider">진행률</th>
|
||||
<th class="px-4 py-3 text-center text-sm font-semibold text-gray-700 uppercase tracking-wider">작업</th>
|
||||
<th class="px-4 py-3 text-center text-sm font-semibold text-gray-700 uppercase tracking-wider">이슈</th>
|
||||
<th class="px-4 py-3 text-left text-sm font-semibold text-gray-700 uppercase tracking-wider">기간</th>
|
||||
<th class="px-6 py-3 text-right text-sm font-semibold text-gray-700 uppercase tracking-wider">액션</th>
|
||||
<th class="px-4 py-3 text-center text-sm font-semibold text-gray-700 uppercase tracking-wider w-32">액션</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="bg-white divide-y divide-gray-200">
|
||||
@forelse($projects as $project)
|
||||
@php
|
||||
$taskStats = $project->task_stats;
|
||||
$issueStats = $project->issue_stats;
|
||||
$taskTotal = $taskStats['total'] ?? 0;
|
||||
$taskDone = $taskStats['done'] ?? 0;
|
||||
$taskInProgress = $taskStats['in_progress'] ?? 0;
|
||||
$donePct = $taskTotal > 0 ? round(($taskDone / $taskTotal) * 100) : 0;
|
||||
$inProgressPct = $taskTotal > 0 ? round((($taskDone + $taskInProgress) / $taskTotal) * 100) : 0;
|
||||
@endphp
|
||||
<tr class="{{ $project->deleted_at ? 'bg-gray-100' : '' }} hover:bg-gray-50">
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
|
||||
{{ $project->id }}
|
||||
<td class="px-4 py-4 whitespace-nowrap text-sm text-center text-gray-500">
|
||||
{{ $loop->iteration + (($projects->currentPage() - 1) * $projects->perPage()) }}
|
||||
</td>
|
||||
<td class="px-4 py-4 whitespace-nowrap">
|
||||
<a href="{{ route('pm.projects.show', $project->id) }}" class="text-sm font-medium text-gray-900 hover:text-blue-600">
|
||||
@@ -32,20 +41,47 @@
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-4 py-4 whitespace-nowrap">
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="w-20 bg-gray-200 rounded-full h-2">
|
||||
<div class="h-2 rounded-full transition-all duration-300
|
||||
{{ $project->progress >= 80 ? 'bg-green-500' : ($project->progress >= 50 ? 'bg-blue-500' : 'bg-yellow-500') }}"
|
||||
style="width: {{ $project->progress }}%"></div>
|
||||
<div class="flex flex-col gap-1">
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="w-20 bg-gray-200 rounded-full h-2 relative overflow-hidden">
|
||||
<!-- 진행중 (파란색, 뒤에 깔림) -->
|
||||
<div class="absolute h-2 rounded-full bg-blue-400" style="width: {{ $inProgressPct }}%"></div>
|
||||
<!-- 완료 (녹색, 앞에 표시) -->
|
||||
<div class="absolute h-2 rounded-full bg-green-500" style="width: {{ $donePct }}%"></div>
|
||||
</div>
|
||||
<span class="text-xs font-medium text-gray-700">{{ $inProgressPct }}%</span>
|
||||
</div>
|
||||
<div class="flex gap-1 text-xs text-gray-500">
|
||||
<span class="text-green-600">{{ $donePct }}%</span>
|
||||
<span>+</span>
|
||||
<span class="text-blue-600">{{ $inProgressPct - $donePct }}%</span>
|
||||
</div>
|
||||
<span class="text-xs text-gray-600">{{ $project->progress }}%</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-4 py-4 whitespace-nowrap text-sm text-center">
|
||||
<span class="font-medium text-gray-900">{{ $project->tasks_count ?? 0 }}</span>
|
||||
<td class="px-4 py-4 whitespace-nowrap text-center">
|
||||
<div class="flex flex-col items-center gap-1">
|
||||
<span class="font-medium text-gray-900">{{ $taskTotal }}</span>
|
||||
<div class="flex gap-1 text-xs">
|
||||
<span class="px-1.5 py-0.5 bg-blue-100 text-blue-700 rounded">{{ $taskInProgress }}</span>
|
||||
<span class="px-1.5 py-0.5 bg-green-100 text-green-700 rounded">{{ $taskDone }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-4 py-4 whitespace-nowrap text-sm text-center">
|
||||
<span class="font-medium text-gray-900">{{ $project->issues_count ?? 0 }}</span>
|
||||
<td class="px-4 py-4 whitespace-nowrap text-center">
|
||||
@php
|
||||
$issueTotal = $issueStats['total'] ?? 0;
|
||||
$issueOpen = $issueStats['open'] ?? 0;
|
||||
$issueInProgress = $issueStats['in_progress'] ?? 0;
|
||||
$issueResolved = $issueStats['resolved'] ?? 0;
|
||||
@endphp
|
||||
<div class="flex flex-col items-center gap-1">
|
||||
<span class="font-medium text-gray-900">{{ $issueTotal }}</span>
|
||||
<div class="flex gap-1 text-xs">
|
||||
<span class="px-1.5 py-0.5 bg-red-100 text-red-700 rounded">{{ $issueOpen }}</span>
|
||||
<span class="px-1.5 py-0.5 bg-yellow-100 text-yellow-700 rounded">{{ $issueInProgress }}</span>
|
||||
<span class="px-1.5 py-0.5 bg-green-100 text-green-700 rounded">{{ $issueResolved }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||
@if($project->start_date || $project->end_date)
|
||||
@@ -54,35 +90,56 @@
|
||||
-
|
||||
@endif
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
||||
<td class="px-4 py-4 whitespace-nowrap text-center">
|
||||
@if($project->deleted_at)
|
||||
<!-- 삭제된 항목 -->
|
||||
<button onclick="confirmRestore({{ $project->id }}, '{{ $project->name }}')"
|
||||
class="text-green-600 hover:text-green-900 mr-3">
|
||||
복원
|
||||
</button>
|
||||
<button onclick="confirmForceDelete({{ $project->id }}, '{{ $project->name }}')"
|
||||
class="text-red-600 hover:text-red-900">
|
||||
영구삭제
|
||||
</button>
|
||||
<!-- 삭제된 항목 - 슈퍼관리자만 복구/영구삭제 가능 -->
|
||||
@if(auth()->user()?->is_super_admin)
|
||||
<div class="flex justify-center gap-1">
|
||||
<button onclick="confirmRestore({{ $project->id }}, '{{ $project->name }}')"
|
||||
class="p-1.5 text-green-600 hover:text-green-900 hover:bg-green-50 rounded" title="복원">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/>
|
||||
</svg>
|
||||
</button>
|
||||
<button onclick="confirmForceDelete({{ $project->id }}, '{{ $project->name }}')"
|
||||
class="p-1.5 text-red-600 hover:text-red-900 hover:bg-red-50 rounded" title="영구삭제">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
@else
|
||||
<span class="text-gray-400 text-xs">삭제됨</span>
|
||||
@endif
|
||||
@else
|
||||
<!-- 활성 항목 -->
|
||||
<a href="{{ route('pm.projects.show', $project->id) }}"
|
||||
class="text-gray-600 hover:text-gray-900 mr-3">
|
||||
보기
|
||||
</a>
|
||||
<a href="{{ route('pm.projects.edit', $project->id) }}"
|
||||
class="text-blue-600 hover:text-blue-900 mr-3">
|
||||
수정
|
||||
</a>
|
||||
<button onclick="confirmDuplicate({{ $project->id }}, '{{ $project->name }}')"
|
||||
class="text-purple-600 hover:text-purple-900 mr-3">
|
||||
복제
|
||||
</button>
|
||||
<button onclick="confirmDelete({{ $project->id }}, '{{ $project->name }}')"
|
||||
class="text-red-600 hover:text-red-900">
|
||||
삭제
|
||||
</button>
|
||||
<div class="flex justify-center gap-1">
|
||||
<a href="{{ route('pm.projects.show', $project->id) }}"
|
||||
class="p-1.5 text-gray-600 hover:text-gray-900 hover:bg-gray-100 rounded" title="보기">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/>
|
||||
</svg>
|
||||
</a>
|
||||
<a href="{{ route('pm.projects.edit', $project->id) }}"
|
||||
class="p-1.5 text-blue-600 hover:text-blue-900 hover:bg-blue-50 rounded" title="수정">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/>
|
||||
</svg>
|
||||
</a>
|
||||
<button onclick="confirmDuplicate({{ $project->id }}, '{{ $project->name }}')"
|
||||
class="p-1.5 text-purple-600 hover:text-purple-900 hover:bg-purple-50 rounded" title="복제">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"/>
|
||||
</svg>
|
||||
</button>
|
||||
<button onclick="confirmDelete({{ $project->id }}, '{{ $project->name }}')"
|
||||
class="p-1.5 text-red-600 hover:text-red-900 hover:bg-red-50 rounded" title="삭제">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user