Skip to content

Commit

Permalink
Merge pull request #1317 from ucdavis/RH/frontend-pronouns
Browse files Browse the repository at this point in the history
Rh/frontend pronouns
  • Loading branch information
laholstege authored Sep 22, 2023
2 parents a12c4e5 + 1ea0d5f commit 9d3f66e
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 16 deletions.
27 changes: 24 additions & 3 deletions Keas.Mvc/ClientApp/src/components/People/PersonDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div>
<div>
Expand All @@ -52,7 +62,18 @@ const PersonDetails = (props: IProps) => {
<div className='card'>
<div className='card-header-people'>
<div className='card-head row justify-content-between'>
<h2>{props.selectedPersonInfo.person.name}</h2>
<div className='row justify-content-between'>
<h2>
{props.selectedPersonInfo.person.name}{' '}
<div className='discreet'>
{!!props.selectedPersonInfo.person.user?.pronouns &&
formatPronouns(
props.selectedPersonInfo.person.user.pronouns
)}
</div>
</h2>
</div>

{canEdit && (
<div className='row justify-content-between'>
<EditPerson
Expand Down Expand Up @@ -118,8 +139,8 @@ const PersonDetails = (props: IProps) => {
{canEdit && (
<HistoryContainer
controller='peopleAdmin'
id={props.selectedPersonInfo.person.id}
showLink={true}
id={props.selectedPersonInfo.person.id}
showLink={true}
/>
)}
</div>
Expand Down
1 change: 1 addition & 0 deletions Keas.Mvc/ClientApp/src/models/People.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface IUser {
firstName: string;
lastName: string;
name: string;
pronouns: string;
email: string;
id: string;
iam: string;
Expand Down
1 change: 1 addition & 0 deletions Keas.Mvc/ClientApp/src/sass/_components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
.card-head {
padding: $card-padding;
padding-top: 1.8rem;
align-items: end;
}
.card-content {
padding: $card-padding;
Expand Down
18 changes: 13 additions & 5 deletions Keas.Mvc/Controllers/Api/PeopleController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public PeopleController(ApplicationDbContext context, IIdentityService identityS
this._identityService = identityService;
_notificationService = notificationService;
}


/// <summary>
///
/// </summary>
/// <param name="filter">0 = ShowActive, 1 = ShowInactive, 2 = ShowAll. Defaults to Show Active</param>
/// <param name="filter">0 = ShowActive, 1 = ShowInactive, 2 = ShowAll. Defaults to Show Active</param>
/// <returns></returns>
[HttpGet]
[ProducesResponseType(typeof(IEnumerable<Person>), StatusCodes.Status200OK)]
Expand Down Expand Up @@ -77,6 +77,14 @@ public async Task<IActionResult> 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,
Expand Down Expand Up @@ -198,7 +206,7 @@ public async Task<IActionResult> SearchUsers(string searchTerm)
[ProducesResponseType(typeof(Person), StatusCodes.Status200OK)]
[Consumes(MediaTypeNames.Application.Json)]
public async Task<IActionResult> 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)
//{
Expand All @@ -220,7 +228,7 @@ public async Task<IActionResult> Create([FromBody] Person person)
if (string.IsNullOrWhiteSpace(person.UserId))
{
ModelState.AddModelError("UserId", "Missing UserId");
}
}

if (ModelState.IsValid)
{
Expand All @@ -241,7 +249,7 @@ public async Task<IActionResult> Create([FromBody] Person person)
person.User = user;
}
else
{
{
//Force lookup. Don't trust passed user
person.User = await _identityService.GetByKerberos(person.UserId);
}
Expand Down
17 changes: 9 additions & 8 deletions Keas.Mvc/Resources/PeopleQueries.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;";


Expand Down Expand Up @@ -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;";

Expand Down

0 comments on commit 9d3f66e

Please sign in to comment.