Skip to content
This repository was archived by the owner on Feb 10, 2024. It is now read-only.

Commit c4b8549

Browse files
Fixed isssue #3 by serializing value to string before passing to detached property
1 parent ccce292 commit c4b8549

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

Package.build.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
****************************************
2121
-->
2222
<PropertyGroup>
23-
<PackageVersion>0.1</PackageVersion>
23+
<PackageVersion>0.1.1</PackageVersion>
2424
<ProjectName>Our.Umbraco.DocTypeGridEditor</ProjectName>
2525
<BuildConfig>Debug</BuildConfig>
2626
</PropertyGroup>
@@ -52,12 +52,12 @@
5252
Encoding="ASCII"
5353
Files="$(ProjectDir)\Properties\AssemblyInfo.cs"
5454
Regex="AssemblyVersion\(&quot;.*&quot;\)\]"
55-
ReplacementText="AssemblyVersion(&quot;$(PackageVersion).0.0&quot;)]" />
55+
ReplacementText="AssemblyVersion(&quot;$(PackageVersion)&quot;)]" />
5656
<FileUpdate
5757
Encoding="ASCII"
5858
Files="$(ProjectDir)\Properties\AssemblyInfo.cs"
5959
Regex="AssemblyFileVersion\(&quot;.*&quot;\)\]"
60-
ReplacementText="AssemblyFileVersion(&quot;$(PackageVersion).0.0&quot;)]" />
60+
ReplacementText="AssemblyFileVersion(&quot;$(PackageVersion)&quot;)]" />
6161
</Target>
6262

6363
<!-- COMPILE -->
20.5 KB
Binary file not shown.

Package/Doc_Type_Grid_Editor_0.1.zip

-20.2 KB
Binary file not shown.

Src/Our.Umbraco.DocTypeGridEditor/Helpers/DocTypeGridEditorHelper.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Linq;
34
using Newtonsoft.Json;
45
using Newtonsoft.Json.Linq;
56
using Our.Umbraco.DocTypeGridEditor.Models;
@@ -31,15 +32,16 @@ public static IPublishedContent ConvertValueToContent(string id, string docTypeA
3132
if (Guid.TryParse(docTypeAlias, out docTypeGuid))
3233
docTypeAlias = Services.ContentTypeService.GetAliasByGuid(docTypeGuid);
3334

34-
var contentType = PublishedContentType.Get(PublishedItemType.Content, docTypeAlias);
35-
var properties = new List<IPublishedProperty>();
35+
var publishedContentType = PublishedContentType.Get(PublishedItemType.Content, docTypeAlias);
36+
var contentType = ApplicationContext.Current.Services.ContentTypeService.GetContentType(docTypeAlias);
37+
var properties = new List<IPublishedProperty>();
3638

3739
// Convert all the properties
3840
var data = JsonConvert.DeserializeObject(dataJson);
3941
var propValues = ((JObject) data).ToObject<Dictionary<string, object>>();
4042
foreach (var jProp in propValues)
4143
{
42-
var propType = contentType.GetPropertyType(jProp.Key);
44+
var propType = publishedContentType.GetPropertyType(jProp.Key);
4345
if (propType != null)
4446
{
4547
/* Because we never store the value in the database, we never run the property editors
@@ -58,7 +60,14 @@ public static IPublishedContent ConvertValueToContent(string id, string docTypeA
5860

5961
var newValue = propEditor.ValueEditor.ConvertEditorToDb(contentPropData, jProp.Value);
6062

61-
properties.Add(new DetachedPublishedProperty(propType, newValue));
63+
/* Now that we have the DB stored value, we actually need to then convert it into it's
64+
* XML serialized state as expected by the published property by calling ConvertDbToString
65+
*/
66+
var propType2 = contentType.PropertyTypes.Single(x => x.Alias == propType.PropertyTypeAlias);
67+
var newValue2 = propEditor.ValueEditor.ConvertDbToString(new Property(propType2, newValue), propType2,
68+
ApplicationContext.Current.Services.DataTypeService);
69+
70+
properties.Add(new DetachedPublishedProperty(propType, newValue2));
6271
}
6372
}
6473

@@ -69,7 +78,7 @@ public static IPublishedContent ConvertValueToContent(string id, string docTypeA
6978
// Do nothing, we just want to parse out the name if we can
7079
}
7180

72-
return new DetachedPublishedContent(nameObj == null ? null : nameObj.ToString(), contentType,
81+
return new DetachedPublishedContent(nameObj == null ? null : nameObj.ToString(), publishedContentType,
7382
properties.ToArray());
7483
}
7584
});

Src/Our.Umbraco.DocTypeGridEditor/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@
3131
//
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
34-
// [assembly: AssemblyVersion("0.1.0.0")]
35-
[assembly: AssemblyVersion("0.1.0.0")]
36-
[assembly: AssemblyFileVersion("0.1.0.0")]
34+
// [assembly: AssemblyVersion("0.1.1")]
35+
[assembly: AssemblyVersion("0.1.1")]
36+
[assembly: AssemblyFileVersion("0.1.1")]

0 commit comments

Comments
 (0)