Merge pull request #7660 from umbraco/v8/bugfix/AB4900-start-nodes-list-views

Fixing when a start node is a content item in a nested list view
This commit is contained in:
Warren Buckley
2020-02-19 09:57:26 +00:00
committed by GitHub
7 changed files with 112 additions and 25 deletions

View File

@@ -27,6 +27,13 @@ namespace Umbraco.Core.Persistence.Repositories
/// <returns></returns>
bool HasContainerInPath(string contentPath);
/// <summary>
/// Gets a value indicating whether there is a list view content item in the path.
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
bool HasContainerInPath(params int[] ids);
/// <summary>
/// Returns true or false depending on whether content nodes have been created based on the provided content type id.
/// </summary>

View File

@@ -1309,14 +1309,16 @@ WHERE cmsContentType." + aliasColumn + @" LIKE @pattern",
return test;
}
/// <summary>
/// Given the path of a content item, this will return true if the content item exists underneath a list view content item
/// </summary>
/// <param name="contentPath"></param>
/// <returns></returns>
/// <inheritdoc />
public bool HasContainerInPath(string contentPath)
{
var ids = contentPath.Split(',').Select(int.Parse);
var ids = contentPath.Split(',').Select(int.Parse).ToArray();
return HasContainerInPath(ids);
}
/// <inheritdoc />
public bool HasContainerInPath(params int[] ids)
{
var sql = new Sql($@"SELECT COUNT(*) FROM cmsContentType
INNER JOIN {Constants.DatabaseSchema.Tables.Content} ON cmsContentType.nodeId={Constants.DatabaseSchema.Tables.Content}.contentTypeId
WHERE {Constants.DatabaseSchema.Tables.Content}.nodeId IN (@ids) AND cmsContentType.isContainer=@isContainer", new { ids, isContainer = true });

View File

@@ -69,6 +69,13 @@ namespace Umbraco.Core.Services
/// <returns></returns>
bool HasContainerInPath(string contentPath);
/// <summary>
/// Gets a value indicating whether there is a list view content item in the path.
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
bool HasContainerInPath(params int[] ids);
Attempt<OperationResult<OperationResultType, EntityContainer>> CreateContainer(int parentContainerId, string name, int userId = Constants.Security.SuperUserId);
Attempt<OperationResult> SaveContainer(EntityContainer container, int userId = Constants.Security.SuperUserId);
EntityContainer GetContainer(int containerId);

View File

@@ -321,6 +321,15 @@ namespace Umbraco.Core.Services.Implement
}
}
public bool HasContainerInPath(params int[] ids)
{
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
{
// can use same repo for both content and media
return Repository.HasContainerInPath(ids);
}
}
public IEnumerable<TItem> GetDescendants(int id, bool andSelf)
{
using (var scope = ScopeProvider.CreateScope(autoComplete: true))