From ec5f9cf92d6553d8b80b313ef0628e44759dce8b Mon Sep 17 00:00:00 2001 From: MedMan Dev Date: Fri, 30 Oct 2026 15:59:15 +0000 Subject: Add tag rename (pen icon) with PATCH endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Pen icon (✎) next to the remove (×) on each tag in the left menu - Opens a dialog with a text input for the new name - New PATCH /api/tags/ endpoint renames the tag and merges duplicates (moves all ftags to an existing tag if name collides) - All tagged items reflect the rename immediately --- templates/index.html | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'templates/index.html') diff --git a/templates/index.html b/templates/index.html index 0e577f2..1b9cbe7 100644 --- a/templates/index.html +++ b/templates/index.html @@ -69,6 +69,8 @@ main { flex:1; display:flex; overflow:hidden; min-height:0; } .tc.sel { border-color:#fff; background:var(--accent); color:#000; } .tc .rm { font-size:0.6rem; opacity:0.4; cursor:pointer; margin-left:1px; } .tc .rm:hover { opacity:1; } +.tc .rename { font-size:0.6rem; opacity:0.4; cursor:pointer; margin-left:1px; } +.tc .rename:hover { opacity:1; } .ti-row { display:flex; gap:3px; margin-top:6px; } .ti-row input { flex:1; background:var(--bg); border:1px solid var(--border); border-radius:4px; padding:4px 6px; color:var(--text); font-size:0.72rem; } .ti-row button { background:var(--accent); color:#000; border:none; border-radius:4px; padding:4px 8px; cursor:pointer; font-weight:600; font-size:0.72rem; } @@ -366,15 +368,52 @@ function rTagList(){ let l=document.getElementById('tag-list'); l.innerHTML=S.tags.map(t=>{ let sel=S.stags.includes(t.name)?'sel':''; - return `${t.name}×`; + return `${t.name}✎×`; }).join(''); l.querySelectorAll('.tc').forEach(c=>{c.addEventListener('click',e=>{ - if(e.target.classList.contains('rm'))return; + if(e.target.classList.contains('rm')||e.target.classList.contains('rename'))return; toggleSearchTag(c.dataset.tag); });}); l.querySelectorAll('.rm').forEach(b=>{b.addEventListener('click',async e=>{ e.stopPropagation(); await api(`/api/tags/${b.dataset.tid}`,{method:'DELETE'}); await lt(); if(S.files.length) await reloadFiles(); st('Tag gelöscht'); });}); + l.querySelectorAll('.rename').forEach(b=>{b.addEventListener('click',e=>{ + e.stopPropagation(); renameTagDialog(parseInt(b.dataset.tid)); + });}); +} + +// ── Rename tag dialog ──────────────────────────────────────────────────── +function renameTagDialog(tid){ + let tag=S.tags.find(t=>t.id===tid); + if(!tag)return; + document.getElementById('m-body').innerHTML= + `

Tag umbenennen

+
Aktuell: ${tag.name}
+
+ +
+
+ + +
`; + document.getElementById('prev-modal').classList.add('on'); + let inp=document.getElementById('rename-in'); + inp.focus(); inp.select(); + async function doRename(){ + let n=inp.value.trim(); + if(!n){st('Name erforderlich');return;} + await api(`/api/tags/${tid}`,{method:'PATCH',headers:{'Content-Type':'application/json'},body:JSON.stringify({name:n})}); + document.getElementById('prev-modal').classList.remove('on'); + st('Tag umbenannt'); + await lt(); + if(S.files.length) await reloadFiles(); + } + document.getElementById('rename-go').onclick=doRename; + document.getElementById('rename-cancel').onclick=()=>document.getElementById('prev-modal').classList.remove('on'); + inp.addEventListener('keydown',e=>{ + if(e.key==='Enter'){e.preventDefault();doRename();} + else if(e.key==='Escape'){document.getElementById('prev-modal').classList.remove('on');} + }); } function toggleSearchTag(name){ -- cgit v1.2.3