Allows members to be ordered by additional system fields (#6575)

This commit is contained in:
Andy Butland
2019-10-15 13:18:45 +02:00
committed by Sebastiaan Janssen
parent 14d0bd056c
commit 28ec4da0fa
2 changed files with 23 additions and 6 deletions

View File

@@ -133,7 +133,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
// joining the type so we can do a query against the member type - not sure if this adds much overhead or not?
// the execution plan says it doesn't so we'll go with that and in that case, it might be worth joining the content
// types by default on the document and media repo's so we can query by content type there too.
// types by default on the document and media repos so we can query by content type there too.
.InnerJoin<ContentTypeDto>().On<ContentDto, ContentTypeDto>(left => left.ContentTypeId, right => right.NodeId);
sql.Where<NodeDto>(x => x.NodeObjectType == NodeObjectTypeId);
@@ -546,6 +546,15 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
if (ordering.OrderBy.InvariantEquals("userName"))
return SqlSyntax.GetFieldName<MemberDto>(x => x.LoginName);
if (ordering.OrderBy.InvariantEquals("updateDate"))
return SqlSyntax.GetFieldName<ContentVersionDto>(x => x.VersionDate);
if (ordering.OrderBy.InvariantEquals("createDate"))
return SqlSyntax.GetFieldName<NodeDto>(x => x.CreateDate);
if (ordering.OrderBy.InvariantEquals("contentTypeAlias"))
return SqlSyntax.GetFieldName<ContentTypeDto>(x => x.Alias);
return base.ApplySystemOrdering(ref sql, ordering);
}

View File

@@ -193,9 +193,14 @@ function listViewController($scope, $routeParams, $injector, $timeout, currentUs
_.each($scope.options.includeProperties, function (e, i) {
e.allowSorting = true;
// Special case for members, only fields on the base table (cmsMember) can be used for sorting
if (e.isSystem && $scope.entityType == "member") {
e.allowSorting = e.alias == 'username' || e.alias == 'email';
// Special case for members, only the configured system fields should be enabled sorting
// (see MemberRepository.ApplySystemOrdering)
if (e.isSystem && $scope.entityType === "member") {
e.allowSorting = e.alias === "username" ||
e.alias === "email" ||
e.alias === "updateDate" ||
e.alias === "createDate" ||
e.alias === "contentTypeAlias";
}
if (e.isSystem) {
@@ -779,8 +784,11 @@ function listViewController($scope, $routeParams, $injector, $timeout, currentUs
case "published":
return "content_isPublished";
case "contentTypeAlias":
// TODO: Check for members
return $scope.entityType === "content" ? "content_documentType" : "content_mediatype";
return $scope.entityType === "content"
? "content_documentType"
: $scope.entityType === "media"
? "content_mediatype"
: "content_membertype";
case "email":
return "general_email";
case "username":