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.

No options — unlike columnsFromSchema / fieldsFromSchema this helper is config-free; tweak output 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'enum.map(v => ({ id: v, label: v }))
anything else'select'[] — populate dynamically from the facet API

Sorting

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