Ga naar hoofdinhoud

filtersFromSchema

Generates filter definitions from the properties block of a schema. Only properties flagged facetable: true are emitted — this is the marker that turns a schema property into a filter in CnFilterBar / CnFacetSidebar.

Signature​

import { filtersFromSchema } from '@conduction/nextcloud-vue'

const filters = filtersFromSchema(schema)

Parameters​

ArgTypeDescription
schemaobjectSchema with a properties object. Returns [] when missing.
options.translate(text: string) => stringDisplay-layer translation applied to each filter's label and description. Schema property titles are authored in English as the canonical source; pass your bound t() (via the injected cnTranslate) so the rendered filter label follows the user's language. Omitted leaves the English source strings unchanged.

Apart from translate, this helper is config-free — unlike columnsFromSchema / fieldsFromSchema there is no include/exclude/overrides; tweak which filters appear by editing the schema's facetable flags.

Returns​

{
key: string,
label: string, // prop.title ?? key
description: string,
propertyType: string, // prop.type ?? 'string'
type: 'checkbox' | 'select',
options: Array<{ id, label }>, // prefilled for enum properties; [] otherwise (load from facet API at runtime)
value: null,
}[]

Filter type mapping​

Property shapetypeoptions
type: 'boolean''checkbox'[]
enum: [...]'select'one option per value; id is the raw value (it is what the facet query sends), label is x-enum-labels[value] when declared, else the value — then run through options.translate
anything else'select'[] — populate dynamically from the facet API

Sorting​

Same as other schema helpers: prop.order ascending, alphabetical tie-break.