+ @Umbraco.Field(item, "bodyText")
+ }
+}
+```
+
+#### Single Item Mode
+
+If your **Nested Content** property editor is configured in single item mode then the value converter will automatically know this and will return a single `IPublishedContent` entity rather than an `IEnumerable` list. Therefore, when using **Nested Content** in single item mode, you can simply call `GetPropertyValue` with a generic type of `IPublishedContent` and you can start accessing the entities property straight away, rather than having to then fetch it from a list first.
+
+Example:
+```csharp
+@inherits Umbraco.Web.Mvc.UmbracoViewPage
+@{
+ var item = Model.GetPropertyValue ("myProperyAlias");
+}
+
@item.GetPropertyValue("name")
+ @Umbraco.Field(item, "bodyText")
+```
+
+---
+
+### Useful Links
+
+* [Source Code](https://github.com/leekelleher/umbraco-nested-content)
+* [Our Umbraco Project Page](http://our.umbraco.org/projects/backoffice-extensions/nested-content)
diff --git a/.nuget/NuGet.Config b/src/.nuget/NuGet.Config
similarity index 100%
rename from .nuget/NuGet.Config
rename to src/.nuget/NuGet.Config
diff --git a/.nuget/NuGet.exe b/src/.nuget/NuGet.exe
similarity index 100%
rename from .nuget/NuGet.exe
rename to src/.nuget/NuGet.exe
diff --git a/.nuget/NuGet.targets b/src/.nuget/NuGet.targets
similarity index 100%
rename from .nuget/NuGet.targets
rename to src/.nuget/NuGet.targets
diff --git a/Our.Umbraco.NestedContent.sln b/src/Our.Umbraco.NestedContent.sln
similarity index 53%
rename from Our.Umbraco.NestedContent.sln
rename to src/Our.Umbraco.NestedContent.sln
index fb26052..9362de1 100644
--- a/Our.Umbraco.NestedContent.sln
+++ b/src/Our.Umbraco.NestedContent.sln
@@ -1,24 +1,32 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
-VisualStudioVersion = 12.0.21005.1
+VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{CEE9961C-D747-40CD-B0B2-868D6B46833E}"
ProjectSection(SolutionItems) = preProject
.nuget\NuGet.Config = .nuget\NuGet.Config
- .nuget\NuGet.exe = .nuget\NuGet.exe
.nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Package", "Package", "{D588B45D-9E67-4136-8271-2B8724C8165F}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Our.Umbraco.NestedContent", "Our.Umbraco.NestedContent\Our.Umbraco.NestedContent.csproj", "{641D5625-F5B4-4B23-875A-4233C507F37D}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build Package", "Build Package", "{F74D7367-2138-4CC2-BD71-22C514BC451C}"
ProjectSection(SolutionItems) = preProject
- Package.build.cmd = Package.build.cmd
- Package.build.xml = Package.build.xml
- Package.xml = Package.xml
- README.markdown = README.markdown
+ ..\appveyor.yml = ..\appveyor.yml
+ ..\build-appveyor.cmd = ..\build-appveyor.cmd
+ ..\build.cmd = ..\build.cmd
+ ..\build\package.nuspec = ..\build\package.nuspec
+ ..\build\package.proj = ..\build\package.proj
+ ..\build\package.xml = ..\build\package.xml
EndProjectSection
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Our.Umbraco.NestedContent", "Src\Our.Umbraco.NestedContent\Our.Umbraco.NestedContent.csproj", "{641D5625-F5B4-4B23-875A-4233C507F37D}"
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2E1F9B00-9D88-460A-8F74-43F517DD913C}"
+ ProjectSection(SolutionItems) = preProject
+ ..\CONTRIBUTING.md = ..\CONTRIBUTING.md
+ ..\LICENSE.md = ..\LICENSE.md
+ ..\README.md = ..\README.md
+ EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -34,4 +42,8 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {CEE9961C-D747-40CD-B0B2-868D6B46833E} = {2E1F9B00-9D88-460A-8F74-43F517DD913C}
+ {F74D7367-2138-4CC2-BD71-22C514BC451C} = {2E1F9B00-9D88-460A-8F74-43F517DD913C}
+ EndGlobalSection
EndGlobal
diff --git a/Src/Our.Umbraco.NestedContent/Bootstrap.cs b/src/Our.Umbraco.NestedContent/Bootstrap.cs
similarity index 80%
rename from Src/Our.Umbraco.NestedContent/Bootstrap.cs
rename to src/Our.Umbraco.NestedContent/Bootstrap.cs
index a6e20c0..311294e 100644
--- a/Src/Our.Umbraco.NestedContent/Bootstrap.cs
+++ b/src/Our.Umbraco.NestedContent/Bootstrap.cs
@@ -16,12 +16,9 @@ private void ExpireCache(IDataTypeService sender, SaveEventArgs(string.Format("ConvertDataToSource ({0})", propertyType.DataTypeId)))
+ {
+ using (DisposableTimer.DebugDuration(string.Format("ConvertDataToSource ({0})", propertyType.DataTypeId)))
{
if (source != null && !source.ToString().IsNullOrWhiteSpace())
{
var rawValue = JsonConvert.DeserializeObject>(source.ToString());
var processedValue = new List();
- var preValue = NestedContentHelper.GetPreValuesDictionaryByDataTypeId(propertyType.DataTypeId);
- var contentType = NestedContentHelper.GetContentTypeFromPreValue(propertyType.DataTypeId);
- if (contentType == null)
- return null;
-
- var publishedContentType = PublishedContentType.Get(PublishedItemType.Content, contentType.Alias);
- if (publishedContentType == null)
- return null;
+ var preValueCollection = NestedContentHelper.GetPreValuesCollectionByDataTypeId(propertyType.DataTypeId);
+ var preValueDictionary = preValueCollection.AsPreValueDictionary();
for (var i = 0; i < rawValue.Count; i++)
{
- var o = rawValue[i];
- var propValues = ((JObject)o).ToObject>();
+ var item = (JObject)rawValue[i];
+
+ // Convert from old style (v.0.1.1) data format if necessary
+ // - Please note: This call has virtually no impact on rendering performance for new style (>v0.1.1).
+ // Even so, this should be removed eventually, when it's safe to assume that there is
+ // no longer any need for conversion.
+ NestedContentHelper.ConvertItemValueFromV011(item, propertyType.DataTypeId, ref preValueCollection);
+
+ var contentTypeAlias = NestedContentHelper.GetContentTypeAliasFromItem(item);
+ if (string.IsNullOrEmpty(contentTypeAlias))
+ {
+ continue;
+ }
+
+ var publishedContentType = PublishedContentType.Get(PublishedItemType.Content, contentTypeAlias);
+ if (publishedContentType == null)
+ {
+ continue;
+ }
+
+ var propValues = item.ToObject>();
var properties = new List();
foreach (var jProp in propValues)
@@ -71,13 +85,17 @@ public override object ConvertDataToSource(PublishedPropertyType propertyType, o
// Do nothing, we just want to parse out the name if we can
}
- processedValue.Add(new DetachedPublishedContent(nameObj == null ? null : nameObj.ToString(), publishedContentType, properties.ToArray()));
+ processedValue.Add(new DetachedPublishedContent(
+ nameObj == null ? null : nameObj.ToString(),
+ publishedContentType,
+ properties.ToArray(),
+ i));
}
// Detect min/max items == 1 and just return a single IPublishedContent
int minItems, maxItems;
- if (preValue.ContainsKey("minItems") && int.TryParse(preValue["minItems"], out minItems) && minItems == 1
- && preValue.ContainsKey("maxItems") && int.TryParse(preValue["maxItems"], out maxItems) && maxItems == 1)
+ if (preValueDictionary.ContainsKey("minItems") && int.TryParse(preValueDictionary["minItems"], out minItems) && minItems == 1
+ && preValueDictionary.ContainsKey("maxItems") && int.TryParse(preValueDictionary["maxItems"], out maxItems) && maxItems == 1)
{
return processedValue.FirstOrDefault();
}
@@ -85,7 +103,7 @@ public override object ConvertDataToSource(PublishedPropertyType propertyType, o
return processedValue;
}
}
- }
+ }
catch (Exception e)
{
LogHelper.Error("Error converting value", e);
@@ -94,4 +112,4 @@ public override object ConvertDataToSource(PublishedPropertyType propertyType, o
return null;
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Our.Umbraco.NestedContent/Extensions/ContentTypeServiceExtensions.cs b/src/Our.Umbraco.NestedContent/Extensions/ContentTypeServiceExtensions.cs
new file mode 100644
index 0000000..735e651
--- /dev/null
+++ b/src/Our.Umbraco.NestedContent/Extensions/ContentTypeServiceExtensions.cs
@@ -0,0 +1,7 @@
+namespace Our.Umbraco.NestedContent.Extensions
+{
+ internal static class ContentTypeServiceExtensions
+ {
+ // implementation obsolete as of PR #4 - empty class left for future expansion
+ }
+}
\ No newline at end of file
diff --git a/Src/Our.Umbraco.NestedContent/Extensions/PreValueCollectionExtensions.cs b/src/Our.Umbraco.NestedContent/Extensions/PreValueCollectionExtensions.cs
similarity index 99%
rename from Src/Our.Umbraco.NestedContent/Extensions/PreValueCollectionExtensions.cs
rename to src/Our.Umbraco.NestedContent/Extensions/PreValueCollectionExtensions.cs
index de0f6a5..d6a6de9 100644
--- a/Src/Our.Umbraco.NestedContent/Extensions/PreValueCollectionExtensions.cs
+++ b/src/Our.Umbraco.NestedContent/Extensions/PreValueCollectionExtensions.cs
@@ -11,4 +11,4 @@ public static IDictionary AsPreValueDictionary(this PreValueColl
return preValue.PreValuesAsDictionary.ToDictionary(x => x.Key, x => x.Value.Value);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Our.Umbraco.NestedContent/Helpers/NestedContentHelper.cs b/src/Our.Umbraco.NestedContent/Helpers/NestedContentHelper.cs
new file mode 100644
index 0000000..c0f32ff
--- /dev/null
+++ b/src/Our.Umbraco.NestedContent/Helpers/NestedContentHelper.cs
@@ -0,0 +1,125 @@
+using System;
+using System.Linq;
+using Newtonsoft.Json.Linq;
+using Our.Umbraco.NestedContent.Extensions;
+using Our.Umbraco.NestedContent.PropertyEditors;
+using Umbraco.Core;
+using Umbraco.Core.Models;
+
+namespace Our.Umbraco.NestedContent.Helpers
+{
+ internal static class NestedContentHelper
+ {
+ public static PreValueCollection GetPreValuesCollectionByDataTypeId(int dtdId)
+ {
+ var preValueCollection = (PreValueCollection)ApplicationContext.Current.ApplicationCache.RuntimeCache.GetCacheItem(
+ string.Concat("Our.Umbraco.NestedContent.GetPreValuesCollectionByDataTypeId_", dtdId),
+ () => ApplicationContext.Current.Services.DataTypeService.GetPreValuesCollectionByDataTypeId(dtdId));
+
+ return preValueCollection;
+ }
+
+ public static string GetContentTypeAliasFromItem(JObject item)
+ {
+ var contentTypeAliasProperty = item[NestedContentPropertyEditor.ContentTypeAliasPropertyKey];
+ if (contentTypeAliasProperty == null)
+ {
+ return null;
+ }
+
+ return contentTypeAliasProperty.ToObject();
+ }
+
+ public static IContentType GetContentTypeFromItem(JObject item)
+ {
+ var contentTypeAlias = GetContentTypeAliasFromItem(item);
+ if (string.IsNullOrEmpty(contentTypeAlias))
+ {
+ return null;
+ }
+
+ return ApplicationContext.Current.Services.ContentTypeService.GetContentType(contentTypeAlias);
+ }
+
+ #region Conversion from v0.1.1 data formats
+
+ public static void ConvertItemValueFromV011(JObject item, int dtdId, ref PreValueCollection preValues)
+ {
+ var contentTypeAlias = GetContentTypeAliasFromItem(item);
+ if (contentTypeAlias != null)
+ {
+ // the item is already in >v0.1.1 format
+ return;
+ }
+
+ // old style (v0.1.1) data, let's attempt a conversion
+ // - get the prevalues (if they're not loaded already)
+ preValues = preValues ?? GetPreValuesCollectionByDataTypeId(dtdId);
+
+ // - convert the prevalues (if necessary)
+ ConvertPreValueCollectionFromV011(preValues);
+
+ // - get the content types prevalue as JArray
+ var preValuesAsDictionary = preValues.AsPreValueDictionary();
+ if (!preValuesAsDictionary.ContainsKey(ContentTypesPreValueKey) || string.IsNullOrEmpty(preValuesAsDictionary[ContentTypesPreValueKey]) != false)
+ {
+ return;
+ }
+
+ var preValueContentTypes = JArray.Parse(preValuesAsDictionary[ContentTypesPreValueKey]);
+ if (preValueContentTypes.Any())
+ {
+ // the only thing we can really do is assume that the item is the first available content type
+ item[NestedContentPropertyEditor.ContentTypeAliasPropertyKey] = preValueContentTypes.First().Value("ncAlias");
+ }
+ }
+
+ public static void ConvertPreValueCollectionFromV011(PreValueCollection preValueCollection)
+ {
+ if (preValueCollection == null)
+ {
+ return;
+ }
+
+ var persistedPreValuesAsDictionary = preValueCollection.AsPreValueDictionary();
+
+ // do we have a "docTypeGuid" prevalue and no "contentTypes" prevalue?
+ if (persistedPreValuesAsDictionary.ContainsKey("docTypeGuid") == false || persistedPreValuesAsDictionary.ContainsKey(ContentTypesPreValueKey))
+ {
+ // the prevalues are already in >v0.1.1 format
+ return;
+ }
+
+ // attempt to parse the doc type guid
+ Guid guid;
+ if (Guid.TryParse(persistedPreValuesAsDictionary["docTypeGuid"], out guid) == false)
+ {
+ // this shouldn't happen... but just in case.
+ return;
+ }
+
+ // find the content type
+ var contentType = ApplicationContext.Current.Services.ContentTypeService.GetAllContentTypes().FirstOrDefault(c => c.Key == guid);
+ if (contentType == null)
+ {
+ return;
+ }
+
+ // add a prevalue in the format expected by the new (>0.1.1) content type picker/configurator
+ preValueCollection.PreValuesAsDictionary[ContentTypesPreValueKey] = new PreValue(
+ string.Format(@"[{{""ncAlias"": ""{0}"", ""ncTabAlias"": ""{1}"", ""nameTemplate"": ""{2}"", }}]",
+ contentType.Alias,
+ persistedPreValuesAsDictionary["tabAlias"],
+ persistedPreValuesAsDictionary["nameTemplate"]
+ )
+ );
+ }
+
+ private static string ContentTypesPreValueKey
+ {
+ get { return NestedContentPropertyEditor.NestedContentPreValueEditor.ContentTypesPreValueKey; }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Src/Our.Umbraco.NestedContent/Models/DetachedPublishedContent.cs b/src/Our.Umbraco.NestedContent/Models/DetachedPublishedContent.cs
similarity index 95%
rename from Src/Our.Umbraco.NestedContent/Models/DetachedPublishedContent.cs
rename to src/Our.Umbraco.NestedContent/Models/DetachedPublishedContent.cs
index 1df3a04..d8bd5a6 100644
--- a/Src/Our.Umbraco.NestedContent/Models/DetachedPublishedContent.cs
+++ b/src/Our.Umbraco.NestedContent/Models/DetachedPublishedContent.cs
@@ -13,16 +13,19 @@ internal class DetachedPublishedContent : PublishedContentBase
private readonly string _name;
private readonly PublishedContentType _contentType;
private readonly IEnumerable _properties;
+ private readonly int _sortOrder;
private readonly bool _isPreviewing;
public DetachedPublishedContent(string name,
PublishedContentType contentType,
IEnumerable properties,
+ int sortOrder = 0,
bool isPreviewing = false)
{
_name = name;
_contentType = contentType;
_properties = properties;
+ _sortOrder = sortOrder;
_isPreviewing = isPreviewing;
}
@@ -96,7 +99,7 @@ public override int TemplateId
public override int SortOrder
{
- get { return 0; }
+ get { return _sortOrder; }
}
public override string UrlName
@@ -149,4 +152,4 @@ public override int Level
get { return 0; }
}
}
-}
+}
\ No newline at end of file
diff --git a/Src/Our.Umbraco.NestedContent/Models/DetachedPublishedProperty.cs b/src/Our.Umbraco.NestedContent/Models/DetachedPublishedProperty.cs
similarity index 98%
rename from Src/Our.Umbraco.NestedContent/Models/DetachedPublishedProperty.cs
rename to src/Our.Umbraco.NestedContent/Models/DetachedPublishedProperty.cs
index de73e46..e85dfbc 100644
--- a/Src/Our.Umbraco.NestedContent/Models/DetachedPublishedProperty.cs
+++ b/src/Our.Umbraco.NestedContent/Models/DetachedPublishedProperty.cs
@@ -15,7 +15,8 @@ internal class DetachedPublishedProperty : IPublishedProperty
public DetachedPublishedProperty(PublishedPropertyType propertyType, object value)
: this(propertyType, value, false)
- { }
+ {
+ }
public DetachedPublishedProperty(PublishedPropertyType propertyType, object value, bool isPreview)
{
@@ -43,7 +44,9 @@ public bool HasValue
}
public object DataValue { get { return _rawValue; } }
+
public object Value { get { return _objectValue.Value; } }
+
public object XPathValue { get { return _xpathValue.Value; } }
}
-}
+}
\ No newline at end of file
diff --git a/Src/Our.Umbraco.NestedContent/Our.Umbraco.NestedContent.csproj b/src/Our.Umbraco.NestedContent/Our.Umbraco.NestedContent.csproj
similarity index 61%
rename from Src/Our.Umbraco.NestedContent/Our.Umbraco.NestedContent.csproj
rename to src/Our.Umbraco.NestedContent/Our.Umbraco.NestedContent.csproj
index 11dc177..238a18f 100644
--- a/Src/Our.Umbraco.NestedContent/Our.Umbraco.NestedContent.csproj
+++ b/src/Our.Umbraco.NestedContent/Our.Umbraco.NestedContent.csproj
@@ -11,7 +11,7 @@
Our.Umbraco.NestedContentv4.5512
- ..\..\
+ ..\true
@@ -33,124 +33,148 @@
- ..\..\packages\AutoMapper.3.0.0\lib\net40\AutoMapper.dll
+ ..\packages\AutoMapper.3.0.0\lib\net40\AutoMapper.dll
+ False
- ..\..\packages\AutoMapper.3.0.0\lib\net40\AutoMapper.Net4.dll
+ ..\packages\AutoMapper.3.0.0\lib\net40\AutoMapper.Net4.dll
+ False
- ..\..\packages\UmbracoCms.Core.7.1.4\lib\businesslogic.dll
+ ..\packages\UmbracoCms.Core.7.1.4\lib\businesslogic.dll
+ False
- ..\..\packages\ClientDependency.1.8.2.1\lib\net45\ClientDependency.Core.dll
+ ..\packages\ClientDependency.1.8.2.1\lib\net45\ClientDependency.Core.dll
+ False
- ..\..\packages\ClientDependency-Mvc.1.7.0.4\lib\ClientDependency.Core.Mvc.dll
+ ..\packages\ClientDependency-Mvc.1.7.0.4\lib\ClientDependency.Core.Mvc.dll
+ False
- ..\..\packages\UmbracoCms.Core.7.1.4\lib\cms.dll
+ ..\packages\UmbracoCms.Core.7.1.4\lib\cms.dll
+ False
- ..\..\packages\UmbracoCms.Core.7.1.4\lib\controls.dll
+ ..\packages\UmbracoCms.Core.7.1.4\lib\controls.dll
+ False
- ..\..\packages\xmlrpcnet.2.5.0\lib\net20\CookComputing.XmlRpcV2.dll
+ ..\packages\xmlrpcnet.2.5.0\lib\net20\CookComputing.XmlRpcV2.dll
+ False
- ..\..\packages\UmbracoCms.Core.7.1.4\lib\Examine.dll
+ ..\packages\UmbracoCms.Core.7.1.4\lib\Examine.dll
+ False
- ..\..\packages\HtmlAgilityPack.1.4.6\lib\Net45\HtmlAgilityPack.dll
+ ..\packages\HtmlAgilityPack.1.4.6\lib\Net45\HtmlAgilityPack.dll
+ False
- ..\..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll
+ ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll
+ False
- ..\..\packages\ImageProcessor.1.9.0.0\lib\ImageProcessor.dll
+ ..\packages\ImageProcessor.1.9.0.0\lib\ImageProcessor.dll
+ False
- ..\..\packages\ImageProcessor.Web.3.2.3.0\lib\net45\ImageProcessor.Web.dll
+ ..\packages\ImageProcessor.Web.3.2.3.0\lib\net45\ImageProcessor.Web.dll
+ False
- ..\..\packages\UmbracoCms.Core.7.1.4\lib\interfaces.dll
+ ..\packages\UmbracoCms.Core.7.1.4\lib\interfaces.dll
+ False
- ..\..\packages\UmbracoCms.Core.7.1.4\lib\log4net.dll
+ ..\packages\UmbracoCms.Core.7.1.4\lib\log4net.dll
+ False
- ..\..\packages\Lucene.Net.2.9.4.1\lib\net40\Lucene.Net.dll
+ ..\packages\Lucene.Net.2.9.4.1\lib\net40\Lucene.Net.dll
+ False
- ..\..\packages\UmbracoCms.Core.7.1.4\lib\Microsoft.ApplicationBlocks.Data.dll
+ ..\packages\UmbracoCms.Core.7.1.4\lib\Microsoft.ApplicationBlocks.Data.dll
+ False
- ..\..\packages\UmbracoCms.Core.7.1.4\lib\Microsoft.Web.Helpers.dll
+ ..\packages\UmbracoCms.Core.7.1.4\lib\Microsoft.Web.Helpers.dll
+ False
- True
- ..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll
+ False
+ ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll
- ..\..\packages\Microsoft.AspNet.Mvc.FixedDisplayModes.1.0.0\lib\net40\Microsoft.Web.Mvc.FixedDisplayModes.dll
+ ..\packages\Microsoft.AspNet.Mvc.FixedDisplayModes.1.0.0\lib\net40\Microsoft.Web.Mvc.FixedDisplayModes.dll
+ False
- ..\..\packages\MiniProfiler.2.1.0\lib\net40\MiniProfiler.dll
+ ..\packages\MiniProfiler.2.1.0\lib\net40\MiniProfiler.dll
+ False
- ..\..\packages\MySql.Data.6.6.5\lib\net40\MySql.Data.dll
+ ..\packages\MySql.Data.6.6.5\lib\net40\MySql.Data.dll
+ False
- ..\..\packages\Newtonsoft.Json.6.0.2\lib\net45\Newtonsoft.Json.dll
+ ..\packages\Newtonsoft.Json.6.0.2\lib\net45\Newtonsoft.Json.dll
+ False
- ..\..\packages\UmbracoCms.Core.7.1.4\lib\SQLCE4Umbraco.dll
+ ..\packages\UmbracoCms.Core.7.1.4\lib\SQLCE4Umbraco.dll
+ False
- True
- ..\..\packages\UmbracoCms.Core.7.1.4\lib\System.Data.SqlServerCe.dll
+ False
+ ..\packages\UmbracoCms.Core.7.1.4\lib\System.Data.SqlServerCe.dll
- True
- ..\..\packages\UmbracoCms.Core.7.1.4\lib\System.Data.SqlServerCe.Entity.dll
+ False
+ ..\packages\UmbracoCms.Core.7.1.4\lib\System.Data.SqlServerCe.Entity.dll
- True
- ..\..\packages\Microsoft.AspNet.WebApi.Client.4.0.30506.0\lib\net40\System.Net.Http.Formatting.dll
+ False
+ ..\packages\Microsoft.AspNet.WebApi.Client.4.0.30506.0\lib\net40\System.Net.Http.Formatting.dll
- True
- ..\..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.Helpers.dll
+ False
+ ..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.Helpers.dll
- True
- ..\..\packages\Microsoft.AspNet.WebApi.Core.4.0.20710.0\lib\net40\System.Web.Http.dll
+ False
+ ..\packages\Microsoft.AspNet.WebApi.Core.4.0.20710.0\lib\net40\System.Web.Http.dll
- True
- ..\..\packages\Microsoft.AspNet.WebApi.WebHost.4.0.20710.0\lib\net40\System.Web.Http.WebHost.dll
+ False
+ ..\packages\Microsoft.AspNet.WebApi.WebHost.4.0.20710.0\lib\net40\System.Web.Http.WebHost.dllFalse
- ..\..\packages\Microsoft.AspNet.Mvc.4.0.20710.0\lib\net40\System.Web.Mvc.dll
+ ..\packages\Microsoft.AspNet.Mvc.4.0.20710.0\lib\net40\System.Web.Mvc.dll
+ False
- True
+ False
- True
- ..\..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.dll
+ False
+ ..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.dll
- True
- ..\..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Deployment.dll
+ False
+ ..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Deployment.dll
- True
- ..\..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Razor.dll
+ False
+ ..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Razor.dll
@@ -158,37 +182,48 @@
- ..\..\packages\UmbracoCms.Core.7.1.4\lib\TidyNet.dll
+ ..\packages\UmbracoCms.Core.7.1.4\lib\TidyNet.dll
+ False
- ..\..\packages\UmbracoCms.Core.7.1.4\lib\umbraco.dll
+ ..\packages\UmbracoCms.Core.7.1.4\lib\umbraco.dll
+ False
- ..\..\packages\UmbracoCms.Core.7.1.4\lib\Umbraco.Core.dll
+ ..\packages\UmbracoCms.Core.7.1.4\lib\Umbraco.Core.dll
+ False
- ..\..\packages\UmbracoCms.Core.7.1.4\lib\umbraco.DataLayer.dll
+ ..\packages\UmbracoCms.Core.7.1.4\lib\umbraco.DataLayer.dll
+ False
- ..\..\packages\UmbracoCms.Core.7.1.4\lib\umbraco.editorControls.dll
+ ..\packages\UmbracoCms.Core.7.1.4\lib\umbraco.editorControls.dll
+ False
- ..\..\packages\UmbracoCms.Core.7.1.4\lib\umbraco.MacroEngines.dll
+ ..\packages\UmbracoCms.Core.7.1.4\lib\umbraco.MacroEngines.dll
+ False
- ..\..\packages\UmbracoCms.Core.7.1.4\lib\umbraco.providers.dll
+ ..\packages\UmbracoCms.Core.7.1.4\lib\umbraco.providers.dll
+ False
- ..\..\packages\UmbracoCms.Core.7.1.4\lib\Umbraco.Web.UI.dll
+ ..\packages\UmbracoCms.Core.7.1.4\lib\Umbraco.Web.UI.dll
+ False
- ..\..\packages\UmbracoCms.Core.7.1.4\lib\umbraco.XmlSerializers.dll
+ ..\packages\UmbracoCms.Core.7.1.4\lib\umbraco.XmlSerializers.dll
+ False
- ..\..\packages\UmbracoCms.Core.7.1.4\lib\UmbracoExamine.dll
+ ..\packages\UmbracoCms.Core.7.1.4\lib\UmbracoExamine.dll
+ False
- ..\..\packages\UmbracoCms.Core.7.1.4\lib\UrlRewritingNet.UrlRewriter.dll
+ ..\packages\UmbracoCms.Core.7.1.4\lib\UrlRewritingNet.UrlRewriter.dll
+ False
@@ -200,6 +235,7 @@
+
@@ -221,9 +257,9 @@
IF %25ComputerName%25 == MBP13-PC-BC (
IF NOT "$(SolutionDir)" == "*Undefined*" (
- xcopy /s /y "$(TargetPath)" "C:\Users\Matt\Work\Sandbox\Umbraco\UmbracoCms.7.2.2\bin"
- xcopy /s /y "$(TargetDir)$(ProjectName).pdb" "C:\Users\Matt\Work\Sandbox\Umbraco\UmbracoCms.7.2.2\bin"
- xcopy /s /y "$(ProjectDir)Web\UI\*.*" "C:\Users\Matt\Work\Sandbox\Umbraco\UmbracoCms.7.2.2"
+ xcopy /s /y "$(TargetPath)" "C:\Users\Matt\Work\Sandbox\Umbraco\UmbracoCms.7.2.6\bin"
+ xcopy /s /y "$(TargetDir)$(ProjectName).pdb" "C:\Users\Matt\Work\Sandbox\Umbraco\UmbracoCms.7.2.6\bin"
+ xcopy /s /y "$(ProjectDir)Web\UI\*.*" "C:\Users\Matt\Work\Sandbox\Umbraco\UmbracoCms.7.2.6"
)
)
diff --git a/src/Our.Umbraco.NestedContent/Properties/AssemblyInfo.cs b/src/Our.Umbraco.NestedContent/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..231ac6e
--- /dev/null
+++ b/src/Our.Umbraco.NestedContent/Properties/AssemblyInfo.cs
@@ -0,0 +1,15 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("Our.Umbraco.NestedContent")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("The Umbraco Community")]
+[assembly: AssemblyProduct("Our.Umbraco.NestedContent")]
+[assembly: AssemblyCopyright("Copyright \xa9 The Umbraco Community 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+[assembly: Guid("8B4FA1D2-118F-497F-B7FB-636F366E245E")]
diff --git a/src/Our.Umbraco.NestedContent/Properties/VersionInfo.cs b/src/Our.Umbraco.NestedContent/Properties/VersionInfo.cs
new file mode 100644
index 0000000..96a08b4
--- /dev/null
+++ b/src/Our.Umbraco.NestedContent/Properties/VersionInfo.cs
@@ -0,0 +1,19 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.34209
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+using System;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyInformationalVersion("1.0.0-local-000100")]
+
+
diff --git a/Src/Our.Umbraco.NestedContent/PropertyEditors/NestedContentPropertyEditor.cs b/src/Our.Umbraco.NestedContent/PropertyEditors/NestedContentPropertyEditor.cs
similarity index 81%
rename from Src/Our.Umbraco.NestedContent/PropertyEditors/NestedContentPropertyEditor.cs
rename to src/Our.Umbraco.NestedContent/PropertyEditors/NestedContentPropertyEditor.cs
index 3db2e42..6332798 100644
--- a/Src/Our.Umbraco.NestedContent/PropertyEditors/NestedContentPropertyEditor.cs
+++ b/src/Our.Umbraco.NestedContent/PropertyEditors/NestedContentPropertyEditor.cs
@@ -1,4 +1,5 @@
-using System.Linq;
+using System;
+using System.Linq;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text.RegularExpressions;
@@ -11,6 +12,7 @@
using Umbraco.Core.Models.Editors;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
+using umbraco.editorControls.SettingControls;
using Umbraco.Web.PropertyEditors;
namespace Our.Umbraco.NestedContent.PropertyEditors
@@ -18,6 +20,8 @@ namespace Our.Umbraco.NestedContent.PropertyEditors
[PropertyEditor(NestedContentPropertyEditor.PropertyEditorAlias, "Nested Content", "/App_Plugins/NestedContent/Views/nestedcontent.html", ValueType = "JSON")]
public class NestedContentPropertyEditor : PropertyEditor
{
+ internal const string ContentTypeAliasPropertyKey = "ncContentTypeAlias";
+
public const string PropertyEditorAlias = "Our.Umbraco.NestedContent";
private IDictionary _defaultPreValues;
@@ -32,10 +36,11 @@ public NestedContentPropertyEditor()
// Setup default values
_defaultPreValues = new Dictionary
{
- {"docTypeGuid", ""},
+ {NestedContentPreValueEditor.ContentTypesPreValueKey, ""},
{"minItems", 0},
{"maxItems", 0},
- {"confirmDeletes", 1}
+ {"confirmDeletes", "1"},
+ {"showIcons", "1"}
};
}
@@ -48,14 +53,10 @@ protected override PreValueEditor CreatePreValueEditor()
internal class NestedContentPreValueEditor : PreValueEditor
{
- [PreValueField("docTypeGuid", "Doc Type", "/App_Plugins/NestedContent/Views/nestedcontent.doctypepicker.html", Description = "Select the doc type to use as the data blueprint.")]
- public string DocTypeGuid { get; set; }
-
- [PreValueField("tabAlias", "Tab", "textstring", Description = "Enter the alias of the tab whos properties should be displayed. If left blank, the first tab on the doc type will be used.")]
- public string TabAlias { get; set; }
+ internal const string ContentTypesPreValueKey = "contentTypes";
- [PreValueField("nameTemplate", "Name Template", "textstring", Description = "Enter an angular expression to evaluate against each item for its name.")]
- public string NameTemplate { get; set; }
+ [PreValueField(ContentTypesPreValueKey, "Doc Types", "/App_Plugins/NestedContent/Views/nestedcontent.doctypepicker.html", Description = "Select the doc types to use as the data blueprint.")]
+ public string[] ContentTypes { get; set; }
[PreValueField("minItems", "Min Items", "number", Description = "Set the minimum number of items allowed.")]
public string MinItems { get; set; }
@@ -66,8 +67,19 @@ internal class NestedContentPreValueEditor : PreValueEditor
[PreValueField("confirmDeletes", "Confirm Deletes", "boolean", Description = "Set whether item deletions should require confirming.")]
public string ConfirmDeletes { get; set; }
+ [PreValueField("showIcons", "Show Icons", "boolean", Description = "Set whether to show the items doc type icon in the list.")]
+ public string ShowIcons { get; set; }
+
[PreValueField("hideLabel", "Hide Label", "boolean", Description = "Set whether to hide the editor label and have the list take up the full width of the editor window.")]
public string HideLabel { get; set; }
+
+ public override IDictionary ConvertDbToEditor(IDictionary defaultPreVals, PreValueCollection persistedPreVals)
+ {
+ // re-format old style (v0.1.1) pre values if necessary
+ NestedContentHelper.ConvertPreValueCollectionFromV011(persistedPreVals);
+
+ return base.ConvertDbToEditor(defaultPreVals, persistedPreVals);
+ }
}
#endregion
@@ -75,9 +87,9 @@ internal class NestedContentPreValueEditor : PreValueEditor
#region Value Editor
protected override PropertyValueEditor CreateValueEditor()
- {
+ {
return new NestedContentPropertyValueEditor(base.CreateValueEditor());
- }
+ }
internal class NestedContentPropertyValueEditor : PropertyValueEditorWrapper
{
@@ -119,15 +131,22 @@ public override string ConvertDbToString(Property property, PropertyType propert
if (value == null)
return string.Empty;
- var contentType = NestedContentHelper.GetContentTypeFromPreValue(propertyType.DataTypeDefinitionId);
- if (contentType == null)
- return string.Empty;
-
// Process value
+ PreValueCollection preValues = null;
for (var i = 0; i < value.Count; i++)
{
var o = value[i];
var propValues = ((JObject)o);
+
+ // convert from old style (v0.1.1) data format if necessary
+ NestedContentHelper.ConvertItemValueFromV011(propValues, propertyType.DataTypeDefinitionId, ref preValues);
+
+ var contentType = NestedContentHelper.GetContentTypeFromItem(propValues);
+ if (contentType == null)
+ {
+ continue;
+ }
+
var propValueKeys = propValues.Properties().Select(x => x.Name).ToArray();
foreach (var propKey in propValueKeys)
@@ -135,7 +154,7 @@ public override string ConvertDbToString(Property property, PropertyType propert
var propType = contentType.PropertyTypes.FirstOrDefault(x => x.Alias == propKey);
if (propType == null)
{
- if (propKey != "name")
+ if (IsSystemPropertyKey(propKey) == false)
{
// Property missing so just delete the value
propValues[propKey] = null;
@@ -177,15 +196,22 @@ public override object ConvertDbToEditor(Property property, PropertyType propert
if (value == null)
return string.Empty;
- var contentType = NestedContentHelper.GetContentTypeFromPreValue(propertyType.DataTypeDefinitionId);
- if (contentType == null)
- return string.Empty;
-
// Process value
+ PreValueCollection preValues = null;
for (var i = 0; i < value.Count; i++)
{
var o = value[i];
var propValues = ((JObject)o);
+
+ // convert from old style (v0.1.1) data format if necessary
+ NestedContentHelper.ConvertItemValueFromV011(propValues, propertyType.DataTypeDefinitionId, ref preValues);
+
+ var contentType = NestedContentHelper.GetContentTypeFromItem(propValues);
+ if (contentType == null)
+ {
+ continue;
+ }
+
var propValueKeys = propValues.Properties().Select(x => x.Name).ToArray();
foreach (var propKey in propValueKeys)
@@ -193,7 +219,7 @@ public override object ConvertDbToEditor(Property property, PropertyType propert
var propType = contentType.PropertyTypes.FirstOrDefault(x => x.Alias == propKey);
if (propType == null)
{
- if (propKey != "name")
+ if (IsSystemPropertyKey(propKey) == false)
{
// Property missing so just delete the value
propValues[propKey] = null;
@@ -238,15 +264,18 @@ public override object ConvertEditorToDb(ContentPropertyData editorValue, object
if (value == null)
return string.Empty;
- var contentType = NestedContentHelper.GetContentTypeFromPreValue(editorValue.PreValues);
- if (contentType == null)
- return string.Empty;
-
// Process value
for (var i = 0; i < value.Count; i++)
{
var o = value[i];
var propValues = ((JObject)o);
+
+ var contentType = NestedContentHelper.GetContentTypeFromItem(propValues);
+ if (contentType == null)
+ {
+ continue;
+ }
+
var propValueKeys = propValues.Properties().Select(x => x.Name).ToArray();
foreach (var propKey in propValueKeys)
@@ -254,7 +283,7 @@ public override object ConvertEditorToDb(ContentPropertyData editorValue, object
var propType = contentType.PropertyTypes.FirstOrDefault(x => x.Alias == propKey);
if (propType == null)
{
- if (propKey != "name")
+ if (IsSystemPropertyKey(propKey) == false)
{
// Property missing so just delete the value
propValues[propKey] = null;
@@ -271,7 +300,7 @@ public override object ConvertEditorToDb(ContentPropertyData editorValue, object
// Create a fake content property data object
var contentPropData = new ContentPropertyData(
- propValues[propKey] == null ? null : propValues[propKey].ToString(), propPreValues,
+ propValues[propKey], propPreValues,
new Dictionary());
// Get the property editor to do it's conversion
@@ -298,14 +327,17 @@ public IEnumerable Validate(object rawValue, PreValueCollectio
if (value == null)
yield break;
- var contentType = NestedContentHelper.GetContentTypeFromPreValue(preValues);
- if (contentType == null)
- yield break;
-
for (var i = 0; i < value.Count; i++)
{
var o = value[i];
var propValues = ((JObject)o);
+
+ var contentType = NestedContentHelper.GetContentTypeFromItem(propValues);
+ if (contentType == null)
+ {
+ continue;
+ }
+
var propValueKeys = propValues.Properties().Select(x => x.Name).ToArray();
foreach (var propKey in propValueKeys)
@@ -349,5 +381,10 @@ public IEnumerable Validate(object rawValue, PreValueCollectio
}
#endregion
+
+ private static bool IsSystemPropertyKey(string propKey)
+ {
+ return propKey == "name" || propKey == ContentTypeAliasPropertyKey;
+ }
}
-}
+}
\ No newline at end of file
diff --git a/Src/Our.Umbraco.NestedContent/Web/Controllers/NestedContentApiController.cs b/src/Our.Umbraco.NestedContent/Web/Controllers/NestedContentApiController.cs
similarity index 77%
rename from Src/Our.Umbraco.NestedContent/Web/Controllers/NestedContentApiController.cs
rename to src/Our.Umbraco.NestedContent/Web/Controllers/NestedContentApiController.cs
index d7f9838..4df5208 100644
--- a/Src/Our.Umbraco.NestedContent/Web/Controllers/NestedContentApiController.cs
+++ b/src/Our.Umbraco.NestedContent/Web/Controllers/NestedContentApiController.cs
@@ -11,15 +11,6 @@ namespace Our.Umbraco.NestedContent.Web.Controllers
[PluginController("NestedContent")]
public class NestedContentApiController : UmbracoAuthorizedJsonController
{
- [System.Web.Http.HttpGet]
- public object GetContentTypeAliasByGuid([ModelBinder] Guid guid)
- {
- return new
- {
- alias = Services.ContentTypeService.GetAliasByGuid(guid)
- };
- }
-
[System.Web.Http.HttpGet]
public IEnumerable