From 07ba627ba3df9754dfd88de31cd10e5670ee5354 Mon Sep 17 00:00:00 2001 From: mattbrailsford Date: Sat, 18 Mar 2017 13:33:49 +0000 Subject: [PATCH] Ditched the custome PropertyValueEditor in favour of the new SimpleInnerContentPropertyValueEditor --- .../StackedContentPropertyEditor.cs | 71 +------------------ 1 file changed, 1 insertion(+), 70 deletions(-) diff --git a/src/Our.Umbraco.StackedContent/PropertyEditors/StackedContentPropertyEditor.cs b/src/Our.Umbraco.StackedContent/PropertyEditors/StackedContentPropertyEditor.cs index 63ada09..b636b27 100644 --- a/src/Our.Umbraco.StackedContent/PropertyEditors/StackedContentPropertyEditor.cs +++ b/src/Our.Umbraco.StackedContent/PropertyEditors/StackedContentPropertyEditor.cs @@ -1,11 +1,6 @@ using System.Collections.Generic; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using Our.Umbraco.InnerContent.PropertyEditors; -using Umbraco.Core.Models; -using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; -using Umbraco.Core.Services; namespace Our.Umbraco.StackedContent.PropertyEditors { @@ -64,71 +59,7 @@ internal class StackPreValueEditor : PreValueEditor protected override PropertyValueEditor CreateValueEditor() { - return new StackPropertyValueEditor(base.CreateValueEditor()); - } - - internal class StackPropertyValueEditor : InnerContentPropertyValueEditorWrapper - { - public StackPropertyValueEditor(PropertyValueEditor wrapped) - : base(wrapped) - { } - - public override string ConvertDbToString(Property property, PropertyType propertyType, IDataTypeService dataTypeService) - { - // Convert / validate value - if (property.Value == null || string.IsNullOrWhiteSpace(property.Value.ToString())) - return string.Empty; - - var value = JsonConvert.DeserializeObject(property.Value.ToString()); - if (value == null) - return string.Empty; - - // Process value - ConvertInnerContentDbToString(value); - - // Update the value on the property - property.Value = JsonConvert.SerializeObject(value); - - // Pass the call down - return base.ConvertDbToString(property, propertyType, dataTypeService); - } - - public override object ConvertDbToEditor(Property property, PropertyType propertyType, IDataTypeService dataTypeService) - { - // Convert / validate value - if (property.Value == null || string.IsNullOrWhiteSpace(property.Value.ToString())) - return string.Empty; - - var value = JsonConvert.DeserializeObject(property.Value.ToString()); - if (value == null) - return string.Empty; - - // Process value - ConvertInnerContentDbToEditor(value); - - // Update the value on the property - property.Value = JsonConvert.SerializeObject(value); - - // Pass the call down - return base.ConvertDbToEditor(property, propertyType, dataTypeService); - } - - public override object ConvertEditorToDb(ContentPropertyData editorValue, object currentValue) - { - // Convert / validate value - if (editorValue.Value == null || string.IsNullOrWhiteSpace(editorValue.Value.ToString())) - return null; - - var value = JsonConvert.DeserializeObject(editorValue.Value.ToString()); - if (value == null || value.Count == 0) - return null; - - // Process value - ConvertInnerContentEditorToDb(value); - - // Return value - return JsonConvert.SerializeObject(value); - } + return new SimpleInnerContentPropertyValueEditor(base.CreateValueEditor()); } #endregion