feat(csvexport): improved csv export
Build and Push Docker image / build-and-push (push) Successful in 6m31s
Details
Build and Push Docker image / build-and-push (push) Successful in 6m31s
Details
This commit is contained in:
parent
63718ae4c0
commit
6a88c1b516
|
@ -7,6 +7,8 @@ import {useForm} from "@mantine/form";
|
|||
import {useEffect} from "react";
|
||||
import {FormSchema} from "@/components/formUtil/formBuilder/types.ts";
|
||||
import {IconDownload} from "@tabler/icons-react";
|
||||
import {useShowDebug} from "@/components/ShowDebug.tsx";
|
||||
import {onlyUnique} from "@/lib/util.ts";
|
||||
|
||||
const CHARSETS = [
|
||||
"utf-8", "ISO-8859-1", "windows-1252", "utf-16be", "utf-16le", "us-ascii"
|
||||
|
@ -36,6 +38,8 @@ export default function DownloadDataModal({opened, onClose, lists, event, query}
|
|||
}
|
||||
})
|
||||
|
||||
const {showDebug} = useShowDebug()
|
||||
|
||||
// Fetch all pages
|
||||
useEffect(() => {
|
||||
if (opened && query.hasNextPage && !query.isFetchingNextPage) {
|
||||
|
@ -72,8 +76,8 @@ export default function DownloadDataModal({opened, onClose, lists, event, query}
|
|||
const entries = query.data?.pages.flatMap(p => p.items) ?? []
|
||||
|
||||
const selectedFields = {
|
||||
questionSchemaFields: formValues.values.questionSchemaFields,
|
||||
statusSchemaFields: formValues.values.statusSchemaFields
|
||||
questionSchemaFields: formValues.values.questionSchemaFields.filter(onlyUnique),
|
||||
statusSchemaFields: formValues.values.statusSchemaFields.filter(onlyUnique)
|
||||
}
|
||||
|
||||
// which question and status fields to include in the CSV
|
||||
|
@ -81,13 +85,13 @@ export default function DownloadDataModal({opened, onClose, lists, event, query}
|
|||
fields: [
|
||||
...event.defaultEntryQuestionSchema?.fields.filter(f => selectedFields.questionSchemaFields.includes(f.id)) ?? [],
|
||||
...lists.flatMap(l => l.entryQuestionSchema?.fields.filter(f => selectedFields.questionSchemaFields.includes(f.id)) ?? [])
|
||||
]
|
||||
].filter((v, i, arr) => arr.findIndex(t => (t.id === v.id)) === i)
|
||||
}
|
||||
const statusSchema = {
|
||||
fields: [
|
||||
...event.defaultEntryStatusSchema?.fields.filter(f => selectedFields.statusSchemaFields.includes(f.id)) ?? [],
|
||||
...lists.flatMap(l => l.entryStatusSchema?.fields.filter(f => selectedFields.statusSchemaFields.includes(f.id)) ?? [])
|
||||
]
|
||||
].filter((v, i, arr) => arr.findIndex(t => (t.id === v.id)) === i)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,7 +109,8 @@ export default function DownloadDataModal({opened, onClose, lists, event, query}
|
|||
|
||||
// assemble the header (first question fields, then status fields)
|
||||
const header = [
|
||||
"Person", "Person ID", "Anmeldezeitpunkt", "Anmelde-ID", "Anmelde-Liste",
|
||||
...(showDebug ? ["Person ID", "Eintrags ID"] : []),
|
||||
"Person", "Anmeldezeitpunkt", "Anmelde-Liste",
|
||||
...questionSchema.fields.map(f => f.label).map(escapeSeparator),
|
||||
...statusSchema.fields.map(f => f.label).map(escapeSeparator)
|
||||
]
|
||||
|
@ -115,7 +120,8 @@ export default function DownloadDataModal({opened, onClose, lists, event, query}
|
|||
const questionData = e.entryQuestionData || {}
|
||||
const statusData = e.entryStatusData || {}
|
||||
return [
|
||||
e.expand?.user.username ?? "N/A", e.user, e.created, e.id, e.listName,
|
||||
...(showDebug ? [e.user, e.id] : []),
|
||||
e.expand?.user.username ?? "N/A", e.created, e.listName,
|
||||
...questionSchema.fields.map(f => questionData[f.id]?.value?.toString() ?? "N/A").map(escapeSeparator),
|
||||
...statusSchema.fields.map(f => statusData[f.id]?.value?.toString() ?? "N/A").map(escapeSeparator)
|
||||
]
|
||||
|
@ -149,8 +155,8 @@ export default function DownloadDataModal({opened, onClose, lists, event, query}
|
|||
>
|
||||
<div className={"stack"}>
|
||||
<ShowHelp>
|
||||
In der CSV sind automatisch die Felder <em>Person</em>, <em>Person
|
||||
ID</em>, <em>Anmeldezeitpunkt</em>, <em>Anmelde-ID</em> und <em>Anmelde-Liste</em> enthalten. Diese
|
||||
In der CSV sind automatisch die Felder <em>Person</em>, <em>Anmeldezeitpunkt</em>,
|
||||
und <em>Anmelde-Liste</em> enthalten. Diese
|
||||
Felder können nicht abgewählt werden.
|
||||
<br/>
|
||||
Um Listen spezifische Daten herunterzuladen, wähle im vorherigen Schritt eine oder mehrere Listen aus.
|
||||
|
|
Loading…
Reference in New Issue