Ensures that itself is never returned in the list, not even disabled (since you can never select yourself), ensures that any comp already selected is enabled for selection in the UI.
This commit is contained in:
@@ -77,9 +77,7 @@ namespace Umbraco.Core.Services
|
||||
//At this point we have a list of content types that 'could' be compositions
|
||||
|
||||
//now we'll filter this list based on the filters requested
|
||||
var filtered = list
|
||||
//not itself
|
||||
.Where(x => x.Id != sourceId)
|
||||
var filtered = list
|
||||
.Where(x =>
|
||||
{
|
||||
//need to filter any content types that are included in this list
|
||||
@@ -95,9 +93,11 @@ namespace Umbraco.Core.Services
|
||||
})
|
||||
.OrderBy(x => x.Name)
|
||||
.ToList();
|
||||
|
||||
//now we can create our result based on what is still available
|
||||
|
||||
//now we can create our result based on what is still available
|
||||
var result = list
|
||||
//not itself
|
||||
.Where(x => x.Id != sourceId)
|
||||
.OrderBy(x => x.Name)
|
||||
.Select(composition => filtered.Contains(composition)
|
||||
? new Tuple<IContentTypeComposition, bool>(composition, true)
|
||||
|
||||
@@ -317,7 +317,7 @@
|
||||
return c.contentType;
|
||||
});
|
||||
// convert icons for composite content types
|
||||
iconHelper.formatContentTypeIcons(contentTypes);
|
||||
iconHelper.formatContentTypeIcons(contentTypes);
|
||||
}),
|
||||
//get content type count
|
||||
countContentTypeResource().then(function(result) {
|
||||
|
||||
@@ -106,11 +106,22 @@ namespace Umbraco.Web.Editors
|
||||
|
||||
var filtered = Services.ContentTypeService.GetAvailableCompositeContentTypes(source, allContentTypes, filterContentTypes, filterPropertyTypes);
|
||||
|
||||
var currCompositions = source == null ? new string[] { } : source.ContentTypeComposition.Select(x => x.Alias).ToArray();
|
||||
|
||||
return filtered
|
||||
.Select(x => new Tuple<EntityBasic, bool>(Mapper.Map<IContentTypeComposition, EntityBasic>(x.Item1), x.Item2))
|
||||
.Select(x =>
|
||||
{
|
||||
//translate the name
|
||||
x.Item1.Name = TranslateItem(x.Item1.Name);
|
||||
|
||||
//we need to ensure that the item is enabled if it is already selected
|
||||
if (currCompositions.Contains(x.Item1.Alias))
|
||||
{
|
||||
//re-set x to be allowed (NOTE: I didn't know you could set an enumerable item in a lambda!)
|
||||
x = new Tuple<EntityBasic, bool>(x.Item1, true);
|
||||
}
|
||||
|
||||
return x;
|
||||
})
|
||||
.ToList();
|
||||
|
||||
Reference in New Issue
Block a user