V8: Filter out invalid selections in the MNTP "Allowed items" picker (#6641)

This commit is contained in:
Kenn Jacobsen
2019-10-24 17:21:38 +02:00
committed by Sebastiaan Janssen
parent f2dfdd6086
commit b0d7bdaa77
2 changed files with 14 additions and 1 deletions

View File

@@ -42,6 +42,11 @@ function TreeSourceTypePickerController($scope, contentTypeResource, mediaTypeRe
var editor = {
multiPicker: true,
filterCssClass: "not-allowed not-published",
filter: function (item) {
// filter out folders (containers), element types (for content) and already selected items
return item.nodeType === "container" || item.metaData.isElement || !!_.findWhere(vm.itemTypes, { udi: item.udi });
},
submit: function (model) {
var newItemTypes = _.map(model.selection,
function(selected) {

View File

@@ -62,8 +62,10 @@ namespace Umbraco.Web.Trees
//if the request is for folders only then just return
if (queryStrings["foldersonly"].IsNullOrWhiteSpace() == false && queryStrings["foldersonly"] == "1") return nodes;
var children = Services.EntityService.GetChildren(intId.Result, UmbracoObjectTypes.DocumentType).ToArray();
var contentTypes = Services.ContentTypeService.GetAll(children.Select(c => c.Id).ToArray()).ToDictionary(c => c.Id);
nodes.AddRange(
Services.EntityService.GetChildren(intId.Result, UmbracoObjectTypes.DocumentType)
children
.OrderBy(entity => entity.Name)
.Select(dt =>
{
@@ -73,6 +75,12 @@ namespace Umbraco.Web.Trees
var node = CreateTreeNode(dt, Constants.ObjectTypes.DocumentType, id, queryStrings, Constants.Icons.ContentType, hasChildren);
node.Path = dt.Path;
// enrich the result with content type data that's not available in the entity service output
var contentType = contentTypes[dt.Id];
node.Alias = contentType.Alias;
node.AdditionalData["isElement"] = contentType.IsElement;
return node;
}));