Skip to content

Commit 97b8bc4

Browse files
authored
Merge pull request #14 from umbraco/temp-deploy-476
deploy-476 Nested content transfer issue
2 parents 97a0ae1 + d23eb35 commit 97b8bc4

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

src/Umbraco.Deploy.Contrib.Connectors/GridCellValueConnectors/LeBlenderGridCellValueConnector.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public class LeBlenderGridCellValueConnector : GridCellValueConnectorBase
1919
private readonly IMacroParser _macroParser;
2020
private readonly Lazy<ValueConnectorCollection> _valueConnectorsLazy;
2121

22+
internal static string MockPropertyTypeAlias = "mockLeBlenderPropertyTypeAlias";
23+
2224
public LeBlenderGridCellValueConnector(IDataTypeService dataTypeService, IMacroParser macroParser, Lazy<ValueConnectorCollection> valueConnectors)
2325
{
2426
if (dataTypeService == null) throw new ArgumentNullException(nameof(dataTypeService));
@@ -193,7 +195,7 @@ public override void SetValue(GridValue.GridControl control, Property property)
193195
continue;
194196
}
195197

196-
var propertyType = new PropertyType(dataType.PropertyEditorAlias, dataType.DatabaseType, "mockPropertyTypeAlias");
198+
var propertyType = new PropertyType(dataType.PropertyEditorAlias, dataType.DatabaseType, MockPropertyTypeAlias);
197199
propertyType.DataTypeDefinitionId = dataType.Id;
198200
// get the value connector for the property type
199201
var propValueConnector = ValueConnectors.Get(propertyType);

src/Umbraco.Deploy.Contrib.Connectors/ValueConnectors/ArchetypeValueConnector.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class ArchetypeValueConnector : IValueConnector
1919
private readonly Lazy<ValueConnectorCollection> _valueConnectorsLazy;
2020
public virtual IEnumerable<string> PropertyEditorAliases => new[] {"Imulus.Archetype"};
2121

22+
internal static string MockPropertyTypeAlias = "mockArchetypePropertyTypeAlias";
2223
private ValueConnectorCollection ValueConnectors => _valueConnectorsLazy.Value;
2324

2425
public ArchetypeValueConnector(IDataTypeService dataTypeService, IMacroParser macroParser, Lazy<ValueConnectorCollection> valueConnectors)
@@ -181,7 +182,7 @@ public void SetValue(IContentBase content, string alias, string value)
181182
}
182183

183184
// if the macro parser didn't convert the value then try to find a value connector that can and convert it
184-
var propertyType = new PropertyType(dataType.PropertyEditorAlias, dataType.DatabaseType, "mockPropertyTypeAlias");
185+
var propertyType = new PropertyType(dataType.PropertyEditorAlias, dataType.DatabaseType, MockPropertyTypeAlias);
185186
propertyType.DataTypeDefinitionId = dataType.Id;
186187
var propValueConnector = ValueConnectors.Get(propertyType);
187188
var mockProperty = new Property(propertyType);

src/Umbraco.Deploy.Contrib.Connectors/ValueConnectors/NestedContentValueConnector.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Umbraco.Core.Logging;
99
using Umbraco.Core.Models;
1010
using Umbraco.Core.Services;
11+
using Umbraco.Deploy.Contrib.Connectors.GridCellValueConnectors;
1112
using Umbraco.Deploy.ValueConnectors;
1213

1314
namespace Umbraco.Deploy.Contrib.Connectors.ValueConnectors
@@ -246,8 +247,12 @@ public void SetValue(IContentBase content, string alias, string value)
246247
}
247248
}
248249

249-
// NestedContent does not use formatting when serializing JSON values
250-
if (nestedContent.Length == 1)
250+
// This statement checks whether we have a single item being stored - and if this is stored inside a LeBlender value.
251+
// For some reason, LeBlender does not store an array of one object (like normal Nested Content would do) if the Nested
252+
// Content is inside a LeBlender property. Instead it simply stores an object - therefore we need to save single items
253+
// using JObject instead of JArray, if the current operation is being run from within a wrapping LeBlender property.
254+
// Note: NestedContent does not use formatting when serializing JSON values.
255+
if (nestedContent.Length == 1 && content.Properties[0]?.Alias == LeBlenderGridCellValueConnector.MockPropertyTypeAlias)
251256
value = JObject.FromObject(nestedContent.FirstOrDefault()).ToString(Formatting.None);
252257
else
253258
value = JArray.FromObject(nestedContent).ToString(Formatting.None);

src/Umbraco.Deploy.Contrib.Connectors/ValueConnectors/VortoValueConnector.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public class VortoValueConnector : IValueConnector
1919
private readonly IDataTypeService _dataTypeService;
2020
private readonly Lazy<ValueConnectorCollection> _valueConnectorsLazy;
2121

22+
internal static string MockPropertyTypeAlias = "mockVortoPropertyTypeAlias";
23+
2224
public VortoValueConnector(IDataTypeService dataTypeService, Lazy<ValueConnectorCollection> valueConnectors)
2325
{
2426
if (dataTypeService == null) throw new ArgumentNullException(nameof(dataTypeService));
@@ -154,7 +156,7 @@ public void SetValue(IContentBase content, string alias, string value)
154156
if (wrappedDataType == null)
155157
throw new InvalidOperationException($"Could not resolve the datatype used inside the Vorto property: {alias}");
156158

157-
var propertyType = new PropertyType(wrappedDataType, "mockPropertyType");
159+
var propertyType = new PropertyType(wrappedDataType, MockPropertyTypeAlias);
158160
var valueConnector = ValueConnectors.Get(propertyType);
159161

160162
// iterate values for each language

0 commit comments

Comments
 (0)