Files
sam-manage/resources/views/item-fields/partials/custom-fields.blade.php
hskwon c1bd7ab4d3 품목기준 필드 관리 기능 구현
- ItemField 모델 및 SystemFieldDefinitions 상수 클래스 추가
- ItemFieldSeedingService: 시스템 필드 시딩/초기화/커스텀 필드 CRUD
- ItemFieldController (API): HTMX 기반 시딩 상태, 커스텀 필드 관리
- 커스텀 필드 수정 기능 (시스템 필드는 source_table/field_key 수정 불가)
- 레거시 데이터 표시 개선: 소스 테이블 비어있으면 '미지정' 배지
- 필드 키 정책 변경: 숫자로 시작 허용 (영문/숫자/밑줄)
- AI 문의하기: 시딩 오류 보고서 생성 기능
- 사이드바에 품목기준 필드 관리 메뉴 추가
2025-12-09 23:13:27 +09:00

116 lines
6.0 KiB
PHP

@if(isset($error))
<div class="p-8 text-center">
<div class="text-yellow-600 mb-2">
<svg class="w-12 h-12 mx-auto" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
</svg>
</div>
<p class="text-gray-600">{{ $error }}</p>
</div>
@elseif($fields->isEmpty())
<div class="p-8 text-center text-gray-500">
<div class="mb-2">
<svg class="w-12 h-12 mx-auto text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4" />
</svg>
</div>
<p>커스텀 필드가 없습니다.</p>
<p class="text-xs mt-1"> 커스텀 필드를 추가해보세요.</p>
</div>
@else
<table class="w-full">
<thead class="bg-gray-50 border-b border-gray-200">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">소스 테이블</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">필드 </th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">필드명</th>
<th class="px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider">타입</th>
<th class="px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider">필수</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">기본값</th>
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">액션</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
@foreach($fields as $field)
<tr class="hover:bg-gray-50">
<td class="px-6 py-4">
@if(empty($field->source_table))
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-600">
미지정
</span>
@else
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
{{ $sourceTables[$field->source_table] ?? $field->source_table }}
</span>
@endif
</td>
<td class="px-6 py-4">
@if(empty($field->field_key))
<span class="text-gray-400 text-sm">미지정</span>
@else
<code class="text-sm text-gray-700 bg-gray-100 px-2 py-1 rounded">{{ $field->field_key }}</code>
@endif
</td>
<td class="px-6 py-4 font-medium text-gray-900">
{{ $field->field_name }}
</td>
<td class="px-6 py-4 text-center">
@php
$typeLabels = [
'textbox' => '텍스트',
'number' => '숫자',
'dropdown' => '드롭다운',
'checkbox' => '체크박스',
'date' => '날짜',
'textarea' => '텍스트영역',
];
@endphp
<span class="text-sm text-gray-500">
{{ $typeLabels[$field->field_type] ?? $field->field_type }}
</span>
</td>
<td class="px-6 py-4 text-center">
@if($field->is_required)
<span class="text-green-600">
<svg class="w-5 h-5 inline" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd" />
</svg>
</span>
@else
<span class="text-gray-300">-</span>
@endif
</td>
<td class="px-6 py-4 text-sm text-gray-500">
{{ $field->default_value ?? '-' }}
</td>
<td class="px-6 py-4 text-right">
<div class="flex justify-end gap-2">
<button onclick="openEditModal({{ json_encode($field) }})"
class="text-blue-600 hover:text-blue-800 text-sm font-medium">
수정
</button>
<button onclick="deleteCustomField({{ $field->id }}, '{{ $field->field_name }}')"
class="text-red-600 hover:text-red-800 text-sm font-medium">
삭제
</button>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
<!-- 요약 정보 -->
<div class="px-6 py-4 bg-gray-50 border-t border-gray-200">
<div class="text-sm text-gray-600">
{{ $fields->count() }}개의 커스텀 필드
@php
$unassignedCount = $fields->filter(fn($f) => empty($f->source_table))->count();
@endphp
@if($unassignedCount > 0)
<span class="text-yellow-600">(미지정: {{ $unassignedCount }})</span>
@endif
</div>
</div>
@endif