Skip to content

Commit

Permalink
Merge pull request #431 from leekelleher/dev/v5.x
Browse files Browse the repository at this point in the history
Preparing v5.1.0 release
  • Loading branch information
leekelleher authored Dec 6, 2024
2 parents 08bc56b + 05ff7e7 commit f70b4bc
Show file tree
Hide file tree
Showing 34 changed files with 468 additions and 158 deletions.
2 changes: 1 addition & 1 deletion .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![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)!
> If you are looking for **Contentment for Umbraco 15** (the new backoffice), [please see the latest progress updates](https://github.com/leekelleher/umbraco-contentment/discussions/357)!
### What is it?

Expand Down
3 changes: 2 additions & 1 deletion .github/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ Property Editors are:
## v6

- [Support for the new Umbraco backoffice, aka Bellissima](https://github.com/leekelleher/umbraco-contentment/discussions/357).
- Adds support for Umbraco 14 (.NET 8) _aka Bellissima_.
- ~Adds support for Umbraco 14 (.NET 8) _aka Bellissima_~.
- Adds support for Umbraco 15 (.NET 9).
- Removes support for Umbraco 13 (.NET 8).


Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.0.2
5.1.0
4 changes: 2 additions & 2 deletions src/Umbraco.Cms.13.x/Umbraco.Cms.13.x.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Umbraco.Cms" Version="13.2.0" />
<PackageReference Include="uSync" Version="13.1.3" />
<PackageReference Include="Umbraco.Cms" Version="13.5.2" />
<PackageReference Include="uSync" Version="13.2.5" />
<ProjectReference Include="..\Umbraco.Community.Contentment\Umbraco.Community.Contentment.csproj" />
</ItemGroup>

Expand Down
4 changes: 4 additions & 0 deletions src/Umbraco.Cms.13.x/appsettings-schema.usync.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@
"description": "Should the history view be on of off ? ",
"default": true
},
"HistoryFolder": {
"type": "string",
"description": "Location of the history folder."
},
"DefaultExtension": {
"type": "string",
"description": "Default file extension for the uSync files. ",
Expand Down
1 change: 0 additions & 1 deletion src/Umbraco.Community.Contentment.sln
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Visual Studio", "Visual Studio", "{7E3CB058-A757-42C9-9277-EB949E1D7D0E}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
Umbraco.Community.Contentment.sln.licenseheader = Umbraco.Community.Contentment.sln.licenseheader
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data Sources", "Data Sources", "{40B5A85D-28D1-4742-87E7-6306CC5F08C1}"
Expand Down
11 changes: 0 additions & 11 deletions src/Umbraco.Community.Contentment.sln.licenseheader

This file was deleted.

20 changes: 18 additions & 2 deletions src/Umbraco.Community.Contentment/DataEditors/Buttons/buttons.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/* Copyright © 2020 Lee Kelleher.
/* Copyright © 2020 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/. */

angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.Buttons.Controller", [
"$scope",
function ($scope) {
"eventsService",
function ($scope, eventsService) {

// console.log("buttons.model", $scope.model);

Expand Down Expand Up @@ -79,6 +80,21 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
$scope.umbProperty.setPropertyActions(vm.propertyActions);
}
}

var events = [];

events.push(eventsService.on("contentment.update.value", (event, args) => {
if (args.alias === $scope.model.alias) {
$scope.model.value = args.value;
init();
}
}));

$scope.$on("$destroy", () => {
for (var event in events) {
eventsService.unsubscribe(events[event]);
}
});
};

function clear() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/* Copyright © 2019 Lee Kelleher.
/* Copyright © 2019 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/. */

angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.CheckboxList.Controller", [
"$scope",
"eventsService",
"localizationService",
function ($scope, localizationService) {
function ($scope, eventsService, localizationService) {

// console.log("checkboxlist.model", $scope.model);

Expand Down Expand Up @@ -60,6 +61,21 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.
vm.toggle = toggle;
vm.toggleChecked = vm.items.every(item => item.checked);
}

var events = [];

events.push(eventsService.on("contentment.update.value", (event, args) => {
if (args.alias === $scope.model.alias) {
$scope.model.value = args.value;
init();
}
}));

$scope.$on("$destroy", () => {
for (var event in events) {
eventsService.unsubscribe(events[event]);
}
});
};

function changed(item) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright © 2019 Lee Kelleher.
/* Copyright © 2019 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/. */
Expand Down Expand Up @@ -65,11 +65,11 @@ angular.module("umbraco").controller("Umbraco.Community.Contentment.DataEditors.

config.expressions[item.key] = {};

if (item.nameTemplate) { // TODO: [LK:2022-07-05] Deprecated.
if (item.nameTemplate) {
config.expressions[item.key]["name"] = $interpolate(item.nameTemplate);
}

if (item.descriptionTemplate) { // TODO: [LK:2022-07-05] Deprecated.
if (item.descriptionTemplate) {
config.expressions[item.key]["description"] = $interpolate(item.descriptionTemplate);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
using Newtonsoft.Json.Linq;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Cms.Core.PropertyEditors.DeliveryApi;
using Umbraco.Extensions;

namespace Umbraco.Community.Contentment.DataEditors
{
public sealed class DataListValueConverter : PropertyValueConverterBase
public sealed class DataListValueConverter : PropertyValueConverterBase, IDeliveryApiPropertyValueConverter
{
private readonly Type _defaultObjectType = typeof(string);
private readonly ConfigurationEditorUtility _utility;
Expand All @@ -25,14 +26,7 @@ public DataListValueConverter(ConfigurationEditorUtility utility)

public override bool IsConverter(IPublishedPropertyType propertyType) => propertyType.EditorAlias.InvariantEquals(DataListDataEditor.DataEditorAlias);

public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
{
TryGetPropertyTypeConfiguration(propertyType, out var hasMultipleValues, out var valueType, out _);

return hasMultipleValues == true
? typeof(List<>).MakeGenericType(valueType)
: valueType;
}
public override Type GetPropertyValueType(IPublishedPropertyType propertyType) => GetPropertyValueTypeImpl(propertyType, isDeliveryApi: false);

public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType) => PropertyCacheLevel.Snapshot;

Expand All @@ -51,9 +45,90 @@ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
return base.ConvertSourceToIntermediate(owner, propertyType, source, preview);
}

public override object? ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object? inter, bool preview)
public override object? ConvertIntermediateToObject(
IPublishedElement owner,
IPublishedPropertyType propertyType,
PropertyCacheLevel referenceCacheLevel,
object? inter,
bool preview) => ConvertIntermediateToObjectImpl(owner, propertyType, referenceCacheLevel, inter, preview, isDeliveryApi: false, expanding: false);

public PropertyCacheLevel GetDeliveryApiPropertyCacheLevel(IPublishedPropertyType propertyType) => GetPropertyCacheLevel(propertyType);

public Type GetDeliveryApiPropertyValueType(IPublishedPropertyType propertyType) => GetPropertyValueTypeImpl(propertyType, isDeliveryApi: true);

public object? ConvertIntermediateToDeliveryApiObject(
IPublishedElement owner,
IPublishedPropertyType propertyType,
PropertyCacheLevel referenceCacheLevel,
object? inter,
bool preview,
bool expanding) => ConvertIntermediateToObjectImpl(owner, propertyType, referenceCacheLevel, inter, preview, isDeliveryApi: true, expanding);

private void TryGetPropertyTypeConfiguration(
IPublishedPropertyType propertyType,
out bool hasMultipleValues,
out Type valueType,
out Func<Type, string, object?>? converter,
bool isDeliveryApi = false,
bool expanding = false)
{
hasMultipleValues = false;
valueType = _defaultObjectType;
converter = default;

if (propertyType.DataType.Configuration is Dictionary<string, object> configuration &&
configuration.TryGetValue(DataListConfigurationEditor.DataSource, out var tmp1) == true &&
tmp1 is JArray array1 && array1.Count > 0 && array1[0] is JObject obj1 &&
obj1.Value<string>("key") is string key1 &&
configuration.TryGetValue(DataListConfigurationEditor.ListEditor, out var tmp2) == true &&
tmp2 is JArray array2 && array2.Count > 0 && array2[0] is JObject obj2 &&
obj2.Value<string>("key") is string key2)
{
var source = _utility.GetConfigurationEditor<IDataSourceValueConverter>(key1);
if (source is not null)
{
var config = obj1["value"]?.ToObject<Dictionary<string, object>>();

if (isDeliveryApi && source is IDataSourceDeliveryApiValueConverter deliveryApiSource)
{
valueType = deliveryApiSource.GetDeliveryApiValueType(config) ?? _defaultObjectType;
converter = (t, v) => deliveryApiSource.ConvertToDeliveryApiValue(t, v, expanding);
}
else
{
valueType = source.GetValueType(config) ?? _defaultObjectType;
converter = source.ConvertValue;
}
}

var editor = _utility.GetConfigurationEditor<IDataListEditor>(key2);
if (editor is not null)
{
var config = obj2["value"]?.ToObject<Dictionary<string, object>>();
hasMultipleValues = editor.HasMultipleValues(config);
}
}
}

private Type GetPropertyValueTypeImpl(IPublishedPropertyType propertyType, bool isDeliveryApi)
{
TryGetPropertyTypeConfiguration(propertyType, out var hasMultipleValues, out var valueType, out _, isDeliveryApi);

return hasMultipleValues == true
? typeof(List<>).MakeGenericType(valueType)
: valueType;
}

private object? ConvertIntermediateToObjectImpl(
IPublishedElement owner,
IPublishedPropertyType propertyType,
PropertyCacheLevel referenceCacheLevel,
object? inter,
bool preview,
bool isDeliveryApi,
bool expanding)
{
TryGetPropertyTypeConfiguration(propertyType, out var hasMultipleValues, out var valueType, out var converter);
TryGetPropertyTypeConfiguration(propertyType, out var hasMultipleValues, out var valueType, out var converter, isDeliveryApi, expanding);

if (inter is string value)
{
Expand Down Expand Up @@ -129,36 +204,5 @@ public override Type GetPropertyValueType(IPublishedPropertyType propertyType)

return base.ConvertIntermediateToObject(owner, propertyType, referenceCacheLevel, inter, preview);
}

private void TryGetPropertyTypeConfiguration(IPublishedPropertyType propertyType, out bool hasMultipleValues, out Type valueType, out Func<Type, string, object>? converter)
{
hasMultipleValues = false;
valueType = _defaultObjectType;
converter = default;

if (propertyType.DataType.Configuration is Dictionary<string, object> configuration &&
configuration.TryGetValue(DataListConfigurationEditor.DataSource, out var tmp1) == true &&
tmp1 is JArray array1 && array1.Count > 0 && array1[0] is JObject obj1 &&
obj1.Value<string>("key") is string key1 &&
configuration.TryGetValue(DataListConfigurationEditor.ListEditor, out var tmp2) == true &&
tmp2 is JArray array2 && array2.Count > 0 && array2[0] is JObject obj2 &&
obj2.Value<string>("key") is string key2)
{
var source = _utility.GetConfigurationEditor<IDataSourceValueConverter>(key1);
if (source is not null)
{
var config = obj1["value"]?.ToObject<Dictionary<string, object>>();
valueType = source.GetValueType(config) ?? _defaultObjectType;
converter = source.ConvertValue!;
}

var editor = _utility.GetConfigurationEditor<IDataListEditor>(key2);
if (editor is not null)
{
var config = obj2["value"]?.ToObject<Dictionary<string, object>>();
hasMultipleValues = editor.HasMultipleValues(config);
}
}
}
}
}
Loading

0 comments on commit f70b4bc

Please sign in to comment.