feat: 작가앱에 작품 제목 수정 기능 추가

- 백엔드 PUT /api/writer/works/:id는 이미 title 갱신을 지원했으나 프론트에 버튼이 없었음
- 헤더에 "✏️ 제목 수정" 버튼 추가, 작품 선택 시에만 표시

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PppKcQmeTJDQCpfcgKietu
This commit is contained in:
kim
2026-09-15 12:00:17 +09:00
co-authored by Claude Sonnet 5
parent e3f038617d
commit 145f4e698f
+18 -1
View File
@@ -162,6 +162,7 @@ body{background:var(--bg);color:var(--text);font-family:system-ui,sans-serif;dis
<option value="">작품을 선택하세요...</option>
</select>
<button class="hdr-btn" onclick="createWork()">+ 새 작품</button>
<button class="hdr-btn" onclick="renameCurrentWork()" id="work-rename-btn" style="display:none">✏️ 제목 수정</button>
<button class="hdr-btn" onclick="deleteCurrentWork()" id="work-del-btn" style="display:none">삭제</button>
<span class="work-meta" id="work-meta"></span>
<div class="hdr-sp"></div>
@@ -562,6 +563,21 @@ async function createWork(){
}catch(e){ showToast('오류: '+e.message,true); }
}
async function renameCurrentWork(){
if(!CURRENT) return;
const title=prompt('새 작품 제목',CURRENT.title);
if(!title||!title.trim()||title.trim()===CURRENT.title) return;
try{
const r=await fetch('/api/writer/works/'+CURRENT.id,{method:'PUT',headers:authH({'Content-Type':'application/json'}),body:JSON.stringify({title})});
const d=await r.json();
if(!d.success) throw new Error(d.error||'수정 실패');
CURRENT.title=title.trim();
await loadWorks();
document.getElementById('work-sel').value=CURRENT.id;
showToast('제목이 변경되었습니다');
}catch(e){ showToast('오류: '+e.message,true); }
}
async function deleteCurrentWork(){
if(!CURRENT) return;
if(!confirm(`"${CURRENT.title}"을(를) 삭제할까요? 딸린 노트도 함께 삭제됩니다.`)) return;
@@ -580,7 +596,7 @@ async function onWorkSelect(){
resetChat();
discardCompose();
document.getElementById('compose-prompt').value='';
if(!id){ CURRENT=null; document.getElementById('draft').value=''; writeElements({}); setWriteView('draft'); document.getElementById('work-del-btn').style.display='none'; return; }
if(!id){ CURRENT=null; document.getElementById('draft').value=''; writeElements({}); setWriteView('draft'); document.getElementById('work-del-btn').style.display='none'; document.getElementById('work-rename-btn').style.display='none'; return; }
try{
const r=await fetch('/api/writer/works/'+id,{headers:authH()});
const d=await r.json();
@@ -592,6 +608,7 @@ async function onWorkSelect(){
setWriteView('draft');
document.querySelectorAll('.genre-btn').forEach(b=>b.classList.toggle('active',b.dataset.g===CURRENT.genre));
document.getElementById('work-del-btn').style.display='';
document.getElementById('work-rename-btn').style.display='';
updateWorkMeta();
if(currentTab==='notes') loadNotes();
if(currentTab==='stats') renderStats();