Fix 2.4.2 upgrade notes formatting refs #19330
[arvados.git] / apps / workbench / app / views / users / profile.html.erb
1 <%# Copyright (C) The Arvados Authors. All rights reserved.
2
3 SPDX-License-Identifier: AGPL-3.0 %>
4
5 <%
6     profile_config = []
7     Rails.configuration.Workbench.UserProfileFormFields.each do |k, v|
8       r = v.dup
9       r["Key"] = k
10       profile_config << r
11     end
12     profile_config.sort_by! { |v| v["Position"] }
13
14     current_user_profile = current_user.prefs[:profile]
15     show_save_button = false
16
17     profile_message = Rails.configuration.Workbench.UserProfileFormMessage
18 %>
19
20 <div>
21     <div class="panel panel-default">
22         <div class="panel-heading">
23           <h4 class="panel-title">
24             Profile
25           </h4>
26         </div>
27         <div class="panel-body">
28           <% if !missing_required_profile? && params[:offer_return_to] %>
29             <div class="alert alert-success">
30               <% if current_user.prefs[:getting_started_shown] %>
31                 <p>Thank you for filling in your profile. <%= link_to 'Back to work!', params[:offer_return_to], class: 'btn btn-sm btn-primary' %></p>
32               <% else %>
33                 <p>Thank you for filling in your profile. <%= link_to 'Get started', params[:offer_return_to], class: 'btn btn-sm btn-primary' %></p>
34               <% end %>
35             </div>
36           <% else %>
37             <div class="alert alert-info">
38               <p><%=raw(profile_message)%></p>
39             </div>
40           <% end %>
41
42             <%= form_for current_user, html: {id: 'save_profile_form', name: 'save_profile_form', class: 'form-horizontal'} do %>
43               <%= hidden_field_tag :offer_return_to, params[:offer_return_to] %>
44               <%= hidden_field_tag :return_to, profile_user_path(current_user.uuid, offer_return_to: params[:offer_return_to]) %>
45               <div class="form-group">
46                   <label for="email" class="col-sm-3 control-label"> E-mail </label>
47                   <div class="col-sm-8">
48                     <p class="form-control-static" id="email" name="email"><%=current_user.email%></p>
49                   </div>
50               </div>
51               <div class="form-group">
52                   <label for="first_name" class="col-sm-3 control-label"> First Name </label>
53                   <div class="col-sm-8">
54                     <p class="form-control-static" id="first_name" name="first_name"><%=current_user.first_name%></p>
55                   </div>
56               </div>
57               <div class="form-group">
58                   <label for="last_name" class="col-sm-3 control-label"> Last Name </label>
59                   <div class="col-sm-8">
60                     <p class="form-control-static" id="last_name" name="last_name"><%=current_user.last_name%></p>
61                   </div>
62               </div>
63               <div class="form-group">
64                   <label for="identity_url" class="col-sm-3 control-label"> Identity URL </label>
65                   <div class="col-sm-8">
66                     <p class="form-control-static" id="identity_url" name="identity_url"><%=current_user.andand.identity_url%></p>
67                   </div>
68               </div>
69
70               <% profile_config.kind_of?(Array) && profile_config.andand.each do |entry| %>
71                 <% if entry[:Key] %>
72                   <%
73                       show_save_button = true
74                       label = entry[:Required] ? '* ' : ''
75                       label += entry[:FormFieldTitle]
76                       value = current_user_profile[entry[:Key].to_sym] if current_user_profile
77                   %>
78                   <div class="form-group">
79                     <label for="<%=entry[:Key]%>"
80                            class="col-sm-3 control-label"
81                            style=<%="color:red" if entry[:Required]&&(!value||value.empty?)%>> <%=label%>
82                     </label>
83                     <% if entry[:Type] == 'select' %>
84                       <div class="col-sm-8">
85                         <select class="form-control" name="user[prefs][profile][<%=entry[:Key]%>]">
86                           <% entry[:Options].each do |option, _| %>
87                             <% option = option.to_s %>
88                             <option value="<%=option%>" <%='selected' if option==value%>><%=option%></option>
89                           <% end %>
90                         </select>
91                       </div>
92                     <% else %>
93                       <div class="col-sm-8">
94                         <input type="text" class="form-control" name="user[prefs][profile][<%=entry[:Key]%>]" placeholder="<%=entry[:FormFieldDescription]%>" value="<%=value%>" ></input>
95                       </div>
96                     <% end %>
97                   </div>
98                 <% end %>
99               <% end %>
100
101               <%# If the user has other prefs, we need to preserve them %>
102               <% current_user.prefs.each do |key, value| %>
103                 <% if key != :profile %>
104                   <input type="hidden" name="user[prefs][<%=key%>]" value="<%=value.to_json%>">
105                 <% end %>
106               <% end %>
107
108               <% if show_save_button %>
109                 <div class="form-group">
110                   <div class="col-sm-offset-3 col-sm-8">
111                     <button type="submit" class="btn btn-primary">Save profile</button>
112                   </div>
113                 </div>
114               <% end %>
115             <% end %>
116         </div>
117     </div>
118 </div>