ConceptTree
Component to display a concept tree with hierarchy from concept field narrower. The tree is based on ItemList and derives all of its slots and methods. The component supports:
- selecting a concept (prop
v-model) - expanding/collapsing nodes (events
open/close) - programmatic scrolling (method
scrollToUri) - programmatic navigation in the hierarchy (method
navigateToUri) - dynamic loading additional concepts (props
registryandscheme)
Props
modelValueobject, v-model, defaultnull— currently selected concept (highlighted)conceptsarray, required — JSKOS concepts to be displayed (usually top concepts)hierarchyboolean, defaulttrue— whether to display concept hierarchy (vianarrower)itemListOptionsobject, default{}— options passed through toItemListviav-bindregistryobject, defaultnull—
Registry to load concepts fromschemeobject, defaultnull—
Concept Scheme to load concepts from. Must have fieldurioridentifierat least.
Concept loading
Either concepts or both of registry and scheme are required to show the concept tree. If registry is not set, it is taken from internal field _registry or inScheme[0]._registry of the first concept. A registry object should have the following methods to load concepts from given scheme URI or concept URI:
getConcepts({ concepts: [{ uri }] })— load concept detailsgetTop({ scheme: { uri } })— load top concepts (only required when propconceptsis not set)getNarrower({ concept: { uri } })— load narrower concepts (only required whengetConceptsdoes not include full fieldnarrowerfor every concept)
See cocoda-sdk for a library that provides registry objects for various terminology APIs.
Slots
The slots are forwarded to the corresponding slots of ItemList:
beforeList— content shown above the list.afterList— content shown below the list.beforeItem— content shown before an item (slot prop:{ item }whereitemis the concept).afterItem— content shown after an item (slot prop:{ item }whereitemis the concept).
Methods
The methods of ItemList are exposed to be used on a component reference.
isUriInView— see ItemListscrollToUri— see ItemListnavigateToUri— navigate to a concept in the hierarchyclose— close an opened concept
navigateToUri
Arguments
uriOrConceptstring | { uri: string } — the concept URI to scroll tooptionsboolean, defaulttrue— whether to setmodelValueto the target conceptonlyIfNotInViewboolean, defaulttrue— pass-through toscrollToUri
If the concept is already rendered, it is scrolled to (and optionally selected). Otherwise the function tries to open the path from the top concepts down to the target using by loading narrower concepts.
Returns a Promise with boolean true if navigation succeeded, false otherwise
close
Close an opened concept. Requires concept object with field uri. Note that parents of selected concepts cannot be closed.
collapse
Close all opened concepts. Note that parents of selected concepts cannot be closed.
Events
selectemitted when a concept is selected. Note thatupdate:modelValueis also emitted each time selection changes. Parameter is the same payload asItemList’sselectevent: an object with properties:item(the clicked concept)row(truewhen the click was initiated via the row, not on the item directly)
openemitted when a concept’s narrower concepts are opened. Parameter is the concept.closeemitted when a concept’s narrower concepts are closed. Parameter is the concept.update:modelValueUsed for v-model updates. Will always be emitted together withselectwhen selection changes.
CSS Classes
.jskos-vue-conceptTree— the component element.jskos-vue-conceptTree-arrow— arrow to expand/collapse a subtree.jskos-vue-conceptTree-depthSpacer— vertical line left to expanded subtrees
Example
Please select a concept.