RepositoryNodeSelector
Select one or more nodes from a Sitevision repository.
The component gets its options from the Sitevision REST API and wraps CustomSelector.
This is a field description.
This is a field description.
Example
Section titled “Example”<script> import { RepositoryNodeSelector } from '@soleil-se/config-svelte';</script>
<RepositoryNodeSelector name="role" label="Role" description="This is a field description." type="role"/>
<RepositoryNodeSelector name="cookies" label="Cookies" description="This is a field description." type="site-cookie" multiple/>| Prop | Type | Description |
|---|---|---|
typerequired | Type | Repository category from which to fetch nodes. |
labelrequired | string | Snippet | Field label, a string or Svelte snippet. |
value$bindable | string | string[] | Selected option value, or an array of values when '' | [] |
description | string | Snippet | Description shown below the field, a string or Svelte snippet. |
name | string | Configuration key and HTML name attribute. |
placeholder | string | Placeholder displayed when no option is selected; localization follows the document language. Default:'Select' | 'Välj' | 'Velj' |
searchable | boolean | Enables searching the options. Default:false |
removable | boolean | Allows the selected value to be cleared. For a single selection with true |
required | boolean | Set the field as required. Default:false |
disabled | boolean | Disables the field. Default:false |
multiple | boolean | Allows selecting multiple options. The false |
show | boolean | Shows or hides the selector without destroying it. Default:true |
class | string | CSS class added to the form-group wrapper. |
children | Snippet | Content rendered after the selector and validation message. |
option | Snippet<[option: Option]> | Renders custom content for each option. |
onChange | function | Called for the Select2 change event with the updated value or values. |
validate | function | Custom validator. |
Repositories that are children to the site are valid types, some are more useful than others.
Available types
Following types are available, not all are useful though.
Useful
Section titled “Useful”alias- Alias Repository.named-reference- Named Reference Repository.rss-feed- RSS Feed Repository.rating-type- Rating Type Repository.responsive-breakpoint- Responsive Breakpoint Repository.role- Role Repository.site-cookie- Site Cookie Repository.tag-group- Tag Group Repository.tag- Tag Repository.user-field- User Field Repository.
Do not use
Section titled “Do not use”color- Color Repository, use<DropdownSelector type="color" />instead.file- File Repository, use<NodeSelector type="file" />instead.font- Font Repository, use<DropdownSelector type="font" />instead.image- Image Repository, use<NodeSelector type="image" />instead.index- Index Repository, use<DropdownSelector type="search-index" />instead.metadata- Metadata Definition Template Repository, use<DropdownSelector type="metadata" />instead.oAuth2- OAuth2 Configuration Repository, use<DropdownSelector type="oauth2-configuration" />instead.page- Page Repository, use<NodeSelector type="page" />instead.principal- Principal Repository, use<NodeSelector type="user" />instead.template- Template Repository, use<DropdownSelector type="template" />instead.
addon- Addon Repository.data-store- Data Store Repository.decoration- Decoration Repository.default-image- Default Image Repository.externaltopicintegration- ExternalTopicIntegration Repository.icon- Icon Repository.list-style- List Style Repository.module-element-draft- Module Element Draft Repository.module-element- Module Element Repository.restApp- RestApp Repository.topic- Topic Repository.webApp- WebApp Repository.
App context
Section titled “App context”The component uses the current site name to fetch repository options through the Sitevision REST API. Initialize app context on the server so getAppContext() can provide siteName:
import router from '@sitevision/api/common/router';import { createAppContext } from '@soleil-se/config-svelte/server';
router.get('/', (req, res) => { createAppContext(res);});The current user must have permission to read the repository, and the REST API must be enabled. Fetch errors are shown in the selector and logged to the console.
Validation
Section titled “Validation”By default, the component applies standard required-field validation. A custom validate prop
replaces that default and returns { success: boolean, message?: string }.
Validation errors are displayed below the component and prevent saving.
See validation for more details.
Snippets
Section titled “Snippets”label and description accept text or Svelte snippets.
Default child content is rendered after the repository selector and validation message.
<script> import { RepositoryNodeSelector } from '@soleil-se/config-svelte';</script>
<RepositoryNodeSelector name="tagGroup" type="tag-group"> {#snippet label()} Välj <strong>tagggrupp</strong> {/snippet} {#snippet description()} Välj en <strong>tagggrupp</strong>. {/snippet} <p>Ytterligare information.</p></RepositoryNodeSelector>Custom option content
Section titled “Custom option content”Use the option snippet to customize each option label. It receives the option as a string or an object with label and value properties.
<RepositoryNodeSelector name="tags" label="Taggar" type="tag" multiple> {#snippet option(opt)} <strong>{opt.label}</strong> ({opt.value}) {/snippet}</RepositoryNodeSelector>