Skip to content

Commit aebb503

Browse files
committed
update with data editor alias and razor examples
1 parent 3c94783 commit aebb503

File tree

6 files changed

+97
-59
lines changed

6 files changed

+97
-59
lines changed

17/umbraco-cms/customizing/property-editors/composition/property-editor-data-source.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Data Sources are an opt-in feature for a Property Editor UI and need to be expli
99
The Data Source support is enabled in the Property Editor UI manifest. Below is a snippet showing how to enable it. The `forDataSourceTypes` can include any already existing Data Source Types or new custom ones.
1010

1111
**Property Editor UI Manifest**
12+
1213
```typescript
1314
{
1415
type: 'propertyEditorUi',
@@ -18,7 +19,7 @@ The Data Source support is enabled in the Property Editor UI manifest. Below is
1819
//... more
1920
supportsDataSource: {
2021
enabled: true,
21-
forDataSourceTypes: ['myDataSourceType']
22+
forDataSourceTypes: ['My.DataSourceType.Custom']
2223
}
2324
}
2425
}
@@ -28,16 +29,17 @@ When this field is enabled, it will be possible to pick a Data Source in the Dat
2829

2930
<figure><img src="../.gitbook/assets/umbraco-docs-data-type-property-editor-data-source.png" alt=""><figcaption><p>Property Editor Data Source Picker</p></figcaption></figure>
3031

31-
## Register a Data Source
32+
## Register a Property Editor Data Source
3233

3334
**Data Source Manifest**
35+
3436
```typescript
3537
{
3638
type: 'propertyEditorDataSource',
37-
dataSourceType: 'myDataSourceType'
38-
alias: 'Umb.PropertyEditorDataSource.MyDataSource',
39-
name: 'My Data Data Source',
40-
api: () => import('./my-data-data-source.js'),
39+
dataSourceType: 'My.DataSourceType.Custom',
40+
alias: 'Umb.PropertyEditorDataSource.MyCustomDataSource',
41+
name: 'My Custom Data Source',
42+
api: () => import('./my-custom-data-source.js'),
4143
meta: {
4244
label: 'My Data',
4345
description: 'A good description of the data',
@@ -47,13 +49,15 @@ When this field is enabled, it will be possible to pick a Data Source in the Dat
4749
```
4850

4951
### Data Source Settings
52+
5053
Like Property Editor UIs and Schemas, Data Sources can have settings for configuration of the data source. These settings are defined in the manifest under `meta.settings`. The settings for a Data Source will be rendered in the Data Type Workspace together with the Property Editor UI and Schema settings.
5154

5255
**Data Source Manifest**
56+
5357
```typescript
5458
{
5559
type: 'propertyEditorDataSource',
56-
alias: 'Umb.PropertyEditorDataSource.MyDataSource',
60+
alias: 'Umb.PropertyEditorDataSource.MyCustomDataSource',
5761
//... more
5862
meta: {
5963
//... more
@@ -70,13 +74,14 @@ When implementing a Property Editor UI element, the Data Source alias can be acc
7074

7175
```typescript
7276
interface UmbPropertyEditorUiElement extends HTMLElement {
73-
dataSourceAlias?: string;
77+
dataSourceAlias?: string;
7478
}
7579
```
7680

7781
## Access Data Source Config in Property Editor UI
82+
7883
The Data Source configuration can be accessed through the `config` property of the Property Editor UI element together with the UI and Schema config.
7984

8085
## Built-in Data Source Types
81-
* [picker](../property-editor-data-source-types/picker.md) - Used by Property Editors that pick entities, e.g. the Entity Data Picker Property Editor.
8286

87+
- [Picker](../data-source-types/picker/README.md) - Used by Property Editors that pick entities, e.g. the Entity Data Picker Property Editor.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Picker Data Source Type
2+
3+
The `Umb.DataSourceType.Picker` Data Source Type is used by Property Editors that pick entities, e.g. the built-in [Entity Data Picker Property Editor](../../../../fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/entity-data-picker.md).
4+
5+
## Register a Picker Data Source
6+
7+
**Data Source Manifest**
8+
9+
```typescript
10+
{
11+
type: 'propertyEditorDataSource',
12+
dataSourceType: 'Umb.DataSourceType.Picker',
13+
alias: 'Umb.PropertyEditorDataSource.MyPickerDataSource',
14+
name: 'My Picker Data Source',
15+
api: () => import('./my-picker-data-source.js'),
16+
meta: {
17+
label: 'My Data Source',
18+
description: 'A good description of the data source',
19+
icon: 'icon-database',
20+
},
21+
},
22+
```
23+
24+
The new Picker supports two types of data structures:
25+
26+
- [Collection Data](./picker-collection-data-source.md)
27+
- [Tree Data](./picker-tree-data-source.md)

17/umbraco-cms/customizing/property-editors/property-editor-data-source-types/README.md

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 56 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,75 @@
11
# Entity Data Picker
22

3-
`Schema Alias: Umbraco.Plain.Json` // TODO: update when alias is final
3+
`Schema Alias: Umbraco.EntityDataPicker`
44

55
`UI Alias: Umb.PropertyEditorUi.EntityDataPicker`
66

7-
`Returns: IEnumerable<string>`
7+
`Returns: Umbraco.Cms.Core.Models.EntityDataPickerValue`
88

9-
`Supported Data Source Types:` [picker](../../../../customizing/property-editors/property-editor-data-source-types/README.md)
9+
`Supported Data Source Types:` [picker](../../../../customizing/property-editors/data-source-types/picker/README.md)
1010

1111
The Entity Data Picker property editor allows editors to pick one or more entities from a configurable data source. The selected entities are stored as an array of strings, where each string represents the ID of the selected entity.
1212

1313
### With Models Builder
1414

15-
```csharp
16-
@if(Model.MyDataItems.Any()){
17-
<ul>
18-
@foreach(var item in Model.MyDataItems){
19-
<li>@item</li>
20-
}
21-
</ul>
15+
```razor
16+
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<EntityDataPickerTest>
17+
@{
18+
Layout = null;
2219
}
20+
<html lang="en">
21+
<head>
22+
<title>Entity Data Picker</title>
23+
</head>
24+
<body>
25+
@if (Model.MyEntityPicker is null)
26+
{
27+
<p>No entity picker value found</p>
28+
}
29+
else
30+
{
31+
<p>Data source: <strong>@Model.MyEntityPicker.DataSource</strong></p>
32+
<p>Picked IDs:</p>
33+
<ul>
34+
@foreach (string id in Model.MyEntityPicker.Ids)
35+
{
36+
<li>@id</li>
37+
}
38+
</ul>
39+
}
40+
</body>
41+
</html>
2342
```
2443

2544
### Without Models Builder
2645

27-
```csharp
28-
@if(Model.HasValue("MyDataItems"))
46+
```razor
47+
@using Umbraco.Cms.Core.Models
48+
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
49+
@{
50+
Layout = null;
51+
var entityDataPickerValue = Model.Value<EntityDataPickerValue>("myEntityPicker");
52+
}
53+
<html lang="en">
54+
<head>
55+
<title>Entity Data Picker</title>
56+
</head>
57+
<body>
58+
@if (entityDataPickerValue is null)
2959
{
30-
var myDataItems = Model.Value<IEnumerable<string>>("MyDataItems");
31-
<ul>
32-
@foreach(var item in myDataItems)
33-
{
34-
<li>@item</li>
35-
}
36-
</ul>
60+
<p>No entity picker value found</p>
3761
}
38-
```
39-
40-
### Content Delivery API
41-
```json
42-
// Missing example
62+
else
63+
{
64+
<p>Data source: <strong>@entityDataPickerValue.DataSource</strong></p>
65+
<p>Picked IDs:</p>
66+
<ul>
67+
@foreach (string id in @entityDataPickerValue.Ids)
68+
{
69+
<li>@id</li>
70+
}
71+
</ul>
72+
}
73+
</body>
74+
</html>
4375
```

0 commit comments

Comments
 (0)