Bonsai.CustomPicker.Backoffice
1.0.2
dotnet add package Bonsai.CustomPicker.Backoffice --version 1.0.2
NuGet\Install-Package Bonsai.CustomPicker.Backoffice -Version 1.0.2
<PackageReference Include="Bonsai.CustomPicker.Backoffice" Version="1.0.2" />
paket add Bonsai.CustomPicker.Backoffice --version 1.0.2
#r "nuget: Bonsai.CustomPicker.Backoffice, 1.0.2"
// Install Bonsai.CustomPicker.Backoffice as a Cake Addin
#addin nuget:?package=Bonsai.CustomPicker.Backoffice&version=1.0.2
// Install Bonsai.CustomPicker.Backoffice as a Cake Tool
#tool nuget:?package=Bonsai.CustomPicker.Backoffice&version=1.0.2
customPickers - for Umbraco 10
This package is used to create pickers that match the look and feel of the built in umbraco picker with data pulled from any data source. See below for to add new pickers.
Step 1 - Create the new picker class
Create a new class that extends one of the following base classes.
BasePicker - Used for synchronous data sources
public class ExamplePicker : BasePicker {
public override Guid Key => new Guid("21696b2b-67fd-47a7-994f-596768e7ea17");
public override string Name => "Example"; //This the used to identify the picker when creating a custom picker data type instance.
public override IEnumerable<PickerOption> Children(string id, string culture) {
...
}
public override IEnumerable<PickerOption> GetInfo(IEnumerable<string> ids, string culture) {
...
}
public override IEnumerable<PickerOption> Search(string searchTerm, string culture) {
...
}
}
BaseAsyncPicker - Used for asynchronous data sources
public class ExampleAsyncPicker : BaseAsyncPicker {
public override Guid Key => new Guid("2470e2dd-b784-4ef2-a879-cffd65a494e5");
public override string Name => "Example Async"; //This the used to identify the picker when creating a custom picker data type instance.
public override Task<IEnumerable<PickerOption>> ChildrenAsync(string id, string culture) {
...
}
public override Task<IEnumerable<PickerOption>> GetInfoAsync(IEnumerable<string> ids, string culture) {
...
}
public override Task<IEnumerable<PickerOption>> SearchAsync(string searchTerm, string culture) {
...
}
}
The Children and ChildrenAsync methods are used to content tree in the picker, where the id is the id of the parent content. The root id will always be "-1" This is the same approach umbraco uses for its TreeControllers (see here).
The GetInfo and GetInfoAsync methods are used to retrieve data about the currently selected items. This is needed since the control only stores the id, similar to how umbraco content pickers store a udi and pull in the relevent information from that.
The Search and SearchAsync methods are used to return a list of options matching the provided searchTerm.
See the code for the PickerPicker for a full implementation of a picker. This is the picker used to select the picker when creating the data type instance.
Step 2 - Create the custom picker instance
Create a new data type like usual and select the newly created picker for the picker property in the configuration.
And that's all there is to it.
Product | Versions |
---|---|
.NET | net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows |
-
net6.0
- Bonsai.CustomPicker.Core (>= 1.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.2 | 67 | 3/11/2023 |
1.0.1 | 332 | 8/26/2022 |
1.0.0 | 285 | 8/26/2022 |
1.0.0-rc.1 | 66 | 8/25/2022 |
- fixed an issue with the package css caused by the scss compiler