Skip to content
Snippets Groups Projects
Unverified Commit b95aa6dd authored by BITARD Michaël's avatar BITARD Michaël Committed by GitHub
Browse files

fix(api): le téléchargement des titres filtrés fonctionne (#117)

parent 477d0ac7
Branches
Tags
No related merge requests found
......@@ -16,6 +16,16 @@ const tableConvert = (
const sheet = xlsx.utils.json_to_sheet(elements as Index<any>[])
if (format === 'xlsx') {
const cells = Object.keys(sheet)
for (const cell of cells) {
if (typeof sheet[cell].v === 'string' && sheet[cell].v.length > 32767) {
sheet[cell].v =
'la cellule est trop grosse pour le format xlsx, veuillez télécharger le document en ods si vous voulez y accéder'
}
}
}
if (format === 'csv') {
contenu = xlsx.utils.sheet_to_csv(sheet)
} else if (format === 'xlsx' || format === 'ods') {
......
......@@ -32,6 +32,7 @@ import { entreprisesFormatTable } from './format/entreprises'
import { matomo } from '../../tools/matomo'
import { isRole } from 'camino-common/src/roles'
import { stringSplit } from '../../database/queries/_utils'
const formatCheck = (formats: string[], format: string) => {
if (!formats.includes(format)) {
......@@ -99,9 +100,9 @@ interface ITitresQueryInput {
domainesIds?: string | null
typesIds?: string | null
statutsIds?: string | null
substances?: string | null
noms?: string | null
entreprises?: string | null
substancesLegalesIds?: string | null
titresIds?: string | null
entreprisesIds?: string | null
references?: string | null
territoires?: string | null
perimetre?: number[] | null
......@@ -116,9 +117,9 @@ const titres = async (
typesIds,
domainesIds,
statutsIds,
substances,
noms,
entreprises,
substancesLegalesIds,
titresIds,
entreprisesIds,
references,
territoires,
perimetre
......@@ -137,9 +138,11 @@ const titres = async (
typesIds: typesIds?.split(','),
domainesIds: domainesIds?.split(','),
statutsIds: statutsIds?.split(','),
substances,
noms,
entreprises,
ids: titresIds ? stringSplit(titresIds) : null,
entreprisesIds: entreprisesIds ? stringSplit(entreprisesIds) : null,
substancesLegalesIds: substancesLegalesIds
? stringSplit(substancesLegalesIds)
: null,
references,
territoires,
perimetre
......@@ -172,9 +175,9 @@ const titres = async (
typesIds,
domainesIds,
statutsIds,
substances,
noms,
entreprises,
substancesLegalesIds,
titresIds,
entreprisesIds,
references,
territoires
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment