diff --git a/.github/README.md b/.github/README.md index 8ebf316a..23bfa6d8 100644 --- a/.github/README.md +++ b/.github/README.md @@ -4,7 +4,10 @@ > contentment /kənˈtɛntm(ə)nt/ - a state of happiness and satisfaction -[![Mozilla Public License](https://img.shields.io/badge/MPL--2.0-orange?label=license)](https://opensource.org/licenses/MPL-2) [![Latest version](https://img.shields.io/nuget/v/Umbraco.Community.Contentment?label=version)](https://marketplace.umbraco.com/package/umbraco.community.contentment) [![NuGet download count](https://img.shields.io/nuget/dt/Our.Umbraco.Community.Contentment.Core?label=downloads)](https://www.nuget.org/packages/Umbraco.Community.Contentment) +[![Mozilla Public License](https://img.shields.io/badge/MPL--2.0-orange?label=license)](https://opensource.org/licenses/MPL-2) [![Latest version](https://img.shields.io/nuget/v/Umbraco.Community.Contentment?label=version)](https://marketplace.umbraco.com/package/umbraco.community.contentment) [![NuGet download count](https://img.shields.io/nuget/dt/Umbraco.Community.Contentment?label=downloads)](https://www.nuget.org/packages/Umbraco.Community.Contentment) + +> [!IMPORTANT] +> If you are looking for **Contentment for Umbraco 14** (Bellissima, the new backoffice), [please see the latest progress updates](https://github.com/leekelleher/umbraco-contentment/discussions/357)! ### What is it? diff --git a/VERSION b/VERSION index 32f3eaad..3e827a3a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.0.1 \ No newline at end of file +5.0.2 \ No newline at end of file diff --git a/docs/editors/data-picker.md b/docs/editors/data-picker.md index 858d9882..44c1214e 100644 --- a/docs/editors/data-picker.md +++ b/docs/editors/data-picker.md @@ -67,7 +67,87 @@ This interface contains two methods; The `DataListItem` model is made up of four `string` properties: `Name`, `Value`, `Description` _(optional)_ and `Icon` _(optional)_. -> `// TODO: Add a code snippet example of a custom data source.` +```csharp +using Umbraco.Cms.Core.Models; +using Umbraco.Cms.Core.PropertyEditors; +using Umbraco.Community.Contentment.DataEditors; + +namespace CodeExample; + +public class EventDataSource : IDataPickerSource +{ + private readonly IEventService _eventService; + + public EventDataSource(IEventService eventService) + { + _eventService = eventService; + } + + public string Name => "Events"; + public string Description => "List of events"; + public string Icon => "icon-movie-alt"; + public Dictionary? DefaultValues => default; + public IEnumerable? Fields => default; + public string Group => "Custom datasources"; + public OverlaySize OverlaySize => OverlaySize.Small; + + public async Task> GetItemsAsync( + Dictionary config, + IEnumerable values + ) + { + var items = new List(); + + var events = (await _eventService.GetEventsAsync()).ToList(); + + if (events.Count == 0) + { + return items; + } + + foreach (var eventItem in events) + { + items.Add(new DataListItem { Name = eventItem.Name, Value = eventItem.Id.ToString() }); + } + + return items.OrderBy(x => x.Name); + } + + public async Task> SearchAsync( + Dictionary config, + int pageNumber = 1, + int pageSize = 12, + string query = "" + ) + { + var items = new List(); + + var events = await _eventService.SearchEventsAsync(query, null, null, null, null); + + if (!events.Events.Any()) + { + return new PagedResult(0, pageNumber, pageSize) { Items = items }; + } + + foreach (var eventItem in events.Events) + { + items.Add( + new DataListItem + { + Name = eventItem.Name, + Value = eventItem.Id.ToString(), + Icon = "icon-movie-alt" + } + ); + } + + return new PagedResult(events.EventCount, pageNumber, pageSize) + { + Items = items + }; + } +} +``` ##### Accessing contextual content diff --git a/src/Umbraco.Cms.13.x/DataSources/RenderPosition.cs b/src/Umbraco.Cms.13.x/DataSources/RenderPosition.cs index 323c41ce..77b3b8e7 100644 --- a/src/Umbraco.Cms.13.x/DataSources/RenderPosition.cs +++ b/src/Umbraco.Cms.13.x/DataSources/RenderPosition.cs @@ -1,9 +1,12 @@ -using Umbraco.Community.Contentment.DataEditors; +using Umbraco.Community.Contentment.DataEditors; namespace Umbraco.Cms.Web.Common.PublishedModels { public enum RenderPosition { + [DataListItem(Name = "Html", Description = "The root <html> tag", Disabled = true)] + Html = 3, + [DataListItem(Name = "Head", Description = "Inside the <head> tags")] Head = 2, diff --git a/src/Umbraco.Community.Contentment/DataEditors/DataList/DataListItemAttribute.cs b/src/Umbraco.Community.Contentment/DataEditors/DataList/DataListItemAttribute.cs index 826d3de5..7dbd7512 100644 --- a/src/Umbraco.Community.Contentment/DataEditors/DataList/DataListItemAttribute.cs +++ b/src/Umbraco.Community.Contentment/DataEditors/DataList/DataListItemAttribute.cs @@ -15,13 +15,13 @@ public DataListItemAttribute() public string? Description { get; set; } - public bool? Disabled { get; set; } + public bool Disabled { get; set; } = false; public string? Group { get; set; } public string? Icon { get; set; } - public bool? Ignore { get; set; } + public bool Ignore { get; set; } = false; public string? Name { get; set; } diff --git a/src/Umbraco.Community.Contentment/Umbraco.Community.Contentment.csproj b/src/Umbraco.Community.Contentment/Umbraco.Community.Contentment.csproj index c855ac40..780826be 100644 --- a/src/Umbraco.Community.Contentment/Umbraco.Community.Contentment.csproj +++ b/src/Umbraco.Community.Contentment/Umbraco.Community.Contentment.csproj @@ -14,7 +14,7 @@ Umbraco.Community.Contentment Contentment for Umbraco Contentment, a collection of components for Umbraco. - 5.0.1 + 5.0.2 Lee Kelleher Lee Kelleher $([System.DateTime]::Now.Year) © $(Company) diff --git a/umbraco-marketplace.json b/umbraco-marketplace.json index b0c761ca..7fc34efa 100644 --- a/umbraco-marketplace.json +++ b/umbraco-marketplace.json @@ -75,5 +75,28 @@ "text input" ], "Title": "Contentment", + "VersionDependencyMode": "Default", + "VersionSpecificPackageIds": [ + { + "UmbracoMajorVersion": 8, + "PackageId": "Our.Umbraco.Community.Contentment" + }, + { + "UmbracoMajorVersion": 9, + "PackageId": "Our.Umbraco.Community.Contentment" + }, + { + "UmbracoMajorVersion": 10, + "PackageId": "Our.Umbraco.Community.Contentment" + }, + { + "UmbracoMajorVersion": 11, + "PackageId": "Our.Umbraco.Community.Contentment" + }, + { + "UmbracoMajorVersion": 12, + "PackageId": "Our.Umbraco.Community.Contentment" + } + ], "VideoUrl": "https://www.youtube.com/embed/alhbwyQkU1E" }