From f580fb282dd841366680990752cc1d09629be392 Mon Sep 17 00:00:00 2001 From: Stommer Date: Sat, 24 Oct 2026 21:23:29 +0200 Subject: [PATCH] =?UTF-8?q?Filtere=20Paperless-Dokumente=20nach=20Zusatzfe?= =?UTF-8?q?ldern=20und=20=C3=B6ffne=20die=20Auswahl=20als=20gro=C3=9Fen=20?= =?UTF-8?q?Dialog=20mit=20Filtern=20links=20und=20Treffern=20rechts.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 --- backend/app/api/sources.py | 3 + backend/app/sourceport.py | 3 + backend/app/sources.py | 132 +++++++++++++++++++- backend/tests/test_connector_followup.py | 85 +++++++++++++ docs/architecture/API_REFERENZ.md | 4 +- frontend/src/pages/Cases.jsx | 2 +- frontend/src/pages/Matters.jsx | 2 +- frontend/src/pages/Modal.jsx | 4 +- frontend/src/pages/Sources.jsx | 139 +++++++++++++++++++++- frontend/src/sources/connector-config.jsx | 1 + frontend/src/styles.css | 24 ++++ 11 files changed, 386 insertions(+), 13 deletions(-) diff --git a/backend/app/api/sources.py b/backend/app/api/sources.py index fd18171..1d5ef83 100644 --- a/backend/app/api/sources.py +++ b/backend/app/api/sources.py @@ -282,6 +282,7 @@ class SearchFilters: added_from: str = "", added_to: str = "", asn: str = "", + custom: str = "", sort: str = "", cursor: str = "", ): @@ -298,6 +299,7 @@ class SearchFilters: "added_from": added_from, "added_to": added_to, "asn": asn, + "custom": custom, "sort": sort, "cursor": cursor, } @@ -445,6 +447,7 @@ _SEARCH_FLAGS = { "added_from": "added_range", "added_to": "added_range", "asn": "asn", + "custom": "custom_fields", "sort": "sort", "cursor": "continuation", } diff --git a/backend/app/sourceport.py b/backend/app/sourceport.py index 2b72cf3..35762ff 100644 --- a/backend/app/sourceport.py +++ b/backend/app/sourceport.py @@ -26,6 +26,7 @@ PAPERLESS_CAPABILITIES = { "document_range": True, "added_range": True, "asn": True, + "custom_fields": True, "sort": True, "continuation": True, "result_preview": True, @@ -52,6 +53,7 @@ IMAP_CAPABILITIES = { "document_range": False, "added_range": False, "asn": False, + "custom_fields": False, "sort": False, "continuation": True, "result_preview": False, @@ -81,6 +83,7 @@ UNSUPPORTED_SEARCH = ( "added_from", "added_to", "asn", + "custom", "sort", "cursor", ) diff --git a/backend/app/sources.py b/backend/app/sources.py index 9a9e053..fc292da 100644 --- a/backend/app/sources.py +++ b/backend/app/sources.py @@ -230,7 +230,103 @@ def _paperless_range(options: dict, prefix: str, field: str, label: str, params: params[f"{field}__date__lte"] = end -def _paperless_params(query: str, options: dict | None) -> dict: +_CUSTOM_KINDS = { + "string": "text", + "url": "text", + "longtext": "text", + "integer": "number", + "float": "number", + "monetary": "number", + "date": "date", + "boolean": "boolean", + "select": "select", +} +_CUSTOM_OPERATORS = { + "text": {"exact", "icontains", "istartswith", "iendswith"}, + "number": {"exact", "gt", "gte", "lt", "lte", "range"}, + "date": {"exact", "gt", "gte", "lt", "lte", "range"}, + "boolean": {"exact"}, + "select": {"exact"}, +} +_CUSTOM_LIMIT = 5 + + +def _custom_number(value, label: str): + text = str(value).strip().replace(",", ".") + try: + number = float(text) + except ValueError as exc: + raise unprocessable(f"{label}: Der Wert ist keine Zahl.") from exc + if number != number or number in (float("inf"), float("-inf")): + raise unprocessable(f"{label}: Der Wert ist keine Zahl.") + return int(number) if "." not in text else number + + +def _custom_value(kind: str, op: str, value, field: dict): + label = field["name"] + if op == "exists": + if not isinstance(value, bool): + raise unprocessable(f"{label}: Gesetzt oder leer ist ungültig.") + return value + if op == "range": + if not isinstance(value, (list, tuple)) or len(value) != 2: + raise unprocessable(f"{label}: Der Bereich braucht Anfang und Ende.") + low, high = (_custom_value(kind, "exact", item, field) for item in value) + if low > high: + raise unprocessable(f"{label}: Der Beginn liegt nach dem Ende.") + return [low, high] + if kind == "text": + text = " ".join(str(value or "").split()) + if not text or len(text) > 200: + raise unprocessable(f"{label}: Der Text fehlt oder ist zu lang.") + return text + if kind == "number": + return _custom_number(value, label) + if kind == "date": + day = _paperless_day(value, label) + if not day: + raise unprocessable(f"{label}: Das Datum fehlt.") + return day + if kind == "boolean": + if not isinstance(value, bool): + raise unprocessable(f"{label}: Ja oder Nein ist ungültig.") + return value + allowed = {option["id"] for option in field.get("options") or []} + if str(value) not in allowed: + raise unprocessable(f"{label}: Das ist keine Auswahl dieses Feldes.") + return str(value) + + +def _paperless_custom_query(raw, fields: list[dict]) -> str | None: + """Paperless-ngx custom_field_query, built only from fields and operators this instance offers.""" + if raw in (None, "", []): + return None + if isinstance(raw, str): + try: + raw = json.loads(raw) + except json.JSONDecodeError as exc: + raise unprocessable("Die Filter der Zusatzfelder sind ungültig.") from exc + if not isinstance(raw, list) or len(raw) > _CUSTOM_LIMIT: + raise unprocessable(f"Es sind höchstens {_CUSTOM_LIMIT} Zusatzfeld-Filter möglich.") + known = {field["id"]: field for field in fields} + atoms = [] + for row in raw: + if not isinstance(row, dict): + raise unprocessable("Die Filter der Zusatzfelder sind ungültig.") + field = known.get(str(row.get("field") or "")) + if field is None: + raise unprocessable("Das Zusatzfeld gibt es an diesem Zugang nicht.") + kind = _CUSTOM_KINDS[field["type"]] + op = str(row.get("op") or "") + if op != "exists" and op not in _CUSTOM_OPERATORS[kind]: + raise unprocessable(f"{field['name']}: Diese Bedingung gibt es für den Feldtyp nicht.") + atoms.append([field["name"], op, _custom_value(kind, op, row.get("value"), field)]) + if not atoms: + return None + return json.dumps(atoms[0] if len(atoms) == 1 else ["AND", atoms], ensure_ascii=False) + + +def _paperless_params(query: str, options: dict | None, custom_fields: list[dict] | None = None) -> dict: """Paperless-ngx document date is the created field, not the upload or modified time.""" options = options or {} params = {"page_size": str(PAPERLESS_PAGE_SIZE)} @@ -268,6 +364,9 @@ def _paperless_params(query: str, options: dict | None) -> dict: params[_PAPERLESS_TAG_MODES[tag_mode]] = ",".join(tag_ids) _paperless_range(options, "document", "created", "Dokumentdatum", params) _paperless_range(options, "added", "added", "Hinzugefügt am", params) + custom = _paperless_custom_query(options.get("custom"), custom_fields or []) + if custom: + params["custom_field_query"] = custom asn = str(options.get("asn") or "").strip() if asn: if not asn.isdigit() or len(asn) > 10: @@ -316,10 +415,10 @@ def _paperless_row(conn, owner_id: UUID, connector_id: UUID | None): def paperless_documents(conn, owner_id: UUID, query: str, connector_id: UUID | None = None, options: dict | None = None) -> dict: row = _paperless_row(conn, owner_id, connector_id) base = row["settings"]["base_url"].rstrip("/") - params = _paperless_params(query, options) release_for_external(conn) - payload = _paperless_get(base, row["secret"], "/api/documents/", params) names = _paperless_lookup(row["id"], base, row["secret"]) + params = _paperless_params(query, options, names["custom_fields"]) + payload = _paperless_get(base, row["secret"], "/api/documents/", params) assert_still_owned(conn, row["id"], owner_id) terms = _search_terms(query, (options or {}).get("title")) items = [] @@ -372,6 +471,7 @@ def paperless_facets(conn, owner_id: UUID, connector_id: UUID) -> dict: "document_types": names["document_types"], "storage_paths": names["storage_paths"], "tags": names["tags"], + "custom_fields": names["custom_fields"], "tag_mode": "all", "tag_modes": list(_PAPERLESS_TAG_MODES), "modes": list(_PAPERLESS_MODES), @@ -414,6 +514,7 @@ def _paperless_lookup(connector_id, base: str, token: str) -> dict: "tags": _paperless_names(base, token, "/api/tags/"), # An instance without storage paths, or a key that may not read them, still searches. "storage_paths": _paperless_names_or_none(base, token, "/api/storage_paths/"), + "custom_fields": _paperless_custom_fields(base, token), } with _lookup_lock: if len(_lookup_cache) >= _LOOKUP_LIMIT: @@ -422,6 +523,31 @@ def _paperless_lookup(connector_id, base: str, token: str) -> dict: return names +def _paperless_custom_fields(base: str, token: str) -> list[dict]: + """Custom fields the picker can filter on. Types it cannot query, such as document links, are left out.""" + found = [] + try: + for page in range(1, 6): + payload = _paperless_get(base, token, "/api/custom_fields/", {"page": str(page), "page_size": "100"}) + rows = payload.get("results") or [] + for item in rows: + kind = item.get("data_type") + if item.get("id") is None or kind not in _CUSTOM_KINDS: + continue + extra = item.get("extra_data") if isinstance(item.get("extra_data"), dict) else {} + options = [ + {"id": str(option["id"]), "name": str(option.get("label") or option["id"])[:200]} + for option in extra.get("select_options") or [] + if isinstance(option, dict) and option.get("id") is not None + ] + found.append({"id": str(item["id"]), "name": str(item.get("name") or item["id"])[:200], "type": kind, "options": options}) + if len(rows) < 100: + break + except Problem: + return [] + return found + + def _paperless_names_or_none(base: str, token: str, path: str) -> list[dict]: try: return _paperless_names(base, token, path) diff --git a/backend/tests/test_connector_followup.py b/backend/tests/test_connector_followup.py index e877ae9..82bbcbd 100644 --- a/backend/tests/test_connector_followup.py +++ b/backend/tests/test_connector_followup.py @@ -535,6 +535,91 @@ def test_paperless_default_search_reads_title_and_content_and_shows_a_preview(cl ) +def test_paperless_custom_field_filters_use_the_instance_fields(client, db, monkeypatch): + import json + + import app.sources as sources + + calls = [] + + def fake_get(base, token, path, params): + calls.append({"path": path, "params": dict(params)}) + if path == "/api/custom_fields/": + return { + "results": [ + {"id": 1, "name": "Rechnungsbetrag", "data_type": "monetary"}, + {"id": 2, "name": "bezahlt_am", "data_type": "date"}, + { + "id": 3, + "name": "Status", + "data_type": "select", + "extra_data": {"select_options": [{"id": "a", "label": "offen"}, {"id": "b", "label": "bezahlt"}]}, + }, + {"id": 4, "name": "Verweis", "data_type": "documentlink"}, + ] + } + if path == "/api/documents/": + return {"count": 0, "results": []} + return {"results": []} + + monkeypatch.setattr(sources, "_paperless_get", fake_get) + ada = Actor(client, "ada-custom@example.test", "Ada Custom") + register(db, ada.email, ada.name) + ada.login() + first = ada.request( + "POST", + "/api/v1/connectors", + json={"kind": "paperless", "name": "Archiv", "base_url": "https://paper.example.test", "token": "token-alpha"}, + status=201, + ) + facets = ada.request("GET", "/api/v1/sources/paperless/facets", params={"connector_id": first["id"]}) + assert [item["name"] for item in facets["custom_fields"]] == ["Rechnungsbetrag", "bezahlt_am", "Status"] + assert facets["custom_fields"][2]["options"] == [{"id": "a", "name": "offen"}, {"id": "b", "name": "bezahlt"}] + + def ask(rows, status=200): + return ada.request( + "GET", + "/api/v1/sources/paperless/documents", + params={"connector_id": first["id"], "custom": json.dumps(rows)}, + status=status, + ) + + ask([{"field": "2", "op": "range", "value": ["2024-01-01", "2024-06-30"]}]) + sent = [call for call in calls if call["path"] == "/api/documents/"][-1]["params"] + assert json.loads(sent["custom_field_query"]) == ["bezahlt_am", "range", ["2024-01-01", "2024-06-30"]] + ask( + [ + {"field": "1", "op": "gte", "value": "100,5"}, + {"field": "3", "op": "exact", "value": "a"}, + {"field": "2", "op": "exists", "value": False}, + ] + ) + sent = [call for call in calls if call["path"] == "/api/documents/"][-1]["params"] + assert json.loads(sent["custom_field_query"]) == [ + "AND", + [["Rechnungsbetrag", "gte", 100.5], ["Status", "exact", "a"], ["bezahlt_am", "exists", False]], + ] + ask([], 200) + assert "custom_field_query" not in [call for call in calls if call["path"] == "/api/documents/"][-1]["params"] + for rows in ( + [{"field": "9", "op": "exact", "value": "x"}], + [{"field": "4", "op": "contains", "value": "1"}], + [{"field": "2", "op": "icontains", "value": "2024"}], + [{"field": "3", "op": "exact", "value": "z"}], + [{"field": "1", "op": "gt", "value": "viel"}], + [{"field": "2", "op": "range", "value": ["2024-06-30", "2024-01-01"]}], + [{"field": "2", "op": "exists", "value": "ja"}], + [{"field": "1", "op": "exact", "value": "1"}] * 6, + ): + ask(rows, 422) + ada.request( + "GET", + "/api/v1/sources/paperless/documents", + params={"connector_id": first["id"], "custom": "kein json"}, + status=422, + ) + + def test_paperless_thumbnail_is_bound_to_the_owners_instance(client, db, monkeypatch): import app.sources as sources diff --git a/docs/architecture/API_REFERENZ.md b/docs/architecture/API_REFERENZ.md index 12f2e72..9ed1d90 100644 --- a/docs/architecture/API_REFERENZ.md +++ b/docs/architecture/API_REFERENZ.md @@ -196,8 +196,8 @@ Legende Spalte „Auth“: **–** öffentlich, **S** gültige Session, **S+R** | GET | `/api/v1/sources/{kind}/search` | Suche der registrierten Quelle im erklärten Umfang; unbekannte Art und nicht erklärte Filter antworten `422` | | GET | `/api/v1/sources/{kind}/navigate?connector_id=` | Fachnavigation, wenn die Quelle sie erklärt | | GET | `/api/v1/sources/{kind}/preview` | Vorschau vor dem Übernehmen, wenn die Quelle sie erklärt | -| GET | `/api/v1/sources/paperless/documents?q=&connector_id=` | Paperless-Suche, 20 Treffer je Seite, `cursor` ist die Seitennummer. `mode`: `title_content` (Standard, Titel und Inhalt ohne Index), `title`, `content`, `index` (Volltextindex von Paperless). Filter: `title`, `correspondent`, `document_type`, `storage_path` (jeweils Nummer oder `none` für „ohne“), `tag` (Nummern, durch Komma) mit `tag_mode` `all` (Standard), `any` oder `none`, `document_from`/`document_to` (Dokumentdatum), `added_from`/`added_to` (Hinzugefügt), `asn`, `sort` (`created`, `added`, `title`, jeweils mit `-`; `-score` nur bei `mode=index` mit Suchtext). Ein ungültiger Wert antwortet `422`. Je Treffer: `title`, `document_on`, `added_on`, `correspondent`, `document_type`, `storage_path`, `tags` (Namen), `pages`, `asn`, `snippet` (Textauszug, reiner Text) und `open_url`; dazu `total`, `next_page`, `previous_page` | -| GET | `/api/v1/sources/{kind}/facets?connector_id=` | Auswahllisten der Instanz (Paperless: Korrespondenten, Dokumenttypen, Speicherpfade, Tags). Namen und Listen werden je Instanz und Schlüssel eine Minute lang vorgehalten | +| GET | `/api/v1/sources/paperless/documents?q=&connector_id=` | Paperless-Suche, 20 Treffer je Seite, `cursor` ist die Seitennummer. `mode`: `title_content` (Standard, Titel und Inhalt ohne Index), `title`, `content`, `index` (Volltextindex von Paperless). Filter: `title`, `correspondent`, `document_type`, `storage_path` (jeweils Nummer oder `none` für „ohne“), `tag` (Nummern, durch Komma) mit `tag_mode` `all` (Standard), `any` oder `none`, `document_from`/`document_to` (Dokumentdatum), `added_from`/`added_to` (Hinzugefügt), `asn`, `custom` (JSON-Liste `[{field, op, value}]`, höchstens 5, alle zugleich; `field` ist die Nummer aus `facets.custom_fields`, `op` je Feldtyp `exact`, `icontains`, `istartswith`, `iendswith`, `gt`, `gte`, `lt`, `lte`, `range` oder `exists`; Dokumentverweis-Felder sind nicht filterbar; wird als `custom_field_query` an Paperless gegeben), `sort` (`created`, `added`, `title`, jeweils mit `-`; `-score` nur bei `mode=index` mit Suchtext). Ein ungültiger Wert antwortet `422`. Je Treffer: `title`, `document_on`, `added_on`, `correspondent`, `document_type`, `storage_path`, `tags` (Namen), `pages`, `asn`, `snippet` (Textauszug, reiner Text) und `open_url`; dazu `total`, `next_page`, `previous_page` | +| GET | `/api/v1/sources/{kind}/facets?connector_id=` | Auswahllisten der Instanz (Paperless: Korrespondenten, Dokumenttypen, Speicherpfade, Tags, Zusatzfelder mit Typ und Auswahlwerten). Namen und Listen werden je Instanz und Schlüssel eine Minute lang vorgehalten | | GET | `/api/v1/sources/paperless/documents/{id}/preview?connector_id=` | Datei zum Ansehen vor dem Übernehmen | | GET | `/api/v1/sources/paperless/documents/{id}/thumb?connector_id=` | Vorschaubild der Trefferliste. Läuft über den Server der eigenen Instanz, `private, no-store`; fremde Instanz `404`, Antwort ohne Bild `422` | | GET | `/api/v1/sources/imap/mailboxes?connector_id=` | IMAP-Fächer | diff --git a/frontend/src/pages/Cases.jsx b/frontend/src/pages/Cases.jsx index 3958560..377d477 100644 --- a/frontend/src/pages/Cases.jsx +++ b/frontend/src/pages/Cases.jsx @@ -389,7 +389,7 @@ export function CaseDetail() { setModal("")}> { load(); if (finished) setModal(""); }} /> - setModal("")}> + setModal("")}> { setModal(""); load(); }} /> setModal("")}> diff --git a/frontend/src/pages/Matters.jsx b/frontend/src/pages/Matters.jsx index bdbdfcc..52e2a2b 100644 --- a/frontend/src/pages/Matters.jsx +++ b/frontend/src/pages/Matters.jsx @@ -413,7 +413,7 @@ export function MatterDetail() { setModal("")}> { load(); if (finished) setModal(""); }} /> - setModal("")}> + setModal("")}> { setModal(""); load(); }} /> setModal("")}> diff --git a/frontend/src/pages/Modal.jsx b/frontend/src/pages/Modal.jsx index 2587613..58bc1c1 100644 --- a/frontend/src/pages/Modal.jsx +++ b/frontend/src/pages/Modal.jsx @@ -1,7 +1,7 @@ import { useEffect, useRef } from "react"; import { isDirty, markDirty } from "../api.js"; -export function Modal({ open, title, onClose, wide = false, split = false, children }) { +export function Modal({ open, title, onClose, wide = false, split = false, large = false, children }) { const dialogRef = useRef(null); const restoreRef = useRef(null); @@ -33,7 +33,7 @@ export function Modal({ open, title, onClose, wide = false, split = false, child if (!open) return null; return (
{ if (event.target === event.currentTarget) requestClose(); }}> -
+

{title}

diff --git a/frontend/src/pages/Sources.jsx b/frontend/src/pages/Sources.jsx index 6e494d2..bc3e9b7 100644 --- a/frontend/src/pages/Sources.jsx +++ b/frontend/src/pages/Sources.jsx @@ -93,7 +93,7 @@ const PAPERLESS_MODE_HINTS = { index: "Der Volltextindex von Paperless findet ganze Wörter, auch mit AND, OR und Anführungszeichen, und ordnet nach Relevanz. Ein neues Dokument erscheint erst, wenn Paperless es indexiert hat.", }; -const NO_FACETS = { correspondents: [], document_types: [], storage_paths: [], tags: [] }; +const NO_FACETS = { correspondents: [], document_types: [], storage_paths: [], tags: [], custom_fields: [] }; const EMPTY_FILTERS = { query: "", @@ -109,6 +109,7 @@ const EMPTY_FILTERS = { addedFrom: "", addedTo: "", asn: "", + custom: [], sort: "-created", }; @@ -124,7 +125,128 @@ function activeFilterCount(filters) { filters.addedFrom, filters.addedTo, filters.asn.trim(), - ].filter(Boolean).length; + ].filter(Boolean).length + customPayload(filters.custom).length; +} + +const CUSTOM_KINDS = { + string: "text", + url: "text", + longtext: "text", + integer: "number", + float: "number", + monetary: "number", + date: "date", + boolean: "boolean", + select: "select", +}; + +const CUSTOM_OPERATORS = { + text: [["icontains", "enthält"], ["exact", "ist gleich"], ["istartswith", "beginnt mit"], ["iendswith", "endet mit"]], + number: [["exact", "gleich"], ["gte", "mindestens"], ["lte", "höchstens"], ["gt", "größer als"], ["lt", "kleiner als"], ["range", "zwischen"]], + date: [["exact", "am"], ["gte", "ab"], ["lte", "bis"], ["gt", "nach"], ["lt", "vor"], ["range", "zwischen"]], + boolean: [["exact", "ist"]], + select: [["exact", "ist"]], +}; + +const CUSTOM_PRESENCE = [["set", "hat einen Wert"], ["unset", "ist leer"]]; +const CUSTOM_LIMIT = 5; + +function customKind(field) { + return CUSTOM_KINDS[field?.type] || "text"; +} + +// Only rows that are complete go to the server. An empty row is a row not filled in yet. +function customPayload(rows) { + const payload = []; + for (const row of rows) { + if (!row.field) continue; + if (row.op === "set" || row.op === "unset") { + payload.push({ field: row.field, op: "exists", value: row.op === "set" }); + } else if (row.op === "range") { + if (row.value && row.value2) payload.push({ field: row.field, op: "range", value: [row.value, row.value2] }); + } else if (row.kind === "boolean") { + payload.push({ field: row.field, op: "exact", value: row.value !== "false" }); + } else if (String(row.value).trim()) { + payload.push({ field: row.field, op: row.op, value: String(row.value).trim() }); + } + } + return payload; +} + +function CustomFieldFilters({ fields, rows, onChange }) { + if (!fields.length) return null; + const byId = new Map(fields.map((item) => [item.id, item])); + + function update(key, patch) { + onChange(rows.map((row) => (row.key === key ? { ...row, ...patch } : row))); + } + + function choose(key, id) { + const field = byId.get(id); + const kind = customKind(field); + const first = field ? CUSTOM_OPERATORS[kind][0][0] : ""; + update(key, { field: id, kind, op: first, value: kind === "boolean" ? "true" : "", value2: "" }); + } + + function add() { + onChange([...rows, { key: `${Date.now()}-${rows.length}`, field: "", kind: "text", op: "", value: "", value2: "" }]); + } + + return ( +
+ Zusatzfelder, alle Bedingungen zugleich + {rows.map((row) => { + const field = byId.get(row.field); + const kind = customKind(field); + const value = (name, label) => { + if (kind === "boolean") { + return ( + + ); + } + if (kind === "select") { + return ( + + ); + } + return ( + update(row.key, { [name]: event.target.value })} + /> + ); + }; + const presence = row.op === "set" || row.op === "unset"; + return ( +
+ + {field ? ( + + ) : null} + {field && !presence ? value("value", row.op === "range" ? "Von" : "Wert") : null} + {field && row.op === "range" ? value("value2", "Bis") : null} + +
+ ); + })} + {rows.length < CUSTOM_LIMIT ? : null} +
+ ); } // The thumbnail comes through the server like every other Paperless call, so the key stays there. @@ -230,6 +352,8 @@ export function PaperlessPicker({ context, placement, chapterId = "", chapterTit if (filters.addedFrom) params.set("added_from", filters.addedFrom); if (filters.addedTo) params.set("added_to", filters.addedTo); if (filters.asn.trim()) params.set("asn", filters.asn.trim()); + const custom = customPayload(filters.custom); + if (custom.length) params.set("custom", JSON.stringify(custom)); if (filters.sort === "-score") { if (text && filters.mode === "index") params.set("sort", "-score"); } else if (filters.sort) { @@ -404,6 +528,8 @@ export function PaperlessPicker({ context, placement, chapterId = "", chapterTit return ( +
+

{PAPERLESS_MODE_HINTS[filters.mode]}

-
0 ? true : undefined}> +
{active ? `Weitere Filter (${active} aktiv)` : "Weitere Filter"}
+ setFilter("custom", rows)} />
+ +

{SEARCH_LIMITS.paperless}

Die Verbindung richtest du unter Quellen ein. Ausgewählte Belege bleiben erhalten, wenn du weiterblätterst oder neu suchst.

@@ -591,6 +720,8 @@ export function PaperlessPicker({ context, placement, chapterId = "", chapterTit {nextPage ? : null}
) : null} + +
); } @@ -998,5 +1129,5 @@ export function MailPicker({ context, placement, chapterId = "", chapterTitle = ); } -registerSourceModule({ kind: "paperless", title: "Paperless", addLabel: "Paperless", manual: true, searchHint: SEARCH_LIMITS.paperless, Picker: PaperlessPicker }); +registerSourceModule({ kind: "paperless", title: "Paperless", addLabel: "Paperless", manual: true, large: true, searchHint: SEARCH_LIMITS.paperless, Picker: PaperlessPicker }); registerSourceModule({ kind: "imap", title: "E-Mail-Konto", addLabel: "E-Mail", wide: true, searchHint: SEARCH_LIMITS.imap, Picker: MailPicker }); diff --git a/frontend/src/sources/connector-config.jsx b/frontend/src/sources/connector-config.jsx index c3ea68f..63c7ad6 100644 --- a/frontend/src/sources/connector-config.jsx +++ b/frontend/src/sources/connector-config.jsx @@ -45,6 +45,7 @@ const SEARCH_FILTERS = [ ["document_range", "Dokumentdatum"], ["added_range", "Hinzugefügt am"], ["asn", "Archivnummer"], + ["custom_fields", "Zusatzfelder (benutzerdefinierte Felder)"], ["sort", "Sortierung"], ["continuation", "Weitere Seiten"], ["result_preview", "Vorschaubild und Textauszug je Treffer"], diff --git a/frontend/src/styles.css b/frontend/src/styles.css index 2fa8748..395e1a6 100644 --- a/frontend/src/styles.css +++ b/frontend/src/styles.css @@ -424,6 +424,16 @@ button.nav-item:active { transform: none; } padding: 18px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18); } +.modal-overlay:has(.modal--large) { padding: 12px; } +.modal.modal--large { + width: min(1800px, 100%); + height: min(96vh, 1400px); + max-height: none; + overflow: hidden; + display: flex; + flex-direction: column; +} +.modal.modal--large > .stack { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; } .modal__bar { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 14px; } .modal.modal--wide { width: min(960px, 100%); } .modal.modal--wide.modal--split { width: min(1120px, 100%); } @@ -1718,6 +1728,15 @@ button.pick-tree__twist { .note-source__bar { display: flex; flex-wrap: wrap; gap: 6px; } .note-source textarea { width: 100%; min-height: 8rem; } .source-filters { display: grid; gap: 8px; } +.paperless-layout { display: grid; gap: 16px; min-height: 0; } +.paperless-layout__filters, .paperless-layout__results { display: grid; gap: 8px; align-content: start; min-width: 0; } +.modal--large .paperless-layout { flex: 1; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); overflow: hidden; } +.modal--large .paperless-layout__filters, .modal--large .paperless-layout__results { overflow: auto; min-height: 0; padding-right: 6px; } +.modal--large .paperless-layout__filters { border-right: 1px solid var(--border); } +.modal--large .paperless-layout__results > button:first-of-type { position: sticky; top: 0; z-index: 1; } +.modal--large .paperless-search { grid-template-columns: minmax(0, 1fr); } +.paperless-custom { display: grid; gap: 6px; } +.paperless-custom__row { display: grid; gap: 4px; padding: 6px; border: 1px solid var(--border); border-radius: 6px; } .paperless-search { display: grid; grid-template-columns: minmax(9rem, 12rem) minmax(0, 1fr) auto; gap: 8px; align-items: end; } .paperless-more > summary { cursor: pointer; font-weight: 600; min-height: 32px; } .paperless-tags { display: grid; gap: 2px; max-height: 12rem; overflow: auto; } @@ -1762,6 +1781,11 @@ button.pick-tree__twist { } .paperless-thumb__image { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; } .paperless-thumb__empty { color: var(--text3); font-size: 11px; } +@media (max-width: 899px) { + .modal--large .paperless-layout { grid-template-columns: minmax(0, 1fr); overflow: auto; } + .modal--large .paperless-layout__filters, .modal--large .paperless-layout__results { overflow: visible; border-right: 0; padding-right: 0; } + .modal.modal--large { overflow: auto; } +} @media (max-width: 600px) { .paperless-search { grid-template-columns: minmax(0, 1fr); } .paperless-card { grid-template-columns: auto 4rem minmax(0, 1fr); }