feat: PDF 매칭 필터링 및 서적 정보 UI 개선

- 서적 편집 페이지에서 PDF 매칭 드롭다운이 현재 서적의 PDF만 표시하도록 수정
- PDF 관리 페이지에 서적 정보 표시 UI 추가
- 타입 안전한 비교로 book_id 필터링 개선
- PDF 통계 카드에 서적별 분류 추가
- 필터 기능에 '서적 포함' 옵션 추가
- 디버깅 로그 추가로 문제 추적 개선

주요 변경사항:
- book-editor.js: String() 타입 변환으로 안전한 book_id 비교
- pdf-manager.html/js: 서적 정보 배지 및 통계 카드 추가
- book-documents.js: HTML 문서 필터링 로직 개선
This commit is contained in:
Hyungi Ahn
2025-08-26 15:32:46 +09:00
parent 04ae64fc4d
commit 8d7f4c04bb
17 changed files with 3398 additions and 400 deletions

View File

@@ -5,7 +5,7 @@ window.pdfManagerApp = () => ({
allDocuments: [],
loading: false,
error: '',
filterType: 'all', // 'all', 'linked', 'standalone'
filterType: 'all', // 'all', 'book', 'linked', 'standalone'
// 인증 상태
isAuthenticated: false,
@@ -66,7 +66,7 @@ window.pdfManagerApp = () => ({
(doc.html_path === null && doc.pdf_path) // PDF만 업로드된 경우
);
// 연결 상태 확인
// 연결 상태 및 서적 정보 확인
this.pdfDocuments.forEach(pdf => {
// 이 PDF를 참조하는 다른 문서가 있는지 확인
const linkedDocuments = this.allDocuments.filter(doc =>
@@ -74,9 +74,27 @@ window.pdfManagerApp = () => ({
);
pdf.isLinked = linkedDocuments.length > 0;
pdf.linkedDocuments = linkedDocuments;
// 서적 정보 추가 (PDF가 속한 서적 또는 연결된 문서의 서적)
if (pdf.book_title) {
// PDF 자체가 서적에 속한 경우
pdf.book_title = pdf.book_title;
} else if (linkedDocuments.length > 0) {
// 연결된 문서가 있는 경우, 첫 번째 연결 문서의 서적 정보 사용
const firstLinked = linkedDocuments[0];
pdf.book_title = firstLinked.book_title;
}
});
console.log('📕 PDF 문서들:', this.pdfDocuments.length, '개');
console.log('📚 서적 포함 PDF:', this.bookPDFs, '개');
console.log('🔗 HTML 연결 PDF:', this.linkedPDFs, '개');
console.log('📄 독립 PDF:', this.standalonePDFs, '개');
// 디버깅: PDF 서적 정보 확인
this.pdfDocuments.slice(0, 5).forEach(pdf => {
console.log(`📋 ${pdf.title}: 서적=${pdf.book_title || '없음'}, 연결=${pdf.isLinked ? '예' : '아니오'}`);
});
} catch (error) {
console.error('PDF 로드 실패:', error);
@@ -90,22 +108,28 @@ window.pdfManagerApp = () => ({
// 필터링된 PDF 목록
get filteredPDFs() {
switch (this.filterType) {
case 'book':
return this.pdfDocuments.filter(pdf => pdf.book_title);
case 'linked':
return this.pdfDocuments.filter(pdf => pdf.isLinked);
case 'standalone':
return this.pdfDocuments.filter(pdf => !pdf.isLinked);
return this.pdfDocuments.filter(pdf => !pdf.isLinked && !pdf.book_title);
default:
return this.pdfDocuments;
}
},
// 통계 계산
get bookPDFs() {
return this.pdfDocuments.filter(pdf => pdf.book_title).length;
},
get linkedPDFs() {
return this.pdfDocuments.filter(pdf => pdf.isLinked).length;
},
get standalonePDFs() {
return this.pdfDocuments.filter(pdf => !pdf.isLinked).length;
return this.pdfDocuments.filter(pdf => !pdf.isLinked && !pdf.book_title).length;
},
// PDF 새로고침