diff --git a/frontend/src/pages/Sources.jsx b/frontend/src/pages/Sources.jsx index e6d5c0f..4d40b5e 100644 --- a/frontend/src/pages/Sources.jsx +++ b/frontend/src/pages/Sources.jsx @@ -308,6 +308,7 @@ export function PaperlessPicker({ context, placement, chapterId = "", chapterTit const [pending, setPending] = useState(false); const [error, setError] = useState(""); // The filters sit beside the hits on a wide screen. On a phone they start folded away. + const [tagSearch, setTagSearch] = useState(""); const [moreOpen, setMoreOpen] = useState(() => typeof window === "undefined" || !window.matchMedia || window.matchMedia("(min-width: 900px)").matches); const searchRef = useRef(0); const previewRef = useRef(0); @@ -524,6 +525,16 @@ export function PaperlessPicker({ context, placement, chapterId = "", chapterTit setFilters((current) => ({ ...current, mode, sort: current.sort === "-score" && mode !== "index" ? "-created" : current.sort })); } + const visibleTags = facets.tags.filter((item) => item.name.toLocaleLowerCase().includes(tagSearch.trim().toLocaleLowerCase())); + + function tagName(id) { + return facets.tags.find((item) => item.id === id)?.name || id; + } + + function selectTags(ids) { + setFilters((current) => ({ ...current, tags: [...new Set([...current.tags, ...ids])] })); + } + function toggleTag(id) { setFilters((current) => { const tags = current.tags.includes(id) ? current.tags.filter((item) => item !== id) : [...current.tags, id]; @@ -616,13 +627,39 @@ export function PaperlessPicker({ context, placement, chapterId = "", chapterTit + {filters.tags.length ? ( +
Keine Tags an diesem Zugang.
} + ))} + {!facets.tags.length ?Keine Tags an diesem Zugang.
: null} + {facets.tags.length && !visibleTags.length ?Kein Tag passt zur Suche.
: null}