fix: 일일 로그 날짜 수정 버그 픽스
- UpdateDailyLogRequest에 log_date 검증 규칙 추가 - DailyLogService.updateDailyLog에 log_date 필드 추가 - 일일 로그 수정 모달에 formatDateForInput 함수 추가 (ISO 형식을 YYYY-MM-DD 형식으로 변환)
This commit is contained in:
@@ -14,6 +14,7 @@ public function authorize(): bool
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'log_date' => ['sometimes', 'date', 'date_format:Y-m-d'],
|
||||
'project_id' => ['nullable', 'integer', 'exists:admin_pm_projects,id'],
|
||||
'summary' => ['nullable', 'string', 'max:5000'],
|
||||
'entries' => ['nullable', 'array'],
|
||||
@@ -29,6 +30,7 @@ public function rules(): array
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'log_date' => '로그 날짜',
|
||||
'project_id' => '프로젝트',
|
||||
'summary' => '요약',
|
||||
'entries' => '항목',
|
||||
|
||||
@@ -130,6 +130,7 @@ public function updateDailyLog(int $id, array $data): AdminPmDailyLog
|
||||
$log = AdminPmDailyLog::findOrFail($id);
|
||||
|
||||
$log->update([
|
||||
'log_date' => $data['log_date'] ?? $log->log_date,
|
||||
'project_id' => $data['project_id'] ?? $log->project_id,
|
||||
'summary' => $data['summary'] ?? $log->summary,
|
||||
'updated_by' => auth()->id(),
|
||||
|
||||
@@ -201,6 +201,13 @@ function nl2br(text) {
|
||||
return escapeHtml(text).replace(/\n/g, '<br>');
|
||||
}
|
||||
|
||||
// ISO 날짜를 YYYY-MM-DD 형식으로 변환
|
||||
function formatDateForInput(dateString) {
|
||||
if (!dateString) return '';
|
||||
// ISO 형식 또는 일반 날짜 문자열에서 YYYY-MM-DD 추출
|
||||
return dateString.substring(0, 10);
|
||||
}
|
||||
|
||||
// 폼 제출 시 HTMX 이벤트 트리거
|
||||
document.getElementById('filterForm').addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
@@ -245,7 +252,7 @@ function editLog(id) {
|
||||
if (data.success) {
|
||||
document.getElementById('modalTitle').textContent = '일일 로그 수정';
|
||||
document.getElementById('logId').value = data.data.id;
|
||||
document.getElementById('logDate').value = data.data.log_date;
|
||||
document.getElementById('logDate').value = formatDateForInput(data.data.log_date);
|
||||
document.getElementById('projectId').value = data.data.project_id || '';
|
||||
document.getElementById('summary').value = data.data.summary || '';
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none foc
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">일일 요약</label>
|
||||
<textarea id="summary"
|
||||
name="summary"
|
||||
rows="2"
|
||||
rows="8"
|
||||
placeholder="오늘의 주요 활동 요약..."
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"></textarea>
|
||||
</div>
|
||||
@@ -91,4 +91,4 @@ class="px-4 py-2 text-white bg-blue-600 rounded-lg hover:bg-blue-700 transition"
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user