Files
sam-manage/resources/views/posts/show.blade.php
hskwon 5c892c1ed9 브라우저 alert/confirm을 SweetAlert2로 전환
- layouts/app.blade.php에 SweetAlert2 CDN 및 전역 헬퍼 함수 추가
  - showToast(): 토스트 알림 (success, error, warning, info)
  - showConfirm(): 확인 대화상자
  - showDeleteConfirm(): 삭제 확인 (경고 아이콘)
  - showPermanentDeleteConfirm(): 영구 삭제 확인 (빨간색 경고)
  - showSuccess(), showError(): 성공/에러 알림

- 변환된 파일 목록 (48개 Blade 파일):
  - menus/* (6개), boards/* (2개), posts/* (3개)
  - daily-logs/* (3개), project-management/* (6개)
  - dev-tools/flow-tester/* (6개)
  - quote-formulas/* (4개), permission-analyze/* (1개)
  - archived-records/* (1개), profile/* (1개)
  - roles/* (3개), permissions/* (3개)
  - departments/* (3개), tenants/* (3개), users/* (3개)

- 주요 개선사항:
  - Tailwind CSS 테마와 일관된 디자인
  - 비동기 콜백 패턴으로 리팩토링
  - 삭제/복원/영구삭제 각각 다른 스타일 적용
2025-12-05 09:49:56 +09:00

171 lines
7.9 KiB
PHP

@extends('layouts.app')
@section('title', $post->title)
@section('content')
<!-- 페이지 헤더 -->
<div class="flex justify-between items-center mb-6">
<div>
<p class="text-sm text-gray-500">{{ $board->name }}</p>
<h1 class="text-2xl font-bold text-gray-800 mt-1">
@if($post->is_notice)
<span class="inline-flex items-center px-2 py-0.5 rounded text-sm font-medium bg-blue-100 text-blue-800 mr-2">
공지
</span>
@endif
@if($post->is_secret)
<svg class="w-5 h-5 inline-block text-gray-400 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"/>
</svg>
@endif
{{ $post->title }}
</h1>
</div>
<a href="{{ route('boards.posts.index', $board) }}" class="text-gray-600 hover:text-gray-900">
&larr; 목록으로
</a>
</div>
<!-- 게시글 정보 -->
<div class="bg-white rounded-lg shadow-sm overflow-hidden">
<!-- 메타 정보 -->
<div class="px-6 py-4 border-b border-gray-200 bg-gray-50">
<div class="flex items-center justify-between text-sm text-gray-500">
<div class="flex items-center gap-6">
<span>
<span class="font-medium text-gray-700">작성자:</span>
{{ $post->author?->name ?? '알 수 없음' }}
</span>
<span>
<span class="font-medium text-gray-700">작성일:</span>
{{ $post->created_at->format('Y-m-d H:i') }}
</span>
<span>
<span class="font-medium text-gray-700">조회:</span>
{{ number_format($post->views) }}
</span>
</div>
@if($post->user_id === auth()->id() || auth()->user()->hasRole(['admin', 'super-admin']))
<div class="flex items-center gap-2">
<a href="{{ route('boards.posts.edit', [$board, $post]) }}"
class="px-3 py-1 text-sm text-blue-600 hover:text-blue-800 border border-blue-300 rounded hover:bg-blue-50 transition">
수정
</a>
<form id="deletePostForm" action="{{ route('boards.posts.destroy', [$board, $post]) }}" method="POST">
@csrf
@method('DELETE')
<button type="button" onclick="confirmDeletePost()"
class="px-3 py-1 text-sm text-red-600 hover:text-red-800 border border-red-300 rounded hover:bg-red-50 transition">
삭제
</button>
</form>
<script>
function confirmDeletePost() {
showDeleteConfirm('이 게시글', () => {
document.getElementById('deletePostForm').submit();
});
}
</script>
</div>
@endif
</div>
</div>
<!-- 커스텀 필드 -->
@if(!empty($customFieldValues))
<div class="px-6 py-4 border-b border-gray-200 bg-gray-50">
<div class="grid grid-cols-3 gap-4 text-sm">
@foreach($board->fields as $field)
@if(isset($customFieldValues[$field->field_key]))
<div>
<span class="font-medium text-gray-700">{{ $field->name }}:</span>
<span class="text-gray-600 ml-1">{{ $customFieldValues[$field->field_key] }}</span>
</div>
@endif
@endforeach
</div>
</div>
@endif
<!-- 본문 -->
<div class="px-6 py-8">
<div class="prose max-w-none">
{!! nl2br(e($post->content)) !!}
</div>
</div>
<!-- 첨부파일 -->
@if($post->files->isNotEmpty())
<div class="px-6 py-4 border-t border-gray-200 bg-gray-50">
<h3 class="text-sm font-medium text-gray-700 mb-3">
첨부파일 ({{ $post->files->count() }})
</h3>
<div class="space-y-2">
@foreach($post->files as $file)
<div class="flex items-center justify-between px-4 py-3 bg-white rounded-lg border border-gray-200">
<div class="flex items-center gap-3">
@if($file->isImage())
<svg class="w-5 h-5 text-green-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"/>
</svg>
@else
<svg class="w-5 h-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
</svg>
@endif
<div>
<span class="text-sm text-gray-900">{{ $file->display_name ?? $file->original_name }}</span>
<span class="text-xs text-gray-400 ml-2">({{ $file->getFormattedSize() }})</span>
</div>
</div>
<a href="{{ route('boards.posts.files.download', [$board, $post, $file->id]) }}"
class="px-3 py-1 text-sm text-blue-600 hover:text-blue-800 border border-blue-300 rounded hover:bg-blue-50 transition">
다운로드
</a>
</div>
@endforeach
</div>
</div>
@endif
</div>
<!-- 이전/다음 네비게이션 -->
<div class="mt-6 bg-white rounded-lg shadow-sm overflow-hidden">
<div class="divide-y divide-gray-200">
@if($adjacent['prev'])
<a href="{{ route('boards.posts.show', [$board, $adjacent['prev']->id]) }}"
class="block px-6 py-4 hover:bg-gray-50 transition">
<div class="flex items-center">
<span class="text-sm text-gray-500 w-20">이전글</span>
<span class="text-gray-900">{{ $adjacent['prev']->title }}</span>
</div>
</a>
@endif
@if($adjacent['next'])
<a href="{{ route('boards.posts.show', [$board, $adjacent['next']->id]) }}"
class="block px-6 py-4 hover:bg-gray-50 transition">
<div class="flex items-center">
<span class="text-sm text-gray-500 w-20">다음글</span>
<span class="text-gray-900">{{ $adjacent['next']->title }}</span>
</div>
</a>
@endif
</div>
</div>
<!-- 목록 버튼 -->
<div class="mt-6 flex justify-center">
<a href="{{ route('boards.posts.index', $board) }}"
class="px-6 py-2 bg-gray-100 hover:bg-gray-200 text-gray-700 rounded-lg transition">
목록
</a>
</div>
<!-- 알림 메시지 -->
@if(session('success'))
<div class="fixed bottom-4 right-4 bg-green-500 text-white px-6 py-3 rounded-lg shadow-lg" id="toast">
{{ session('success') }}
</div>
<script>setTimeout(() => document.getElementById('toast')?.remove(), 3000);</script>
@endif
@endsection