Freigabe #4

Merged
bjoernpoettker merged 23 commits from Freigabe into main 2026-06-16 14:49:23 +00:00
2 changed files with 24 additions and 9 deletions
Showing only changes of commit d5bc1bcee0 - Show all commits
@@ -98,9 +98,19 @@ export class FreigabeService {
const field = (fields as any[]).find((f: any) => f.id === FREIGABE_FIELD_ID);
if (!field) return [];
const options: string[] = field.extra_data?.select_options ?? [];
return options
const rawOptions: any[] = field.extra_data?.select_options ?? [];
return rawOptions
.filter((o) => o !== null && o !== undefined && o !== '')
.map((o) => ({ id: o, label: o }));
.map((o) => {
if (typeof o === 'object') {
// Paperless kann select_options als Objekte liefern
return {
id: String(o.id ?? o.value ?? o.label ?? ''),
label: String(o.label ?? o.name ?? o.id ?? ''),
};
}
return { id: String(o), label: String(o) };
})
.filter((o) => o.id !== '');
}
}
+11 -6
View File
@@ -67,19 +67,24 @@ export default function FreigabePage() {
return correspondents.find((c) => c.id === id)?.name ?? String(id);
};
const toCfString = (value: any): string | null => {
if (value === null || value === undefined || value === '') return null;
if (typeof value === 'object') return String(value?.id ?? value?.value ?? value?.label ?? '') || null;
return String(value);
};
const getFreigabeValue = (doc: FreigabeDocument) => {
const cf = doc.custom_fields?.find((f) => f.field === FREIGABE_FIELD_ID);
if (!cf || cf.value === null || cf.value === '' || cf.value === undefined) {
return <Tag color="warning">Nicht gesetzt</Tag>;
}
const opt = freigabeOptions.find((o) => String(o.id) === String(cf.value));
return <Tag color="success">{opt?.label ?? String(cf.value)}</Tag>;
const cfStr = toCfString(cf?.value);
if (!cfStr) return <Tag color="warning">Nicht gesetzt</Tag>;
const opt = freigabeOptions.find((o) => o.id === cfStr);
return <Tag color="success">{opt?.label ?? cfStr}</Tag>;
};
const openModal = (doc: FreigabeDocument) => {
const cf = doc.custom_fields?.find((f) => f.field === FREIGABE_FIELD_ID);
setSelectedDoc(doc);
setSelectedValue(cf?.value ?? null);
setSelectedValue(toCfString(cf?.value));
setModalOpen(true);
};