Filtere Paperless-Dokumente nach Zusatzfeldern und öffne die Auswahl als großen Dialog mit Filtern links und Treffern rechts.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9089d830b3
commit
f580fb282d
11 files changed
+386
-13
No files matched your search
@@ -389,7 +389,7 @@ export function CaseDetail() {
|
||||
<Modal open={modal === "file"} title="Datei" onClose={() => setModal("")}>
|
||||
<FileForm context={context} chapters={record.chapters} initialChapter={addChapterId} targetLabel={targetLabel} onChange={(finished = true) => { load(); if (finished) setModal(""); }} />
|
||||
</Modal>
|
||||
<Modal open={modal.startsWith("source:")} title={moduleFor(modal.slice(7))?.title || "Quelle"} wide={Boolean(moduleFor(modal.slice(7))?.wide)} split={Boolean(moduleFor(modal.slice(7))?.wide)} onClose={() => setModal("")}>
|
||||
<Modal open={modal.startsWith("source:")} title={moduleFor(modal.slice(7))?.title || "Quelle"} wide={Boolean(moduleFor(modal.slice(7))?.wide)} split={Boolean(moduleFor(modal.slice(7))?.wide)} large={Boolean(moduleFor(modal.slice(7))?.large)} onClose={() => setModal("")}>
|
||||
<SourcePicker sourceKind={modal.slice(7)} context={context} chapterId={addChapterId} chapterTitle={addChapterId ? chapterPathLabel(record.chapters, addChapterId) : ""} targetLabel={targetLabel} onInserted={load} onDone={() => { setModal(""); load(); }} />
|
||||
</Modal>
|
||||
<Modal open={modal === "subcase"} title="Unterakte anlegen" onClose={() => setModal("")}>
|
||||
|
||||
@@ -413,7 +413,7 @@ export function MatterDetail() {
|
||||
<Modal open={modal === "file"} title="Datei" onClose={() => setModal("")}>
|
||||
<FileForm context={rightsContext} placement={placement} chapters={record.chapters} initialChapter={addChapterId} targetLabel={targetLabel} onChange={(finished = true) => { load(); if (finished) setModal(""); }} />
|
||||
</Modal>
|
||||
<Modal open={modal.startsWith("source:")} title={moduleFor(modal.slice(7))?.title || "Quelle"} wide={Boolean(moduleFor(modal.slice(7))?.wide)} split={Boolean(moduleFor(modal.slice(7))?.wide)} onClose={() => setModal("")}>
|
||||
<Modal open={modal.startsWith("source:")} title={moduleFor(modal.slice(7))?.title || "Quelle"} wide={Boolean(moduleFor(modal.slice(7))?.wide)} split={Boolean(moduleFor(modal.slice(7))?.wide)} large={Boolean(moduleFor(modal.slice(7))?.large)} onClose={() => setModal("")}>
|
||||
<SourcePicker sourceKind={modal.slice(7)} context={rightsContext} placement={placement} chapterId={addChapterId} chapterTitle={addChapterId ? chapterPathLabel(record.chapters, addChapterId) : ""} targetLabel={targetLabel} onInserted={load} onDone={() => { setModal(""); load(); }} />
|
||||
</Modal>
|
||||
<Modal open={modal === "submatter"} title="Teilvorgang anlegen" onClose={() => setModal("")}>
|
||||
|
||||
@@ -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 (
|
||||
<div className="modal-overlay" onClick={(event) => { if (event.target === event.currentTarget) requestClose(); }}>
|
||||
<div ref={dialogRef} className={`modal${wide ? " modal--wide" : ""}${split ? " modal--split" : ""}`} role="dialog" aria-modal="true" aria-label={title} tabIndex={-1}>
|
||||
<div ref={dialogRef} className={`modal${wide ? " modal--wide" : ""}${split ? " modal--split" : ""}${large ? " modal--large" : ""}`} role="dialog" aria-modal="true" aria-label={title} tabIndex={-1}>
|
||||
<header className="modal__bar">
|
||||
<h2>{title}</h2>
|
||||
<button type="button" className="quiet" onClick={requestClose}>Schließen</button>
|
||||
|
||||
@@ -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 (
|
||||
<fieldset className="paperless-custom">
|
||||
<legend>Zusatzfelder, alle Bedingungen zugleich</legend>
|
||||
{rows.map((row) => {
|
||||
const field = byId.get(row.field);
|
||||
const kind = customKind(field);
|
||||
const value = (name, label) => {
|
||||
if (kind === "boolean") {
|
||||
return (
|
||||
<select aria-label={label} value={row.value} onChange={(event) => update(row.key, { [name]: event.target.value })}>
|
||||
<option value="true">Ja</option>
|
||||
<option value="false">Nein</option>
|
||||
</select>
|
||||
);
|
||||
}
|
||||
if (kind === "select") {
|
||||
return (
|
||||
<select aria-label={label} value={row.value} onChange={(event) => update(row.key, { [name]: event.target.value })}>
|
||||
<option value="">Wert wählen</option>
|
||||
{(field.options || []).map((option) => <option key={option.id} value={option.id}>{option.name}</option>)}
|
||||
</select>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<input
|
||||
aria-label={label}
|
||||
type={kind === "date" ? "date" : "text"}
|
||||
inputMode={kind === "number" ? "decimal" : undefined}
|
||||
value={name === "value" ? row.value : row.value2}
|
||||
onChange={(event) => update(row.key, { [name]: event.target.value })}
|
||||
/>
|
||||
);
|
||||
};
|
||||
const presence = row.op === "set" || row.op === "unset";
|
||||
return (
|
||||
<div key={row.key} className="paperless-custom__row">
|
||||
<select aria-label="Zusatzfeld" value={row.field} onChange={(event) => choose(row.key, event.target.value)}>
|
||||
<option value="">Feld wählen</option>
|
||||
{fields.map((item) => <option key={item.id} value={item.id}>{item.name}</option>)}
|
||||
</select>
|
||||
{field ? (
|
||||
<select aria-label="Bedingung" value={row.op} onChange={(event) => update(row.key, { op: event.target.value })}>
|
||||
{CUSTOM_OPERATORS[kind].map(([op, label]) => <option key={op} value={op}>{label}</option>)}
|
||||
{CUSTOM_PRESENCE.map(([op, label]) => <option key={op} value={op}>{label}</option>)}
|
||||
</select>
|
||||
) : null}
|
||||
{field && !presence ? value("value", row.op === "range" ? "Von" : "Wert") : null}
|
||||
{field && row.op === "range" ? value("value2", "Bis") : null}
|
||||
<button type="button" className="quiet" onClick={() => onChange(rows.filter((item) => item.key !== row.key))}>Entfernen</button>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{rows.length < CUSTOM_LIMIT ? <button type="button" className="quiet" onClick={add}>Zusatzfeld-Bedingung hinzufügen</button> : null}
|
||||
</fieldset>
|
||||
);
|
||||
}
|
||||
|
||||
// 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 (
|
||||
<SourceFrame targetLabel={targetLabel} chapterId={chapterId} chapterTitle={chapterTitle}>
|
||||
<div className="paperless-layout">
|
||||
<aside className="paperless-layout__filters" aria-label="Suche und Filter">
|
||||
{connectors.length > 1 ? (
|
||||
<label>
|
||||
Paperless-Zugang
|
||||
@@ -442,7 +568,7 @@ export function PaperlessPicker({ context, placement, chapterId = "", chapterTit
|
||||
<button type="submit">Suchen</button>
|
||||
</div>
|
||||
<p className="muted">{PAPERLESS_MODE_HINTS[filters.mode]}</p>
|
||||
<details className="paperless-more" open={active > 0 ? true : undefined}>
|
||||
<details className="paperless-more" open>
|
||||
<summary>{active ? `Weitere Filter (${active} aktiv)` : "Weitere Filter"}</summary>
|
||||
<div className="source-filters">
|
||||
<label>
|
||||
@@ -503,6 +629,7 @@ export function PaperlessPicker({ context, placement, chapterId = "", chapterTit
|
||||
Archivnummer (ASN)
|
||||
<input inputMode="numeric" value={filters.asn} onChange={(event) => setFilter("asn", event.target.value)} />
|
||||
</label>
|
||||
<CustomFieldFilters fields={facets.custom_fields || []} rows={filters.custom} onChange={(rows) => setFilter("custom", rows)} />
|
||||
</div>
|
||||
</details>
|
||||
<label>
|
||||
@@ -521,6 +648,8 @@ export function PaperlessPicker({ context, placement, chapterId = "", chapterTit
|
||||
<button type="button" className="quiet" onClick={resetFilters}>Filter zurücksetzen</button>
|
||||
</div>
|
||||
</form>
|
||||
</aside>
|
||||
<section className="paperless-layout__results" aria-label="Treffer">
|
||||
<ErrorNote error={error} />
|
||||
<p className="muted">{SEARCH_LIMITS.paperless}</p>
|
||||
<p className="muted">Die Verbindung richtest du unter <Link to="/sources">Quellen</Link> ein. Ausgewählte Belege bleiben erhalten, wenn du weiterblätterst oder neu suchst.</p>
|
||||
@@ -591,6 +720,8 @@ export function PaperlessPicker({ context, placement, chapterId = "", chapterTit
|
||||
{nextPage ? <button type="button" onClick={(event) => runSearch(event, nextPage)}>Weitere Treffer</button> : null}
|
||||
</div>
|
||||
) : null}
|
||||
</section>
|
||||
</div>
|
||||
</SourceFrame>
|
||||
);
|
||||
}
|
||||
@@ -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 });
|
||||
@@ -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"],
|
||||
|
||||
@@ -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); }
|
||||
|
||||
Reference in new issue
Block a user