fix(tksafety): 작업별 항목 표시 안 되는 버그 — check_type 'task' vs 'work_type' 불일치 수정

DB에 저장된 check_type='task'를 프론트에서 'work_type'으로 필터링하여 매칭 0건.
HTML option value와 JS 필터를 모두 'task'로 통일.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-03-13 21:13:20 +09:00
parent 07aac305d6
commit 1abdb92a71
2 changed files with 8 additions and 8 deletions

View File

@@ -110,7 +110,7 @@
<select id="itemType" class="input-field w-full px-3 py-2 rounded-lg text-sm" required>
<option value="basic">기본</option>
<option value="weather">날씨별</option>
<option value="work_type">작업별</option>
<option value="task">작업별</option>
</select>
</div>
<!-- 날씨 조건 (weather type only) -->
@@ -162,7 +162,7 @@
</div>
<script src="/static/js/tksafety-core.js?v=3"></script>
<script src="/static/js/tksafety-checklist.js?v=2"></script>
<script src="/static/js/tksafety-checklist.js?v=3"></script>
<script>initChecklistPage();</script>
</body>
</html>

View File

@@ -137,7 +137,7 @@ function renderWeatherItems() {
/* ===== Render worktype items (2-level: work_type → task) ===== */
function renderWorktypeItems() {
const items = checklistItems.filter(i => i.item_type === 'work_type');
const items = checklistItems.filter(i => i.item_type === 'task');
const container = document.getElementById('worktypeItemsList');
if (!items.length) {
container.innerHTML = '<div class="text-center text-gray-400 py-8">작업별 항목이 없습니다</div>';
@@ -208,7 +208,7 @@ function openAddItem(tab) {
document.getElementById('itemDisplayOrder').value = '0';
// Set type based on tab
const typeMap = { basic: 'basic', weather: 'weather', worktype: 'work_type' };
const typeMap = { basic: 'basic', weather: 'weather', worktype: 'task' };
document.getElementById('itemType').value = typeMap[tab] || 'basic';
toggleTypeFields();
@@ -251,9 +251,9 @@ function closeItemModal() {
function toggleTypeFields() {
const type = document.getElementById('itemType').value;
document.getElementById('weatherConditionField').classList.toggle('hidden', type !== 'weather');
document.getElementById('workTypeField').classList.toggle('hidden', type !== 'work_type');
// Hide task field when type changes away from work_type
if (type !== 'work_type') {
document.getElementById('workTypeField').classList.toggle('hidden', type !== 'task');
// Hide task field when type changes away from task
if (type !== 'task') {
document.getElementById('taskField').classList.add('hidden');
} else {
// Show task field if work type is already selected
@@ -281,7 +281,7 @@ async function submitItem(e) {
data.weather_condition_id = parseInt(document.getElementById('itemWeatherCondition').value) || null;
if (!data.weather_condition_id) { showToast('날씨 조건을 선택해주세요', 'error'); return; }
}
if (data.item_type === 'work_type') {
if (data.item_type === 'task') {
const taskId = parseInt(document.getElementById('itemTask').value) || null;
if (!taskId) { showToast('작업을 선택해주세요', 'error'); return; }
data.task_id = taskId;