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 across objects. Lightweight grouping, no nesting.
  • 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.
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).

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.
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.
fetcherFunctionnullfiles 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.
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
createEmitted when the New-folder button is clicked.
selectEmitted when a folder (or "All") is chosen.