Merge branch 'master' into 4523-full-text-search
[arvados.git] / apps / workbench / app / views / users / profile.html.erb
1 <%
2     profile_config = Rails.configuration.user_profile_form_fields
3     current_user_profile = current_user.prefs[:profile]
4     show_save_button = false
5
6     profile_message = Rails.configuration.user_profile_form_message
7 %>
8
9 <div>
10     <div class="panel panel-default">
11         <div class="panel-heading">
12           <h4 class="panel-title">
13             Profile
14           </h4>
15         </div>
16         <div class="panel-body">
17           <% if !missing_required_profile? && params[:offer_return_to] %>
18             <div class="alert alert-success">
19               <p>Thank you for filling in your profile. <%= link_to 'Back to work!', params[:offer_return_to], class: 'btn btn-sm btn-primary' %></p>
20             </div>
21           <% else %>
22             <div class="alert alert-info">
23               <p><%=raw(profile_message)%></p>
24             </div>
25           <% end %>
26
27             <%= form_for current_user, html: {id: 'save_profile_form', name: 'save_profile_form', class: 'form-horizontal'} do %>
28               <%= hidden_field_tag :offer_return_to, params[:offer_return_to] %>
29               <%= hidden_field_tag :return_to, profile_user_path(current_user.uuid, offer_return_to: params[:offer_return_to]) %>
30               <div class="form-group">
31                   <label for="email" class="col-sm-3 control-label"> E-mail </label>
32                   <div class="col-sm-8">
33                     <p class="form-control-static" id="email" name="email"><%=current_user.email%></p>
34                   </div>
35               </div>
36               <div class="form-group">
37                   <label for="first_name" class="col-sm-3 control-label"> First Name </label>
38                   <div class="col-sm-8">
39                     <p class="form-control-static" id="first_name" name="first_name"><%=current_user.first_name%></p>
40                   </div>
41               </div>
42               <div class="form-group">
43                   <label for="last_name" class="col-sm-3 control-label"> Last Name </label>
44                   <div class="col-sm-8">
45                     <p class="form-control-static" id="last_name" name="last_name"><%=current_user.last_name%></p>
46                   </div>
47               </div>
48               <div class="form-group">
49                   <label for="identity_url" class="col-sm-3 control-label"> Identity URL </label>
50                   <div class="col-sm-8">
51                     <p class="form-control-static" id="identity_url" name="identity_url"><%=current_user.andand.identity_url%></p>
52                   </div>
53               </div>
54
55               <% profile_config.kind_of?(Array) && profile_config.andand.each do |entry| %>
56                 <% if entry['key'] %>
57                   <%
58                       show_save_button = true
59                       label = entry['required'] ? '* ' : ''
60                       label += entry['form_field_title']
61                       value = current_user_profile[entry['key'].to_sym] if current_user_profile
62                   %>
63                   <div class="form-group">
64                     <label for="<%=entry['key']%>"
65                            class="col-sm-3 control-label"
66                            style=<%="color:red" if entry['required']&&(!value||value.empty?)%>> <%=label%>
67                     </label>
68                     <% if entry['type'] == 'select' %>
69                       <div class="col-sm-8">
70                         <select class="form-control" name="user[prefs][:profile][:<%=entry['key']%>]">
71                           <% entry['options'].each do |option| %>
72                             <option value="<%=option%>" <%='selected' if option==value%>><%=option%></option>
73                           <% end %>
74                         </select>
75                       </div>
76                     <% else %>
77                       <div class="col-sm-8">
78                         <input type="text" class="form-control" name="user[prefs][:profile][:<%=entry['key']%>]" placeholder="<%=entry['form_field_description']%>" value="<%=value%>" ></input>
79                       </div>
80                     <% end %>
81                   </div>
82                 <% end %>
83               <% end %>
84
85               <% if show_save_button %>
86                 <div class="form-group">
87                   <div class="col-sm-offset-3 col-sm-8">
88                     <button type="submit" class="btn btn-primary">Save profile</button>
89                   </div>
90                 </div>
91               <% end %>
92             <% end %>
93         </div>
94     </div>
95 </div>