diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs index 1d168aad1d..cb4463fa6f 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs @@ -31,6 +31,8 @@ namespace Umbraco.Core.Models.PublishedContent _propertyTypes = propertyTypes.ToArray(); + IsElement = contentType.IsElement; + InitializeIndexes(); } @@ -166,6 +168,11 @@ namespace Umbraco.Core.Models.PublishedContent return index >= 0 && index < _propertyTypes.Length ? _propertyTypes[index] : null; } + /// + /// Gets a value indicating whether this content type is for an element. + /// + public bool IsElement { get; } + #endregion } } diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js index 79e00fa453..d6cc35bacd 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js @@ -285,28 +285,31 @@ angular.module("umbraco").controller("Umbraco.PropertyEditors.NestedContent.Prop $scope.scaffolds = []; _.each($scope.model.config.contentTypes, function (contentType) { contentResource.getScaffold(-20, contentType.ncAlias).then(function (scaffold) { - // remove all tabs except the specified tab - var tabs = scaffold.variants[0].tabs; - var tab = _.find(tabs, function (tab) { - return tab.id != 0 && (tab.alias.toLowerCase() == contentType.ncTabAlias.toLowerCase() || contentType.ncTabAlias == ""); - }); - scaffold.tabs = []; - if (tab) { - scaffold.tabs.push(tab); + // make sure it's an element type before allowing the user to create new ones + if (scaffold.isElement) { + // remove all tabs except the specified tab + var tabs = scaffold.variants[0].tabs; + var tab = _.find(tabs, function (tab) { + return tab.id != 0 && (tab.alias.toLowerCase() == contentType.ncTabAlias.toLowerCase() || contentType.ncTabAlias == ""); + }); + scaffold.tabs = []; + if (tab) { + scaffold.tabs.push(tab); - angular.forEach(tab.properties, - function (property) { - if (_.find(notSupported, function (x) { return x === property.editor; })) { - property.notSupported = true; - //TODO: Not supported message to be replaced with 'content_nestedContentEditorNotSupported' dictionary key. Currently not possible due to async/timing quirk. - property.notSupportedMessage = "Property " + property.label + " uses editor " + property.editor + " which is not supported by Nested Content."; - } - }); + angular.forEach(tab.properties, + function (property) { + if (_.find(notSupported, function (x) { return x === property.editor; })) { + property.notSupported = true; + //TODO: Not supported message to be replaced with 'content_nestedContentEditorNotSupported' dictionary key. Currently not possible due to async/timing quirk. + property.notSupportedMessage = "Property " + property.label + " uses editor " + property.editor + " which is not supported by Nested Content."; + } + }); + } + + // Store the scaffold object + $scope.scaffolds.push(scaffold); } - // Store the scaffold object - $scope.scaffolds.push(scaffold); - scaffoldsLoaded++; initIfAllScaffoldsHaveLoaded(); }, function (error) { diff --git a/src/Umbraco.Web/PropertyEditors/NestedContentConfiguration.cs b/src/Umbraco.Web/PropertyEditors/NestedContentConfiguration.cs index 44648ee859..b904a2250d 100644 --- a/src/Umbraco.Web/PropertyEditors/NestedContentConfiguration.cs +++ b/src/Umbraco.Web/PropertyEditors/NestedContentConfiguration.cs @@ -8,7 +8,7 @@ namespace Umbraco.Web.PropertyEditors /// public class NestedContentConfiguration { - [ConfigurationField("contentTypes", "Doc Types", "views/propertyeditors/nestedcontent/nestedcontent.doctypepicker.html", Description = "Select the doc types to use as the data blueprint.")] + [ConfigurationField("contentTypes", "Document types", "views/propertyeditors/nestedcontent/nestedcontent.doctypepicker.html", Description = "Select the document types to use as the item blueprints. Only \"element\" types can be used.")] public ContentType[] ContentTypes { get; set; } [ConfigurationField("minItems", "Min Items", "number", Description = "Set the minimum number of items allowed.")] @@ -38,4 +38,4 @@ namespace Umbraco.Web.PropertyEditors public string Template { get; set; } } } -} \ No newline at end of file +} diff --git a/src/Umbraco.Web/PropertyEditors/NestedContentController.cs b/src/Umbraco.Web/PropertyEditors/NestedContentController.cs index 103967d20a..8d144c5904 100644 --- a/src/Umbraco.Web/PropertyEditors/NestedContentController.cs +++ b/src/Umbraco.Web/PropertyEditors/NestedContentController.cs @@ -12,6 +12,7 @@ namespace Umbraco.Web.PropertyEditors public IEnumerable GetContentTypes() { return Services.ContentTypeService.GetAll() + .Where(x => x.IsElement) .OrderBy(x => x.SortOrder) .Select(x => new { diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentValueConverterBase.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentValueConverterBase.cs index 7e9b1dfe88..e3723e2221 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentValueConverterBase.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentValueConverterBase.cs @@ -45,8 +45,9 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters if (string.IsNullOrEmpty(elementTypeAlias)) return null; + // only convert element types - content types will cause an exception when PublishedModelFactory creates the model var publishedContentType = _publishedSnapshotAccessor.PublishedSnapshot.Content.GetContentType(elementTypeAlias); - if (publishedContentType == null) + if (publishedContentType == null || publishedContentType.IsElement == false) return null; var propertyValues = sourceObject.ToObject>();