Fix: PDF 매칭 드롭다운 값 바인딩 문제 해결

- Alpine.js에서 :value="null"이 문자열로 변환되는 문제 수정
- option value를 빈 문자열("")로 변경
- JavaScript에서 null 값을 빈 문자열로 변환하여 UI 바인딩 개선
- 저장 시 빈 문자열과 null 모두 처리하도록 수정
This commit is contained in:
Hyungi Ahn
2025-09-03 18:35:50 +09:00
parent 77c18d31a9
commit e983d01a83
2 changed files with 7 additions and 2 deletions

View File

@@ -150,7 +150,7 @@
<select x-model="doc.matched_pdf_id"
:class="doc.matched_pdf_id ? 'border-green-300 bg-green-50' : 'border-gray-300'"
class="w-full px-3 py-2 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm">
<option :value="null">PDF 매칭 없음</option>
<option value="">PDF 매칭 없음</option>
<template x-for="pdf in availablePDFs" :key="pdf.id">
<option :value="pdf.id" x-text="pdf.title"></option>
</template>

View File

@@ -95,6 +95,11 @@ window.bookEditorApp = () => ({
console.log(`📄 문서 ${index + 1}: ${doc.title}`);
console.log(` - matched_pdf_id: ${doc.matched_pdf_id || 'null'}`);
console.log(` - sort_order: ${doc.sort_order || 'null'}`);
// null 값을 빈 문자열로 변환 (UI 바인딩을 위해)
if (doc.matched_pdf_id === null) {
doc.matched_pdf_id = "";
}
});
// 사용 가능한 PDF 문서들 로드 (현재 서적의 PDF만)
@@ -237,7 +242,7 @@ window.bookEditorApp = () => ({
return window.api.updateDocument(doc.id, {
sort_order: doc.sort_order,
matched_pdf_id: doc.matched_pdf_id === "" ? null : doc.matched_pdf_id
matched_pdf_id: doc.matched_pdf_id === "" || doc.matched_pdf_id === null ? null : doc.matched_pdf_id
});
});