Ga naar hoofdinhoud

CnFolderSidebar

Source-agnostic folder navigation sidebar. Renders an "All" reset entry plus a (nested) folder tree, and emits select with the chosen folder id (or null for "All"). Drop it into an index page's sidebar to filter the list by folder.

Folder sources (source prop)​

  • custom (default) — the parent supplies folders (flat with parentField, or already-nested via childrenField) and handles CRUD via the create / rename / delete events. Fits app-owned folder tables, OpenRegister folder objects, anything.

  • field — no folder entity: the tree is built from the distinct values of a groupBy field. Lightweight grouping, no nesting.

    objects is normally one page of a longer list, and folders derived from a page alone are incomplete: they shift as the reader pages, their counts are per-page tallies, and a value whose rows all sit on a later page has no folder at all. Pass facetValues to avoid that. A facet is computed with the pagination parameters removed, so it carries every distinct value with its true total, and it replaces the row grouping entirely. Any property marked facetable: true gets one. Where no facet is available, set partial so the counts are dropped rather than shown as totals.

  • files — real Nextcloud folders/collections under filesPath, loaded over WebDAV via fetchWebdavFolderTree (override with the fetcher prop, e.g. for tests).

<!-- App-owned folders -->
<CnFolderSidebar :folders="folderTree" :selected-id="folderId" allow-create
@select="onFolder" @create="onCreateFolder" />

<!-- Group by any field -->
<CnFolderSidebar source="field" :objects="rows" group-by="status"
:selected-id="status" @select="onFolder" />

<!-- Real Nextcloud folders -->
<CnFolderSidebar source="files" files-path="/Vault" :selected-id="path" @select="onFolder" />

Props​

PropTypeDefaultDescription
sourceString'custom'Folder source: custom | field | files.
foldersArray[]custom source: the folders (flat or nested).
objectsArray[]field source: the objects whose values become folders.
groupByString''field source: the property to group by.
facetValuesArray[]field source: facet buckets for groupBy ({ value, count?, label? }). Computed across the whole query, so they replace the row grouping when present.
partialBooleanfalsefield source: whether objects is only part of the result set. Suppresses per-page counts and shows a notice.
partialLabelString'Folders cover this page only.'The notice shown when partial is set and no facet is available.
filesPathString'/'files source: root path to list.
maxDepthNumber1files source: recursion depth.
fetcherFunctionnullfiles source: async loader override.
selectedIdString | NumbernullThe selected folder id (null = All).
titleString''Optional heading above the tree.
allLabelString(i18n)Label for the "All" reset entry.
allIconString''MDI name for the "All" entry (empty = built-in).
idField / nameField / parentField / childrenFieldStringid / name / parentId / childrenField names for the custom source.
allowCreateBooleanfalseShow a "New folder" button.
createLabelString(i18n)Label for the New-folder button.

Events​

  • @select(id \| null) — a folder (or "All") was chosen.
  • @create({ parentId }) — the New-folder button was clicked (opt-in).

OpenRegister reliance​

none: this component does not touch OpenRegister, directly or through anything it imports. 0 direct references, 0 files reached through imports.

See the reliance overview for the filterable list.

Props​

NameTypeRequiredDefaultDescription
sourcestring'custom'Folder source strategy.
foldersArray<object>[]custom source: the folders, flat (with parentField) or nested (with childrenField). Each needs at least idField + nameField.
objectsarray[]field source: the objects whose groupBy values become folders.
groupBystring''field source: the object property to group by.
facetValuesArray<object>[]field source: facet buckets for groupBy, normalised as the object store delivers them ({ value, count?, label? }). A facet is computed across the whole query rather than the loaded page, so when this is supplied it replaces the row grouping entirely.
partialbooleanfalsefield source: whether objects is only part of the result set. Set it when the list is paged and no facet is available, so the sidebar can say the folders are incomplete instead of implying they are all there.
filesPathstring'/'files source: the folder path to list children of (root of the tree).
maxDepthnumber1files source: how deep to recurse under filesPath (each level is a WebDAV request per folder — keep small). 1 = immediate children only.
fetcher(opts: {path: string, depth: number}) => Promise<object[]>nullfiles source: async loader override. Signature ({ path, depth }) =&gt; Promise&lt;folders&gt;. Defaults to a built-in WebDAV PROPFIND loader. Inject in tests.
selectedIdstring&#124;numbernullThe currently selected folder id (or null for "All").
titlestring''Optional heading above the tree.
allLabelstring() =&gt; t('nextcloud-vue', 'All')Label for the "All" reset entry.
partialLabelstring() =&gt; t('nextcloud-vue', 'Folders cover this page only.')Notice shown when the folders cover only the loaded page.
allIconstring''MDI icon name for the "All" entry (resolved via CnIcon; empty = the built-in all-inclusive icon).
idFieldstring'id'Property holding each folder's id (custom source).
nameFieldstring'name'Property holding each folder's display name (custom source).
parentFieldstring'parentId'Property holding the parent id for flat custom folders.
childrenFieldstring'children'Property holding pre-nested children (custom source).
allowCreatebooleanfalseShow a "New folder" button (custom source).
createLabelstring() =&gt; t('nextcloud-vue', 'New folder')Label for the New-folder button.

Events​

NamePayloadDescription
create—Emitted when the New-folder button is clicked.
select—Emitted when a folder (or "All") is chosen.