add pronouns to profile page

fixes KNO-132
flag=account_pronouns

Test Plan:
- on the account settings page enable profiles for your account
- as a user go to the profile page
- notice in the edit settings you can edit your pronouns
- edit pronouns
- notice they now show up
- remove pronouns
- notice they go away

Change-Id: I51053a9e6e06e271d17e3ba5c9e5069f4875b979
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/217564
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Tested-by: Jenkins
Reviewed-by: Ryan Shaw <ryan@instructure.com>
QA-Review: Steven Burnett <sburnett@instructure.com>
Product-Review: Steven Burnett <sburnett@instructure.com>
This commit is contained in:
Steven Burnett 2019-11-16 22:25:49 -07:00
parent 4f6b22b87e
commit b8258a0bb9
3 changed files with 9 additions and 3 deletions

View File

@ -402,6 +402,7 @@ class ProfileController < ApplicationController
@context = @profile
short_name = params[:user] && params[:user][:short_name]
@user.pronouns = params[:pronouns] if params[:pronouns]
@user.short_name = short_name if short_name && @user.user_can_edit_name?
if params[:user_profile]
user_profile_params = params[:user_profile].permit(:title, :bio)

View File

@ -42,10 +42,15 @@
<div class="profileContent__Block">
<% if @user_data[:can_edit_name] %>
<h2 class="hide-if-editing"><%= @user_data[:short_name] %></h2>
<h2 class="hide-if-editing"><%= @user_data[:short_name] %> <% if @user_data[:pronouns] %><i>(<%= @user_data[:pronouns] %>)</i><% end %></h2>
<label class="show-if-editing ic-Label"><%= t('name', 'Name') %>:
<input aria-label="<%= t 'Name' %>" id="name_input" class="ic-Input" type="text" name="user[short_name]" value="<%= @user_data[:short_name] %>" required>
</label>
<%# even if @domain_root_account.settings[:can_add_pronouns] is false, we still want to let someone that has pronouns set to see this so they can unset them %>
<% if @user.pronouns || @domain_root_account.settings[:can_add_pronouns] %>
<label for="pronouns"class="show-if-editing ic-Label"><%= t('Pronouns') %>:</label>
<%= select_tag :pronouns, options_for_select([[t("None"), '']] + @domain_root_account.pronouns, @user.pronouns), class:"show-if-editing" %>
<% end %>
<p class="profileDetails">
<span class="hide-if-editing"><%= @user_data[:title] %></span>
<label class="show-if-editing ic-Label"><%= t('title', 'Title') %>:
@ -53,7 +58,7 @@
</label>
</p>
<% else %>
<h2><%= @user_data[:short_name] %></h2>
<h2><%= @user_data[:short_name] %> <% if @user_data[:pronouns] %><i>(<%= @user_data[:pronouns] %>)</i><% end %></h2>
<p><%= @user_data[:title] %></p>
<% end %>

View File

@ -28,7 +28,7 @@ module Api::V1::UserProfile
json = user_json(user, current_user, session, 'avatar_url', context)
# don't unintentionally include stuff added to user_json
json.slice! :id, :name, :short_name, :sortable_name, :sis_user_id,
:sis_login_id, :login_id, :avatar_url, :integration_id
:sis_login_id, :login_id, :avatar_url, :integration_id, :pronouns
json[:title] = profile.title
json[:bio] = profile.bio