Ga naar hoofdinhoud

selectionPlugin

Adds selection state to the object store. Manages a flat list of selected object IDs across all types, with a helper to check whether an entire collection is selected and to toggle selection for one type at a time.

Usage

import { createObjectStore, selectionPlugin } from '@conduction/nextcloud-vue'

const useMyStore = createObjectStore('myapp', {
plugins: [selectionPlugin()],
})

const store = useMyStore()

store.setSelectedObjects(['abc', 'def'])
store.toggleSelectAllObjects('invoice') // selects/deselects every id in store.collections.invoice
store.isAllSelected('invoice') // true | false
store.clearSelectedObjects()

State

PropertyType
selectedObjectsstring[] — IDs of currently selected objects across all types

Getters

GetterSignatureDescription
isAllSelected(type: string) => booleantrue when every row in state.collections[type] is in selectedObjects. Returns false for empty collections. Resolves each row's ID as row.id ?? row['@self']?.id.

Actions

ActionSignatureDescription
setSelectedObjects(ids: string[]) => voidReplace the selection. Non-array input becomes [].
clearSelectedObjects() => voidDeselect everything.
toggleSelectAllObjects(type: string) => voidIf the whole collection for type is already selected, remove only that type's IDs from selectedObjects. Otherwise, add every ID from store.getCollection(type) (deduped against the existing selection). Selections from other types are preserved.

Notes

  • selectedObjects is a flat array shared across types — IDs from different types coexist. If you need per-type isolation, create separate store instances.
  • The plugin expects getCollection(type) and state.collections to be provided by the host store (both are standard on createObjectStore).