fix: show names in admin tag panel

This commit is contained in:
Marcel
2026-03-15 21:08:06 +00:00
parent c2625657e2
commit 62189d8bb3
3 changed files with 5 additions and 10 deletions

View File

@@ -59,11 +59,8 @@ public class TagController {
} }
@GetMapping @GetMapping
public List<String> searchTags(@RequestParam(defaultValue = "") String query) { public List<Tag> searchTags(@RequestParam(defaultValue = "") String query) {
return tagRepository.findByNameContainingIgnoreCase(query) return tagRepository.findByNameContainingIgnoreCase(query);
.stream()
.map(Tag::getName)
.toList();
} }
} }

View File

@@ -14,12 +14,12 @@
return; return;
} }
try { try {
console.log('fetch tags')
const res = await fetch(`/api/tags?query=${encodeURIComponent(query)}`); const res = await fetch(`/api/tags?query=${encodeURIComponent(query)}`);
if (res.ok) { if (res.ok) {
const data = await res.json(); const data = await res.json();
// Filter out tags already selected // API returns Tag objects with { id, name }
suggestions = data.filter((t: string) => !tags.includes(t)); const names: string[] = data.map((t: { name: string }) => t.name);
suggestions = names.filter((t) => !tags.includes(t));
showSuggestions = true; showSuggestions = true;
} }
} catch (e) { } catch (e) {
@@ -43,7 +43,6 @@
} }
function handleKeydown(e: KeyboardEvent) { function handleKeydown(e: KeyboardEvent) {
console.log("keydown",e)
if (e.key === 'Enter') { if (e.key === 'Enter') {
e.preventDefault(); e.preventDefault();
if (activeIndex >= 0 && suggestions[activeIndex]) { if (activeIndex >= 0 && suggestions[activeIndex]) {

View File

@@ -4,7 +4,6 @@
export let data; export let data;
export let form; export let form;
console.log(data)
let activeTab = 'users'; let activeTab = 'users';
let editingTagId: string | null = null; let editingTagId: string | null = null;