Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit 409e528

Browse files
committed
Merge branch 'develop'
2 parents 4204ee1 + b38267b commit 409e528

File tree

9 files changed

+126
-11
lines changed

9 files changed

+126
-11
lines changed

.github/NUGET_README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## Custom Value Converter for Umbraco
2+
3+
A wrapper property-editor (for [Umbraco](https://github.com/umbraco/Umbraco-CMS/)) that lets you pick a custom/alternative `ValueConverter` for a specified data-type.
4+
5+
For more information, please visit the GitHub repository:
6+
<https://github.com/leekelleher/umbraco-custom-valueconverter>

.github/README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
## Custom Value Converter for Umbraco
22

3-
A wrapper property-editor that lets you pick a custom/alternative `ValueConverter`.
3+
A wrapper property-editor (for Umbraco) that lets you pick a custom/alternative `ValueConverter` for a specified data-type.
44

5+
6+
### Installation
7+
8+
_**Please note,**_ currently you can only install a package from the [NuGet package repository](https://www.nuget.org/packages/Our.Umbraco.Community.CustomValueConverter).
9+
10+
dotnet add package Our.Umbraco.Community.CustomValueConverter
11+
12+
13+
### License
14+
15+
Copyright &copy; [Lee Kelleher](https://leekelleher.com).
16+
17+
All source code is licensed under the [Mozilla Public License](../LICENSE).
18+
19+
20+
#### Logo
21+
22+
The package logo uses the [Replace](https://thenounproject.com/icon/replace-212135/) icon (by [Arthur Shlain](https://thenounproject.com/ArtZ91/)) icon from the [Noun Project](https://thenounproject.com), licensed under [CC BY 3.0 US](https://creativecommons.org/licenses/by/3.0/us/).

.github/workflows/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release Package
2+
3+
on:
4+
push:
5+
tags:
6+
- "[0-9]+.[0-9]+.[0-9]+"
7+
8+
jobs:
9+
build:
10+
11+
runs-on: windows-latest
12+
13+
steps:
14+
15+
- name: Checkout repository
16+
uses: actions/checkout@v3
17+
18+
- name: Setup .NET
19+
uses: actions/setup-dotnet@v2
20+
with:
21+
dotnet-version: 5.0.x
22+
23+
- name: Build project
24+
run: dotnet build src\Umbraco.Community.CustomValueConverter.csproj --configuration Release
25+
26+
- name: Push to NuGet
27+
run: dotnet nuget push **\*.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json
28+
29+
- name: Push to GitHub
30+
run: dotnet nuget push **\*.nupkg --api-key ${{secrets.LK_GITHUB_PAT}} --source https://nuget.pkg.github.com/leekelleher/index.json

docs/assets/img/logo.png

7.77 KB
Loading

docs/assets/img/logo.psd

574 KB
Binary file not shown.

src/App_Plugins/CustomValueConverter/notes.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,9 @@
33
- License, v. 2.0. If a copy of the MPL was not distributed with this
44
- file, You can obtain one at https://mozilla.org/MPL/2.0/. -->
55

6-
<div class="umb-readonlyvalue" ng-bind-html="model.config.notes | safe_html"></div>
6+
<div class="umb-readonlyvalue">
7+
<details class="well well-small">
8+
<summary><strong ng-bind="model.config.heading"></strong></summary>
9+
<div ng-bind-html="model.config.message | safe_html"></div>
10+
</details>
11+
</div>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/* Copyright © 2022 Lee Kelleher.
2+
* This Source Code Form is subject to the terms of the Mozilla Public
3+
* License, v. 2.0. If a copy of the MPL was not distributed with this
4+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
5+
6+
using System.Collections.Generic;
7+
8+
#if NET472
9+
using Umbraco.Core;
10+
using Umbraco.Core.Deploy;
11+
using Umbraco.Core.Models;
12+
using Umbraco.Core.PropertyEditors;
13+
using Umbraco.Core.Serialization;
14+
#else
15+
using Umbraco.Cms.Core;
16+
using Umbraco.Cms.Core.PropertyEditors;
17+
using Umbraco.Extensions;
18+
using Umbraco.Cms.Core.Models;
19+
using Umbraco.Cms.Core.Deploy;
20+
using Umbraco.Cms.Core.Serialization;
21+
#endif
22+
23+
namespace Umbraco.Community.CustomValueConverter.DataEditor
24+
{
25+
internal sealed class CustomValueConverterConfigurationConnector : IDataTypeConfigurationConnector
26+
{
27+
public IEnumerable<string> PropertyEditorAliases => new[] { CustomValueConverterDataEditor.DataEditorName };
28+
29+
private readonly IConfigurationEditorJsonSerializer _configurationEditorJsonSerializer;
30+
31+
public CustomValueConverterConfigurationConnector(IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
32+
{
33+
_configurationEditorJsonSerializer = configurationEditorJsonSerializer;
34+
}
35+
36+
public object FromArtifact(IDataType dataType, string configuration)
37+
{
38+
var dataTypeConfigurationEditor = dataType.Editor.GetConfigurationEditor();
39+
return dataTypeConfigurationEditor.FromDatabase(configuration, _configurationEditorJsonSerializer);
40+
}
41+
42+
public string ToArtifact(IDataType dataType, ICollection<ArtifactDependency> dependencies)
43+
{
44+
if (dataType.Configuration is Dictionary<string, object> config &&
45+
config.TryGetValueAs(CustomValueConverterConfigurationEditor.DataType, out GuidUdi udi) == true)
46+
{
47+
dependencies.Add(new ArtifactDependency(udi, false, ArtifactDependencyMode.Match));
48+
}
49+
50+
#if NET472
51+
return ConfigurationEditor.ToDatabase(dataType.Configuration);
52+
#else
53+
return ConfigurationEditor.ToDatabase(dataType.Configuration, _configurationEditorJsonSerializer);
54+
#endif
55+
}
56+
}
57+
}

src/DataEditor/CustomValueConverterConfigurationEditor.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,11 @@ public CustomValueConverterConfigurationEditor(
5353
View = ioHelper.ResolveRelativeOrVirtualUrl(NotesViewPath),
5454
Config = new Dictionary<string, object>
5555
{
56-
{ "notes", @"<details class=""well well-small"">
57-
<summary><strong>A note about changing the default value converter.</strong></summary>
58-
<p>Some of Umbraco's built-in value converters are designed to work explicitly with their associated property editor and data type configuration.</p>
56+
{ "heading", "A note about changing the default value converter." },
57+
{ "message", @"<p>Some of Umbraco's built-in value converters are designed to work explicitly with their associated property editor and data type configuration.</p>
5958
<p>This means they may not be hot-swappable. For example, the <code>MediaPicker</code> and <code>MultiNodeTreePicker</code> value converters will try to detect if the data type is configured for single or multiple use. So if you wanted to change the value converter for a textstring editor, then the target value converter would not be aware of the intended configuration, and potentially cause an error.</p>
6059
<p>For primitive values, e.g. integer, decimal, string, boolean. These should work as expected.</p>
61-
<p>If you are using you own custom value converter code, then you don't need to be concerned with this note, you will have full control over the value conversion.</p>
62-
</details>" },
60+
<p>If you are using you own custom value converter code, then you don't need to be concerned with this note, you will have full control over the value conversion.</p>" },
6361
},
6462
HideLabel = true,
6563
});

src/Umbraco.Community.CustomValueConverter.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
<Company>Package Factory</Company>
1313
<Authors>Lee Kelleher</Authors>
1414
<Copyright>2022 © Lee Kelleher</Copyright>
15+
<PackageIcon>icon.png</PackageIcon>
16+
<PackageReadmeFile>README.md</PackageReadmeFile>
1517
<PackageLicenseExpression>MPL-2.0</PackageLicenseExpression>
1618
<PackageProjectUrl>https://github.com/leekelleher/umbraco-custom-valueconverter</PackageProjectUrl>
1719
<RepositoryUrl>https://github.com/leekelleher/umbraco-custom-valueconverter</RepositoryUrl>
@@ -43,10 +45,9 @@
4345
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
4446
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
4547
</Content>
46-
<None Include="build\**\*.*">
47-
<Pack>True</Pack>
48-
<PackagePath>buildTransitive</PackagePath>
49-
</None>
48+
<None Include="build\*.targets" Pack="true" PackagePath="buildTransitive" />
49+
<None Include="..\docs\assets\img\logo.png" Pack="true" PackagePath="\icon.png" />
50+
<None Include="..\.github\NUGET_README.md" Pack="true" PackagePath="\README.md" />
5051
</ItemGroup>
5152

5253
</Project>

0 commit comments

Comments
 (0)