Fixes: U4-4055 List View document types still display children in content tree
This commit is contained in:
@@ -231,7 +231,7 @@ namespace Umbraco.Core
|
||||
/// <returns>The contains key ignore case.</returns>
|
||||
public static bool ContainsKeyIgnoreCase<TValue>(this IDictionary<string, TValue> dictionary, string key)
|
||||
{
|
||||
return dictionary.Keys.Any(i => i.Equals(key, StringComparison.CurrentCultureIgnoreCase));
|
||||
return dictionary.Keys.InvariantContains(key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -257,9 +257,9 @@ namespace Umbraco.Core
|
||||
/// <param name="key">The key.</param>
|
||||
/// <typeparam name="TValue">The type</typeparam>
|
||||
/// <returns>The entry</returns>
|
||||
public static TValue GetEntryIgnoreCase<TValue>(this IDictionary<string, TValue> dictionary, string key)
|
||||
public static TValue GetValueIgnoreCase<TValue>(this IDictionary<string, TValue> dictionary, string key)
|
||||
{
|
||||
return dictionary.GetEntryIgnoreCase(key, default(TValue));
|
||||
return dictionary.GetValueIgnoreCase(key, default(TValue));
|
||||
}
|
||||
|
||||
/// <summary>The get entry ignore case.</summary>
|
||||
@@ -268,11 +268,11 @@ namespace Umbraco.Core
|
||||
/// <param name="defaultValue">The default value.</param>
|
||||
/// <typeparam name="TValue">The type</typeparam>
|
||||
/// <returns>The entry</returns>
|
||||
public static TValue GetEntryIgnoreCase<TValue>(this IDictionary<string, TValue> dictionary, string key, TValue defaultValue)
|
||||
public static TValue GetValueIgnoreCase<TValue>(this IDictionary<string, TValue> dictionary, string key, TValue defaultValue)
|
||||
{
|
||||
key = dictionary.Keys.Where(i => i.Equals(key, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
|
||||
key = dictionary.Keys.FirstOrDefault(i => i.InvariantEquals(key));
|
||||
|
||||
return !key.IsNullOrWhiteSpace()
|
||||
return key.IsNullOrWhiteSpace() == false
|
||||
? dictionary[key]
|
||||
: defaultValue;
|
||||
}
|
||||
|
||||
32
src/Umbraco.Core/Models/UmbracoEntityExtensions.cs
Normal file
32
src/Umbraco.Core/Models/UmbracoEntityExtensions.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.UI.WebControls;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
{
|
||||
internal static class UmbracoEntityExtensions
|
||||
{
|
||||
|
||||
public static object GetAdditionalDataValueIgnoreCase(this IUmbracoEntity entity, string key, object defaultVal)
|
||||
{
|
||||
if (entity.AdditionalData.ContainsKeyIgnoreCase(key) == false) return defaultVal;
|
||||
return entity.AdditionalData.GetValueIgnoreCase(key, defaultVal);
|
||||
}
|
||||
|
||||
public static bool IsContainer(this IUmbracoEntity entity)
|
||||
{
|
||||
if (entity.AdditionalData.ContainsKeyIgnoreCase("IsContainer") == false) return false;
|
||||
var val = entity.AdditionalData.GetValueIgnoreCase("IsContainer", null);
|
||||
if (val is bool && (bool) val)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -339,6 +339,7 @@
|
||||
<Compile Include="Models\PublishedContent\PublishedContentModelFactoryResolver.cs" />
|
||||
<Compile Include="Models\TaggableObjectTypes.cs" />
|
||||
<Compile Include="Models\TemplateNode.cs" />
|
||||
<Compile Include="Models\UmbracoEntityExtensions.cs" />
|
||||
<Compile Include="Packaging\PackageBinaryInspector.cs" />
|
||||
<Compile Include="PropertyEditors\DefaultPropertyValueConverterAttribute.cs" />
|
||||
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSeven\UpdateRelatedLinksData.cs" />
|
||||
|
||||
@@ -119,8 +119,8 @@ namespace Umbraco.Web.Models.Mapping
|
||||
// only when creating a new member and we want to have a generated password pre-filled.
|
||||
Value = new Dictionary<string, object>
|
||||
{
|
||||
{"generatedPassword", member.AdditionalData.ContainsKey("GeneratedPassword") ? member.AdditionalData["GeneratedPassword"] : null},
|
||||
{"newPassword", member.AdditionalData.ContainsKey("NewPassword") ? member.AdditionalData["NewPassword"] : null},
|
||||
{"generatedPassword", member.GetAdditionalDataValueIgnoreCase("GeneratedPassword", null) },
|
||||
{"newPassword", member.GetAdditionalDataValueIgnoreCase("NewPassword", null) },
|
||||
},
|
||||
//TODO: Hard coding this because the changepassword doesn't necessarily need to be a resolvable (real) property editor
|
||||
View = "changepassword",
|
||||
|
||||
@@ -98,9 +98,7 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
|
||||
//Special check to see if it ia a container, if so then we'll hide children.
|
||||
var isContainer = e.AdditionalData.ContainsKey("IsContainer")
|
||||
&& e.AdditionalData["IsContainer"] is bool
|
||||
&& (bool)e.AdditionalData["IsContainer"];
|
||||
var isContainer = e.IsContainer();
|
||||
|
||||
var node = CreateTreeNode(
|
||||
e.Id.ToInvariantString(),
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Umbraco.Web.Trees
|
||||
protected abstract int UserStartNode { get; }
|
||||
|
||||
protected abstract TreeNodeCollection PerformGetTreeNodes(string id, FormDataCollection queryStrings);
|
||||
|
||||
|
||||
protected abstract MenuItemCollection PerformGetMenuForNode(string id, FormDataCollection queryStrings);
|
||||
|
||||
protected abstract UmbracoObjectTypes UmbracoObjectType { get; }
|
||||
@@ -88,7 +88,7 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
//just return their single start node, it will show up under the 'Content' label
|
||||
var startNode = Services.EntityService.Get(UserStartNode, UmbracoObjectType);
|
||||
return new[] {startNode};
|
||||
return new[] { startNode };
|
||||
}
|
||||
|
||||
return Services.EntityService.GetChildren(iid, UmbracoObjectType).ToArray();
|
||||
@@ -116,8 +116,8 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
var nodes = new TreeNodeCollection();
|
||||
var altStartId = string.Empty;
|
||||
|
||||
if(queryStrings.HasKey(TreeQueryStringParameters.StartNodeId))
|
||||
|
||||
if (queryStrings.HasKey(TreeQueryStringParameters.StartNodeId))
|
||||
altStartId = queryStrings.GetValue<string>(TreeQueryStringParameters.StartNodeId);
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace Umbraco.Web.Trees
|
||||
// for the time being we'll just load the dashboard of the section.
|
||||
//queryStrings.GetValue<string>("application") + TreeAlias.EnsureStartsWith('/') + "/recyclebin"));
|
||||
queryStrings.GetValue<string>("application")));
|
||||
|
||||
|
||||
}
|
||||
|
||||
return nodes;
|
||||
@@ -176,12 +176,12 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
//before we get the children we need to see if this is a container node
|
||||
var current = Services.EntityService.Get(int.Parse(id), UmbracoObjectType);
|
||||
if (current != null && current.AdditionalData.ContainsKey("IsContainer") && current.AdditionalData["IsContainer"] is bool && (bool)current.AdditionalData["IsContainer"])
|
||||
|
||||
if (current != null && current.IsContainer())
|
||||
{
|
||||
//no children!
|
||||
return new TreeNodeCollection();
|
||||
}
|
||||
|
||||
return PerformGetTreeNodes(id, queryStrings);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,9 +78,7 @@ namespace Umbraco.Web.Trees
|
||||
var entity = (UmbracoEntity)e;
|
||||
|
||||
//Special check to see if it ia a container, if so then we'll hide children.
|
||||
var isContainer = entity.AdditionalData.ContainsKey("IsContainer")
|
||||
&& entity.AdditionalData["IsContainer"] is bool
|
||||
&& (bool)entity.AdditionalData["IsContainer"];
|
||||
var isContainer = entity.IsContainer();
|
||||
|
||||
var node = CreateTreeNode(
|
||||
e.Id.ToInvariantString(),
|
||||
|
||||
Reference in New Issue
Block a user