Add member system fields to ListView (#14069)

* Add member system fields to ListView

* Small fix

* Add sort options for new systemfield for members.

---------

Co-authored-by: Lucas Bach Bisgaard <lom@novicell.dk>
This commit is contained in:
Lucas Bach Bisgaard
2023-04-28 16:37:22 +02:00
committed by GitHub
parent 0765a2ebbb
commit 2aa9ceab1a
6 changed files with 107 additions and 43 deletions

View File

@@ -13,6 +13,24 @@ public class MemberBasic : ContentItemBasic<ContentPropertyBasic>
[DataMember(Name = "email")]
public string? Email { get; set; }
[DataMember(Name = "failedPasswordAttempts")]
public int FailedPasswordAttempts { get; set; }
[DataMember(Name = "approved")]
public bool Approved { get; set; }
[DataMember(Name = "lockedOut")]
public bool LockedOut { get; set; }
[DataMember(Name = "lastLockoutDate")]
public DateTime? LastLockoutDate { get; set; }
[DataMember(Name = "lastLoginDate")]
public DateTime? LastLoginDate { get; set; }
[DataMember(Name = "lastPasswordChangeDate")]
public DateTime? LastPasswordChangeDate { get; set; }
[DataMember(Name = "properties")]
public override IEnumerable<ContentPropertyBasic> Properties
{

View File

@@ -280,6 +280,36 @@ public class MemberRepository : ContentRepositoryBase<int, IMember, MemberReposi
return SqlSyntax.GetFieldName<ContentTypeDto>(x => x.Alias);
}
if (ordering.OrderBy.InvariantEquals("failedPasswordAttempts"))
{
return SqlSyntax.GetFieldName<MemberDto>(x => x.FailedPasswordAttempts);
}
if (ordering.OrderBy.InvariantEquals("approved"))
{
return SqlSyntax.GetFieldName<MemberDto>(x => x.IsApproved);
}
if (ordering.OrderBy.InvariantEquals("lockedOut"))
{
return SqlSyntax.GetFieldName<MemberDto>(x => x.IsLockedOut);
}
if (ordering.OrderBy.InvariantEquals("lastLockoutDate"))
{
return SqlSyntax.GetFieldName<MemberDto>(x => x.LastLockoutDate);
}
if (ordering.OrderBy.InvariantEquals("lastLoginDate"))
{
return SqlSyntax.GetFieldName<MemberDto>(x => x.LastLoginDate);
}
if (ordering.OrderBy.InvariantEquals("lastPasswordChangeDate"))
{
return SqlSyntax.GetFieldName<MemberDto>(x => x.LastPasswordChangeDate);
}
return base.ApplySystemOrdering(ref sql, ordering);
}

View File

@@ -88,6 +88,12 @@ public class MemberMapDefinition : IMapDefinition
target.Udi = Udi.Create(Constants.UdiEntityType.Member, source.Key);
target.UpdateDate = source.UpdateDate;
target.Username = source.Username;
target.FailedPasswordAttempts = source.FailedPasswordAttempts;
target.Approved = source.IsApproved;
target.LockedOut = source.IsLockedOut;
target.LastLockoutDate = source.LastLockoutDate;
target.LastLoginDate = source.LastLoginDate;
target.LastPasswordChangeDate = source.LastPasswordChangeDate;
}
// Umbraco.Code.MapAll -Icon -Trashed -ParentId -Alias

View File

@@ -10,42 +10,26 @@ function includePropsPreValsController($rootScope, $scope, localizationService,
$scope.propertyAliases = [];
$scope.selectedField = null;
$scope.systemFields = [
{ value: "sortOrder" },
{ value: "updateDate" },
{ value: "updater" },
{ value: "createDate" },
{ value: "owner" },
{ value: "published"},
{ value: "contentTypeAlias" },
{ value: "email" },
{ value: "username" }
{ value: "sortOrder", localizedKey: "general_sort" },
{ value: "updateDate", localizedKey: "content_updateDate" },
{ value: "updater", localizedKey: "content_updatedBy" },
{ value: "createDate", localizedKey: "content_createDate" },
{ value: "owner", localizedKey: "content_createBy" },
{ value: "published", localizedKey: "content_isPublished" },
{ value: "contentTypeAlias", localizedKey: "content_documentType" },
{ value: "email", localizedKey: "general_email" },
{ value: "username", localizedKey: "general_username" },
{ value: "failedPasswordAttempts", localizedKey: "user_failedPasswordAttempts" },
{ value: "approved", localizedKey: "user_stateApproved" },
{ value: "lockedOut", localizedKey: "user_stateLockedOut" },
{ value: "lastLockoutDate", localizedKey: "user_lastLockoutDate" },
{ value: "lastLoginDate", localizedKey: "user_lastLogin" },
{ value: "lastPasswordChangeDate", localizedKey: "user_lastPasswordChangeDate" }
];
$scope.getLocalizedKey = function(alias) {
switch (alias) {
case "name":
return "general_name";
case "sortOrder":
return "general_sort";
case "updateDate":
return "content_updateDate";
case "updater":
return "content_updatedBy";
case "createDate":
return "content_createDate";
case "owner":
return "content_createBy";
case "published":
return "content_isPublished";
case "contentTypeAlias":
//NOTE: This will just be 'Document' type even if it's for media/members since this is just a pre-val editor and we don't have a key for 'Content Type Alias'
return "content_documentType";
case "email":
return "general_email";
case "username":
return "general_username";
}
return alias;
$scope.getLocalizedKey = function (alias) {
const translationKey = $scope.systemFields.find(x => x.value === alias)?.localizedKey;
return translationKey !== undefined ? translationKey : alias;
}
$scope.changeField = function () {
@@ -65,16 +49,18 @@ function includePropsPreValsController($rootScope, $scope, localizationService,
e.name = v;
switch (e.value) {
case "published":
case "updater":
e.name += " (Content only)";
break;
case "published":
e.name += " (Content only)";
break;
case "email":
e.name += " (Members only)";
break;
case "username":
case "email":
case "failedPasswordAttempts":
case "approved":
case "lockedOut":
case "lastLockoutDate":
case "lastLoginDate":
case "lastPasswordChangeDate":
e.name += " (Members only)";
break;
}
@@ -174,4 +160,4 @@ function includePropsPreValsController($rootScope, $scope, localizationService,
}
angular.module("umbraco").controller("Umbraco.PrevalueEditors.IncludePropertiesListViewController", includePropsPreValsController);
angular.module("umbraco").controller("Umbraco.PrevalueEditors.IncludePropertiesListViewController", includePropsPreValsController);

View File

@@ -213,7 +213,13 @@ function listViewController($scope, $interpolate, $routeParams, $injector, $time
e.alias === "email" ||
e.alias === "updateDate" ||
e.alias === "createDate" ||
e.alias === "contentTypeAlias";
e.alias === "contentTypeAlias" ||
e.alias === "failedPasswordAttempts" ||
e.alias === "approved" ||
e.alias === "lockedOut" ||
e.alias === "lastLockoutDate" ||
e.alias === "lastLoginDate" ||
e.alias === "lastPasswordChangeDate";
}
if (e.isSystem) {
@@ -815,6 +821,18 @@ function listViewController($scope, $interpolate, $routeParams, $injector, $time
return "general_email";
case "username":
return "general_username";
case "failedPasswordAttempts":
return "user_failedPasswordAttempts";
case "approved":
return "user_stateApproved";
case "lockedOut":
return "user_stateLockedOut";
case "lastLockoutDate":
return "user_lastLockoutDate";
case "lastLoginDate":
return "user_lastLogin";
case "lastPasswordChangeDate":
return "user_lastPasswordChangeDate";
}
return alias;
}

View File

@@ -53,7 +53,13 @@ function sortByPreValsController($rootScope, $scope, localizationService, editor
{ value: "ContentTypeAlias", key: "content_documentType" },
{ value: "Published", key: "content_isPublished" },
{ value: "Email", key: "general_email" },
{ value: "Username", key: "general_username" }
{ value: "Username", key: "general_username" },
{ value: "failedPasswordAttempts", key: "user_failedPasswordAttempts" },
{ value: "approved", key: "user_stateApproved" },
{ value: "lockedOut", key: "user_stateLockedOut" },
{ value: "lastLockoutDate", key: "user_lastLockoutDate" },
{ value: "lastLoginDate", key: "user_lastLogin" },
{ value: "lastPasswordChangeDate", key: "user_lastPasswordChangeDate" }
];
_.each(systemFields, function (e) {
localizationService.localize(e.key).then(function (v) {