Merge branch 'temp8-pr4102' into temp8

This commit is contained in:
Stephan
2019-01-22 15:04:32 +01:00
5 changed files with 34 additions and 22 deletions

View File

@@ -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;
}
/// <summary>
/// Gets a value indicating whether this content type is for an element.
/// </summary>
public bool IsElement { get; }
#endregion
}
}

View File

@@ -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) {

View File

@@ -8,7 +8,7 @@ namespace Umbraco.Web.PropertyEditors
/// </summary>
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; }
}
}
}
}

View File

@@ -12,6 +12,7 @@ namespace Umbraco.Web.PropertyEditors
public IEnumerable<object> GetContentTypes()
{
return Services.ContentTypeService.GetAll()
.Where(x => x.IsElement)
.OrderBy(x => x.SortOrder)
.Select(x => new
{

View File

@@ -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<Dictionary<string, object>>();