Skip to content

Commit

Permalink
Merge pull request #395 from leekelleher/dev/v4.x
Browse files Browse the repository at this point in the history
Preparing v4.7.0 release
  • Loading branch information
leekelleher authored Apr 19, 2024
2 parents 6fb4c8e + 19b3843 commit a80fd56
Show file tree
Hide file tree
Showing 45 changed files with 500 additions and 246 deletions.
6 changes: 5 additions & 1 deletion .github/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,14 @@ Property Editors are:
- [Data Picker](https://github.com/leekelleher/umbraco-contentment/pull/297)
- Data List: [Umbraco Backoffice Sections](https://github.com/leekelleher/umbraco-contentment/commit/c8a2f0f8552b2ad3a778782f13c45cbb18aff88c) data-source.

### v4.6
### [v4.6](https://github.com/leekelleher/umbraco-contentment/releases/tag/4.6.0)

- A non-breaking-change minor release. Adds support for Umbraco v13, .NET 8.0. _(Whilst still supporting v8.17+, v9, v10, v11 and v12)._

### [v4.7](https://github.com/leekelleher/umbraco-contentment/releases/tag/4.7.0)

- Data Picker: [Data List source bridge](https://github.com/leekelleher/umbraco-contentment/pull/393) _(to enable all the built-in Data List sources within Data Picker)._


## v5

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ build/build-push-umb.ps1
src/packages/*/**
src/Umbraco.Cms.*.x/*
src/Umbraco.Community.Contentment/wwwroot/App_Plugins/Contentment/*
src/Umbraco.Community.Contentment.StaticAssets/*
tools/*.exe
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.6.1
4.7.0
1 change: 1 addition & 0 deletions build/readme-nuget-main.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The following property editors are available...
- [Code Editor](https://github.com/leekelleher/umbraco-contentment/blob/develop/docs/editors/code-editor.md) - a code snippet editor, _(using the ACE library that is bundled with Umbraco)._
- [Content Blocks](https://github.com/leekelleher/umbraco-contentment/blob/develop/docs/editors/content-blocks.md) - a block editor, configurable using element types.
- [Data List](https://github.com/leekelleher/umbraco-contentment/blob/develop/docs/editors/data-list.md) - an editor that combines a custom data source with a custom list editor.
- [Data Picker](https://github.com/leekelleher/umbraco-contentment/blob/develop/docs/editors/data-picker.md) - advanced picker editor to query a custom data source.
- [Editor Notes](https://github.com/leekelleher/umbraco-contentment/blob/develop/docs/editors/editor-notes.md) - Similar to [Notes](https://github.com/leekelleher/umbraco-contentment/blob/develop/docs/editors/notes.md), with enhanced UI options.
- [Icon Picker](https://github.com/leekelleher/umbraco-contentment/blob/develop/docs/editors/icon-picker.md) - an editor to select an icon (from the Umbraco icon library).
- [Notes](https://github.com/leekelleher/umbraco-contentment/blob/develop/docs/editors/notes.md) - a read-only label to display rich-text instructional messages for content editors.
Expand Down
16 changes: 16 additions & 0 deletions src/Umbraco.Cms.10.x/uSync/v10/ContentTypes/testmiscpage.config
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@
<ValidationRegExpMessage></ValidationRegExpMessage>
<LabelOnTop>false</LabelOnTop>
</GenericProperty>
<GenericProperty>
<Key>45248546-4d6c-4418-92e9-855c3aac8328</Key>
<Name>Data Picker - uCssClassName</Name>
<Alias>dataPickerUCssClassName</Alias>
<Definition>d4b190f2-e2a6-470c-a39f-8e1ae14d521c</Definition>
<Type>Umbraco.Community.Contentment.DataPicker</Type>
<Mandatory>false</Mandatory>
<Validation></Validation>
<Description><![CDATA[]]></Description>
<SortOrder>20</SortOrder>
<Tab Alias="dataPicker">Data Picker</Tab>
<Variations>Nothing</Variations>
<MandatoryMessage></MandatoryMessage>
<ValidationRegExpMessage></ValidationRegExpMessage>
<LabelOnTop>false</LabelOnTop>
</GenericProperty>
<GenericProperty>
<Key>a290a9de-0b71-49b7-9572-0bf541525469</Key>
<Name>Data Picker - Umbraco Content</Name>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<DataType Key="d4b190f2-e2a6-470c-a39f-8e1ae14d521c" Alias="[Contentment] Data Picker - Web uCssClassName" Level="2">
<Info>
<Name>[Contentment] Data Picker - Web uCssClassName</Name>
<EditorAlias>Umbraco.Community.Contentment.DataPicker</EditorAlias>
<DatabaseType>Ntext</DatabaseType>
<Folder>Test+Data+Picker</Folder>
</Info>
<Config><![CDATA[{
"dataSource": [
{
"key": "Umbraco.Community.Contentment.DataEditors.uCssClassNameDataListSource, Umbraco.Community.Contentment",
"value": {
"cssPath": "~/umbraco/lib/font-awesome/css/font-awesome.min.css",
"cssRegex": "\\.fa-([^:]*?):before",
"excludeList": "",
"iconPattern": "icon-fa fa-{0}"
}
}
],
"displayMode": [
{
"key": "Umbraco.Community.Contentment.DataEditors.CardsDataPickerDisplayMode, Umbraco.Community.Contentment",
"value": null
}
],
"pageSize": 12,
"overlaySize": [
"medium"
],
"hideSearch": "0",
"maxItems": 0,
"enableDevMode": "1"
}]]></Config>
</DataType>
16 changes: 16 additions & 0 deletions src/Umbraco.Cms.13.x/uSync/v9/ContentTypes/testmiscpage.config
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@
<ValidationRegExpMessage></ValidationRegExpMessage>
<LabelOnTop>false</LabelOnTop>
</GenericProperty>
<GenericProperty>
<Key>2f56d9fd-2066-4905-9c2e-8e29c657fe10</Key>
<Name>Data Picker - uCssClassName</Name>
<Alias>dataPickerUCssClassName</Alias>
<Definition>882e9021-789a-412c-ac26-9818df51c647</Definition>
<Type>Umbraco.Community.Contentment.DataPicker</Type>
<Mandatory>false</Mandatory>
<Validation></Validation>
<Description><![CDATA[]]></Description>
<SortOrder>20</SortOrder>
<Tab Alias="dataPicker">Data Picker</Tab>
<Variations>Nothing</Variations>
<MandatoryMessage></MandatoryMessage>
<ValidationRegExpMessage></ValidationRegExpMessage>
<LabelOnTop>false</LabelOnTop>
</GenericProperty>
<GenericProperty>
<Key>a290a9de-0b71-49b7-9572-0bf541525469</Key>
<Name>Data Picker - Umbraco Content</Name>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<DataType Key="882e9021-789a-412c-ac26-9818df51c647" Alias="[Contentment] Data Picker - Web uCssClassName" Level="2">
<Info>
<Name>[Contentment] Data Picker - Web uCssClassName</Name>
<EditorAlias>Umbraco.Community.Contentment.DataPicker</EditorAlias>
<DatabaseType>Ntext</DatabaseType>
<Folder>Test+Data+Picker</Folder>
</Info>
<Config><![CDATA[{
"dataSource": [
{
"key": "Umbraco.Community.Contentment.DataEditors.uCssClassNameDataListSource, Umbraco.Community.Contentment",
"value": {
"cssPath": "~/umbraco/lib/font-awesome/css/font-awesome.min.css",
"cssRegex": "\\.fa-([^:]*?):before",
"excludeList": "",
"iconPattern": "icon-fa fa-{0}"
}
}
],
"displayMode": [
{
"key": "Umbraco.Community.Contentment.DataEditors.CardsDataPickerDisplayMode, Umbraco.Community.Contentment",
"value": {}
}
],
"pageSize": 12,
"overlaySize": [
"medium"
],
"hideSearch": "0",
"maxItems": 0,
"enableDevMode": "1"
}]]></Config>
</DataType>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Umbraco.Community.Contentment.Web.PublishedCache;
#if NET472
using Umbraco.Core;
Expand Down Expand Up @@ -51,6 +53,11 @@ public override object ConvertSourceToIntermediate(IPublishedElement owner, IPub
return JsonConvert.DeserializeObject<IEnumerable<ContentBlock>>(value);
}

if (source is JArray array && array.Any() == true)
{
return array.ToObject<IEnumerable<ContentBlock>>();
}

return base.ConvertSourceToIntermediate(owner, propertyType, source, preview);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/* Copyright © 2024 Lee Kelleher.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
#if NET472
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.PropertyEditors;
#else
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Extensions;
#endif

namespace Umbraco.Community.Contentment.DataEditors
{
public abstract class DataListToDataPickerSourceBridge : IDataListSource, IDataPickerSource
{
public abstract string Name { get; }

public abstract string Description { get; }

public abstract string Icon { get; }

public abstract string Group { get; }

public abstract IEnumerable<ConfigurationField> Fields { get; }

public abstract Dictionary<string, object> DefaultValues { get; }

public abstract OverlaySize OverlaySize { get; }

public abstract IEnumerable<DataListItem> GetItems(Dictionary<string, object> config);

public virtual Task<IEnumerable<DataListItem>> GetItemsAsync(Dictionary<string, object> config, IEnumerable<string> values)
{
var items = GetItems(config);

if (items?.Any() == true)
{
return Task.FromResult(items.Where(x => values.Contains(x.Value) == true));
}

return Task.FromResult(Enumerable.Empty<DataListItem>());
}

public virtual Task<PagedResult<DataListItem>> SearchAsync(Dictionary<string, object> config, int pageNumber = 1, int pageSize = 12, string query = "")
{
var items = default(IEnumerable<DataListItem>);

if (string.IsNullOrWhiteSpace(query) == true)
{
items = GetItems(config);
}
else
{
items = GetItems(config)?.Where(x => x.Name?.InvariantContains(query) == true || x.Value?.InvariantStartsWith(query) == true);
}

if (items?.Any() == true)
{
var offset = (pageNumber - 1) * pageSize;
return Task.FromResult(new PagedResult<DataListItem>(items.Count(), pageNumber, pageSize)
{
Items = items.Skip(offset).Take(pageSize),
});
}

return Task.FromResult(new PagedResult<DataListItem>(-1, pageNumber, pageSize));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

namespace Umbraco.Community.Contentment.DataEditors
{
public sealed class EnumDataListSource : IDataListSource, IDataSourceValueConverter, IContentmentListTemplateItem
public sealed class EnumDataListSource : DataListToDataPickerSourceBridge, IDataListSource, IDataSourceValueConverter, IContentmentListTemplateItem
{
private readonly ConcurrentDictionary<Type, (List<DataListItem>, Dictionary<string, object>)> _lookup;
private readonly IIOHelper _ioHelper;
Expand Down Expand Up @@ -56,23 +56,23 @@ public EnumDataListSource(
_ioHelper = ioHelper;
}

public string Name => ".NET Enumeration";
public override string Name => ".NET Enumeration";

public string NameTemplate => default;

public string Description => "Select an enumeration from a .NET assembly as the data source.";
public override string Description => "Select an enumeration from a .NET assembly as the data source.";

public string DescriptionTemplate => "{{ enumType[1] }}";

public string Icon => "icon-indent";
public override string Icon => "icon-indent";

public string Group => Constants.Conventions.DataSourceGroups.DotNet;
public override string Group => Constants.Conventions.DataSourceGroups.DotNet;

public OverlaySize OverlaySize => OverlaySize.Small;
public override OverlaySize OverlaySize => OverlaySize.Small;

public Dictionary<string, object> DefaultValues => default;
public override Dictionary<string, object> DefaultValues => default;

public IEnumerable<ConfigurationField> Fields => new[]
public override IEnumerable<ConfigurationField> Fields => new[]
{
new ConfigurationField
{
Expand Down Expand Up @@ -134,7 +134,7 @@ public EnumDataListSource(
return (items, values);
}

public IEnumerable<DataListItem> GetItems(Dictionary<string, object> config)
public override IEnumerable<DataListItem> GetItems(Dictionary<string, object> config)
{
var type = GetValueType(config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

namespace Umbraco.Community.Contentment.DataEditors
{
public sealed class ExamineDataListSource : IDataListSource
public sealed class ExamineDataListSource : DataListToDataPickerSourceBridge, IDataListSource
{

private readonly IContentmentContentContext _contentmentContentContext;
Expand Down Expand Up @@ -102,17 +102,17 @@ public ExamineDataListSource(
_shortStringHelper = shortStringHelper;
}

public string Name => "Examine Query";
public override string Name => "Examine Query";

public string Description => "Populate the data source from an Examine query.";
public override string Description => "Populate the data source from an Examine query.";

public string Icon => "icon-search";
public override string Icon => "icon-search";

public string Group => Constants.Conventions.DataSourceGroups.Umbraco;
public override string Group => Constants.Conventions.DataSourceGroups.Umbraco;

public OverlaySize OverlaySize => OverlaySize.Small;
public override OverlaySize OverlaySize => OverlaySize.Small;

public IEnumerable<ConfigurationField> Fields => new[]
public override IEnumerable<ConfigurationField> Fields => new[]
{
new ConfigurationField
{
Expand Down Expand Up @@ -181,7 +181,7 @@ public ExamineDataListSource(
},
};

public Dictionary<string, object> DefaultValues => new Dictionary<string, object>
public override Dictionary<string, object> DefaultValues => new Dictionary<string, object>()
{
{ "examineIndex", UmbConstants.UmbracoIndexes.ExternalIndexName },
{ "luceneQuery", "+__IndexType:content" },
Expand All @@ -191,7 +191,7 @@ public ExamineDataListSource(
{ "descriptionField", string.Empty },
};

public IEnumerable<DataListItem> GetItems(Dictionary<string, object> config)
public override IEnumerable<DataListItem> GetItems(Dictionary<string, object> config)
{
var examineIndex = config.GetValueAs("examineIndex", UmbConstants.UmbracoIndexes.ExternalIndexName);
if (_examineManager.TryGetIndex(examineIndex, out var index) == true)
Expand Down
Loading

0 comments on commit a80fd56

Please sign in to comment.