profile.mustache 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <%
  2. # Copyright (C) 2012 - present Instructure, Inc.
  3. #
  4. # This file is part of Canvas.
  5. #
  6. # Canvas is free software: you can redistribute it and/or modify it under
  7. # the terms of the GNU Affero General Public License as published by the Free
  8. # Software Foundation, version 3 of the License.
  9. #
  10. # Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
  11. # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. # A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  13. # details.
  14. #
  15. # You should have received a copy of the GNU Affero General Public License along
  16. # with this program. If not, see <http://www.gnu.org/licenses/>.
  17. %>
  18. <%
  19. css_bundle :profile_show, :tinymce
  20. js_bundle :profile_show
  21. @body_classes << 'not-editing'
  22. js_env PROFILE: @user_data if @user_data[:can_edit]
  23. js_env(folder_id: @user.profile_pics_folder.id) if @user == @current_user
  24. %>
  25. <%= form_tag update_profile_profile_path, { :method => :put, :id => :edit_profile_form, :class => "ic-Form-control" } do %>
  26. <div class="image-block">
  27. <div class="image-block-image profile-avatar-wrapper">
  28. <% if @user_data[:can_edit] %>
  29. <%= avatar(@user_data[:id], size: 128, url: '#', edit: true, class: "profile-link", title: t('titles.click_to_change_profile_pic', "Click to change profile pic")) %>
  30. <% elsif @user != @current_user %>
  31. <%= avatar(@user, size: 128, url: report_avatar_image_url(@user.id),
  32. class: "report_avatar_link", title: t("Click to report profile picture"), show_flag: true) %>
  33. <% else %>
  34. <%= avatar(@user_data[:id], size: 128, url: nil) %>
  35. <% end %>
  36. </div>
  37. <div class="profileContent__Block">
  38. <% if @user_data[:can_edit_name] %>
  39. <h2 class="hide-if-editing"><%= @user_data[:short_name] %></h2>
  40. <label class="show-if-editing ic-Label">{{#t}}Name{{/t}}:
  41. <input aria-label="<%= t 'Name' %>" id="name_input" class="ic-Input" type="text" name="user[short_name]" value="<%= @user_data[:short_name] %>" required>
  42. </label>
  43. <p class="profileDetails">
  44. <span class="hide-if-editing"><%= @user_data[:title] %></span>
  45. <label class="show-if-editing ic-Label">{{#t}}Title{{/t}}:
  46. <input aria-label="<%= t 'Title' %>" class="ic-Input" type="text" name="user_profile[title]" value="<%= @user_data[:title] %>">
  47. </label>
  48. </p>
  49. <% else %>
  50. <h2><%= @user_data[:short_name] %></h2>
  51. <p><%= @user_data[:title] %></p>
  52. <% end %>
  53. <div class="show-if-editing edit-contact-methods">
  54. <h3 class="profileHeader">{{#t}}Contact{{/t}}</h3>
  55. <% if @user_data[:user_services].present? %>
  56. <ul class="social-links">
  57. <li>
  58. <label for="social_message" class="social hide-text message ic-Label" title="<%= t :message_title, 'Message' %>" data-tooltip><%= t :message_me, 'message me in Canvas' %></label>
  59. </li>
  60. <% @user_data[:user_services].each do |s| %>
  61. <li>
  62. <% service_name = s[:service_name] || s[:service].to_s.titleize %>
  63. <label for="social_<%= s[:service] %>" class="social hide-text <%= s[:service] %> ic-Label" title="<%= service_name %>" data-tooltip><%= t :service_contact, 'contact %{user} with %{service}', :user => @user_data[:short_name], :service => service_name %></label>
  64. <input class="ic-Input" type="hidden" value="0" name="user_services[<%= s[:service] %>">
  65. <%= check_box_tag "user_services[#{s[:service]}]", 1, s[:visible], :id => "social_#{s[:service]}" %>
  66. </li>
  67. <% end %>
  68. </ul>
  69. <div class="social-instructions">
  70. <p>
  71. {{#t}}Check the contact methods you'd like to be visible to others on your profile.{{/t}}<br>
  72. <%= link_to(t(:manage_settings, "Manage Registered Services"), settings_profile_path) %>
  73. </p>
  74. </div>
  75. <% else %>
  76. <p><%= t('#profile.you_have_no_services', "No registered services, you can add some on the *settings* page.", :name => @user_data[:short_name], :wrapper => link_to('\1', settings_profile_path)) %></p>
  77. <% end %>
  78. </div>
  79. <div class="hide-if-editing">
  80. <h3 class="profileHeader"><%= t :ways_to_contact_user, "Contact" %></h3>
  81. <% if @user_data[:user_services].blank? && @user == @current_user %>
  82. <p><%= t('#profile.you_have_no_services', "No registered services, you can add some on the *settings* page.", :name => @user_data[:short_name], :wrapper => link_to('\1', settings_profile_path)) %></p>
  83. <% else %>
  84. <ul class="social-links">
  85. <% if current_user_is_account_admin && @user != @current_user %>
  86. <li><a href="<%= message_user_path(@user) %>" class="social hide-text message" title="<%= t :message_title, 'Message' %>" data-tooltip><%= t :message_user_canvas, 'Message %{user} in Canvas', :user => @user_data[:short_name] %></a></li>
  87. <% end %>
  88. <% if @user_data[:user_services].present? && @user.show_user_services %>
  89. <% @user_data[:user_services].select{|s| s[:visible] }.each do |s| %>
  90. <% service_name = s[:service_name] || s[:service].to_s.titleize %>
  91. <li><a href="<%= s[:service_user_link] %>" class="social hide-text <%= s[:service] %>" title="<%= service_name %>" data-tooltip><%= t :service_contact, 'contact %{user} with %{service}', :user => @user_data[:short_name], :service => service_name %></a></li>
  92. <% end %>
  93. <% end %>
  94. </ul>
  95. <% end %>
  96. </div>
  97. <div>
  98. <h3 id="profile_bio_label" class="profileHeader"><%= t :bio, "Biography" %></h3>
  99. <% if @user_data[:bio] %>
  100. <div class="hide-if-editing"><%= raw format_message(@user_data[:bio]).first %></div>
  101. <% else %>
  102. <p class="hide-if-editing"><%= t('user_has_no_bio', "%{user} hasn't added a bio", :user => @user_data[:short_name]) %></p>
  103. <% end %>
  104. <% if @user_data[:can_edit] %>
  105. <div class="show-if-editing">
  106. <textarea class="ic_Input" id="profile_bio" name="user_profile[bio]" aria-labelledby="profile_bio_label"><%= @user_data[:bio] %></textarea>
  107. </div>
  108. <% end %>
  109. </div>
  110. <div>
  111. <% if @user != @current_user %>
  112. <div class="hide-if-editing">
  113. <h3 class="profileHeader"><%= t :user_enrolled, "Enrollments" %></h3>
  114. <% if @user_data[:common_contexts] %>
  115. <ul>
  116. <% @user_data[:common_contexts].each do |context| %>
  117. <li class="profileEnrollment__Items"><%= context[:roles].join(', ') %> in <a href="<%= context[:html_url] %>"><%= context[:name] %></a></li>
  118. <% end %>
  119. </ul>
  120. <% else %>
  121. <p>{{#t}}You don't have anything in common{{/t}}</p>
  122. <% end %>
  123. </div>
  124. <% end %>
  125. </div>
  126. <div class="profile_links">
  127. <h3 class="profileHeader"><%= t :links, "Links" %></h3>
  128. <div class="hide-if-editing">
  129. <% if @user_data[:links].length > 0 %>
  130. <ul class="profileLink">
  131. <% @user_data[:links].each do |link| %>
  132. <li class="profileLink__Item">
  133. <i class="icon-link" role="presentation"></i>
  134. <a href="<%= add_uri_scheme_name(link[:url]) %>"><%= link[:title] %></a>
  135. </li>
  136. <% end %>
  137. </ul>
  138. <% else %>
  139. <p><%= t :no_links, "%{name} hasn't added any links", :name => @user_data[:short_name] %></p>
  140. <% end %>
  141. </div>
  142. <% if @user_data[:can_edit] %>
  143. <input type="hidden" name="delete_links" value="1">
  144. <div class="show-if-editing">
  145. <table id="edit_links_table">
  146. <thead>
  147. <th scope="col"><%= t :links_title, 'Title' %></th>
  148. <th></th>
  149. <th scope="col"><%= t :links_url, 'URL' %></th>
  150. </thead>
  151. <tbody id="profile_link_fields"></tbody>
  152. </table>
  153. <button data-event="addLinkField" class="btn btn-small"><%= t :add_link_field, "Add another link" %></button>
  154. </div>
  155. <% end %>
  156. </div>
  157. <% if @user_data[:can_edit] %>
  158. <div class="form-actions no-margin-bottom show-if-editing">
  159. <button data-event="cancelEditProfile" class="btn">{{#t}}Cancel{{/t}}</button>
  160. <button class="btn btn-primary">{{#t}}Save Profile{{/t}}</button>
  161. </div>
  162. <% end %>
  163. </div>
  164. </div>
  165. <% end %>