Files
sam-manage/resources/views/project-management/projects/edit.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

129 lines
5.0 KiB
PHP

@extends('layouts.app')
@section('title', '프로젝트 수정')
@section('content')
<!-- 페이지 헤더 -->
<div class="flex items-center gap-4 mb-6">
<a href="{{ route('pm.projects.show', $project->id) }}" class="text-gray-500 hover:text-gray-700">
프로젝트 상세
</a>
<h1 class="text-2xl font-bold text-gray-800">✏️ 프로젝트 수정</h1>
</div>
<!-- -->
<div class="bg-white rounded-lg shadow-sm p-6 max-w-2xl">
<form id="projectForm">
<!-- 프로젝트명 -->
<div class="mb-6">
<label for="name" class="block text-sm font-medium text-gray-700 mb-2">
프로젝트명 <span class="text-red-500">*</span>
</label>
<input type="text"
id="name"
name="name"
required
value="{{ $project->name }}"
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
placeholder="프로젝트 이름을 입력하세요">
</div>
<!-- 설명 -->
<div class="mb-6">
<label for="description" class="block text-sm font-medium text-gray-700 mb-2">
설명
</label>
<textarea id="description"
name="description"
rows="4"
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
placeholder="프로젝트 설명을 입력하세요">{{ $project->description }}</textarea>
</div>
<!-- 상태 -->
<div class="mb-6">
<label for="status" class="block text-sm font-medium text-gray-700 mb-2">
상태
</label>
<select id="status"
name="status"
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
@foreach($statuses as $value => $label)
<option value="{{ $value }}" {{ $project->status === $value ? 'selected' : '' }}>{{ $label }}</option>
@endforeach
</select>
</div>
<!-- 기간 -->
<div class="grid grid-cols-2 gap-4 mb-6">
<div>
<label for="start_date" class="block text-sm font-medium text-gray-700 mb-2">
시작일
</label>
<input type="date"
id="start_date"
name="start_date"
value="{{ $project->start_date?->format('Y-m-d') }}"
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label for="end_date" class="block text-sm font-medium text-gray-700 mb-2">
종료일
</label>
<input type="date"
id="end_date"
name="end_date"
value="{{ $project->end_date?->format('Y-m-d') }}"
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
</div>
<!-- 버튼 -->
<div class="flex gap-4">
<button type="submit"
class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg transition">
저장
</button>
<a href="{{ route('pm.projects.show', $project->id) }}"
class="bg-gray-300 hover:bg-gray-400 text-gray-700 px-6 py-2 rounded-lg transition">
취소
</a>
</div>
</form>
</div>
@endsection
@push('scripts')
<script>
document.getElementById('projectForm').addEventListener('submit', async function(e) {
e.preventDefault();
const formData = new FormData(this);
const data = Object.fromEntries(formData.entries());
try {
const response = await fetch('/api/admin/pm/projects/{{ $project->id }}', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}',
'Accept': 'application/json'
},
body: JSON.stringify(data)
});
const result = await response.json();
if (result.success) {
showToast(result.message, 'success');
window.location.href = '{{ route('pm.projects.show', $project->id) }}';
} else {
showToast(result.message || '저장에 실패했습니다.', 'error');
}
} catch (error) {
console.error('Error:', error);
showToast('저장 중 오류가 발생했습니다.', 'error');
}
});
</script>
@endpush