diff --git a/Keas.Mvc/ClientApp/src/components/People/PersonDetails.tsx b/Keas.Mvc/ClientApp/src/components/People/PersonDetails.tsx index dc92c291a..2fff63f5c 100644 --- a/Keas.Mvc/ClientApp/src/components/People/PersonDetails.tsx +++ b/Keas.Mvc/ClientApp/src/components/People/PersonDetails.tsx @@ -41,6 +41,16 @@ const PersonDetails = (props: IProps) => { const canEdit = PermissionsUtil.canEditPeople(context.permissions); + // this is the only place we render pronouns. if we use them elsewhere, we should move this to a util + const formatPronouns = (pronouns: string) => { + pronouns = pronouns.trim(); + if (pronouns.startsWith('(') && pronouns.endsWith(')')) { + return pronouns; // if user has, say "(they/them" then that's their problem and i don't care + } else { + return `(${pronouns})`; + } + }; + return (
@@ -52,7 +62,18 @@ const PersonDetails = (props: IProps) => {
-

{props.selectedPersonInfo.person.name}

+
+

+ {props.selectedPersonInfo.person.name}{' '} +
+ {!!props.selectedPersonInfo.person.user?.pronouns && + formatPronouns( + props.selectedPersonInfo.person.user.pronouns + )} +
+

+
+ {canEdit && (
{ {canEdit && ( )}
diff --git a/Keas.Mvc/ClientApp/src/models/People.ts b/Keas.Mvc/ClientApp/src/models/People.ts index 11baa8e13..cfffbbc2a 100644 --- a/Keas.Mvc/ClientApp/src/models/People.ts +++ b/Keas.Mvc/ClientApp/src/models/People.ts @@ -12,6 +12,7 @@ export interface IUser { firstName: string; lastName: string; name: string; + pronouns: string; email: string; id: string; iam: string; diff --git a/Keas.Mvc/ClientApp/src/sass/_components.scss b/Keas.Mvc/ClientApp/src/sass/_components.scss index f83da4059..4b079b9b3 100644 --- a/Keas.Mvc/ClientApp/src/sass/_components.scss +++ b/Keas.Mvc/ClientApp/src/sass/_components.scss @@ -8,6 +8,7 @@ .card-head { padding: $card-padding; padding-top: 1.8rem; + align-items: end; } .card-content { padding: $card-padding; diff --git a/Keas.Mvc/Controllers/Api/PeopleController.cs b/Keas.Mvc/Controllers/Api/PeopleController.cs index 080978fd2..881938548 100644 --- a/Keas.Mvc/Controllers/Api/PeopleController.cs +++ b/Keas.Mvc/Controllers/Api/PeopleController.cs @@ -34,11 +34,11 @@ public PeopleController(ApplicationDbContext context, IIdentityService identityS this._identityService = identityService; _notificationService = notificationService; } - + /// /// /// - /// 0 = ShowActive, 1 = ShowInactive, 2 = ShowAll. Defaults to Show Active + /// 0 = ShowActive, 1 = ShowInactive, 2 = ShowAll. Defaults to Show Active /// [HttpGet] [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] @@ -77,6 +77,14 @@ public async Task List(ApiParameterModels.Filter filter = ApiPara FirstName = r.FirstName, LastName = r.LastName, Email = r.Email, + User = r.UserId == null ? null : new User + { + Id = r.UserId, + FirstName = r.FirstName, + LastName = r.LastName, + Email = r.Email, + Pronouns = r.Pronouns + }, Tags = r.Tags, TeamId = r.TeamId, Notes = r.Notes, @@ -198,7 +206,7 @@ public async Task SearchUsers(string searchTerm) [ProducesResponseType(typeof(Person), StatusCodes.Status200OK)] [Consumes(MediaTypeNames.Application.Json)] public async Task Create([FromBody] Person person) - { + { //This commented out code would be much clearer, but I don't feel like updating and testing it now -- Jason //if (!ModelState.IsValid) //{ @@ -220,7 +228,7 @@ public async Task Create([FromBody] Person person) if (string.IsNullOrWhiteSpace(person.UserId)) { ModelState.AddModelError("UserId", "Missing UserId"); - } + } if (ModelState.IsValid) { @@ -241,7 +249,7 @@ public async Task Create([FromBody] Person person) person.User = user; } else - { + { //Force lookup. Don't trust passed user person.User = await _identityService.GetByKerberos(person.UserId); } diff --git a/Keas.Mvc/Resources/PeopleQueries.cs b/Keas.Mvc/Resources/PeopleQueries.cs index 0df200f28..db5a57526 100644 --- a/Keas.Mvc/Resources/PeopleQueries.cs +++ b/Keas.Mvc/Resources/PeopleQueries.cs @@ -1,6 +1,6 @@ public static class PeopleQueries { - public static string List = @"select People.*, SUP.FirstName SupervisorFirstName, SUP.LastName SupervisorLastName, SUP.Email SupervisorEmail, SUP.UserId SupervisorUserId, EquipmentCount, AccessCount, KeyCount, WorkstationCount, + public static string List = @"select People.*, U.Pronouns, SUP.FirstName SupervisorFirstName, SUP.LastName SupervisorLastName, SUP.Email SupervisorEmail, SUP.UserId SupervisorUserId, EquipmentCount, AccessCount, KeyCount, WorkstationCount, cast(CASE WHEN EXISTS(SELECT * FROM People emp WHERE emp.SupervisorId = people.id) THEN 1 ELSE 0 END as bit) as isSupervisor from (select People.Id, count(E.Id) as EquipmentCount from People @@ -26,6 +26,7 @@ from People group by People.Id ) t4 on t1.Id = t4.Id left outer join People SUP on People.SupervisorId = SUP.Id + left outer join Users U on People.UserId = U.Id where (People.Active = @active1 or People.Active = @active2) and People.TeamId = @teamId;"; @@ -53,13 +54,13 @@ left outer join ( from People left join WorkstationAssignments WA on People.Id = WA.PersonId group by People.Id - ) t4 on t1.Id = t4.Id - left outer join People SUP on People.SupervisorId = SUP.Id - INNER JOIN - Teams ON People.TeamId = dbo.Teams.Id "; - - - + ) t4 on t1.Id = t4.Id + left outer join People SUP on People.SupervisorId = SUP.Id + INNER JOIN + Teams ON People.TeamId = dbo.Teams.Id "; + + + public static string PeopleLeavingWithAssets = @$"{PeopleLeavingCommon} where (People.Active = 0 or (People.EndDate is not null and People.EndDate <= @enddate)) and (EquipmentCount > 0 or AccessCount > 0 or KeyCount > 0 or WorkstationCount > 0) and People.TeamId = @teamId;";