1 <%# Copyright (C) The Arvados Authors. All rights reserved.
3 SPDX-License-Identifier: AGPL-3.0 %>
6 profile_config = Rails.configuration.user_profile_form_fields
7 current_user_profile = current_user.prefs[:profile]
8 show_save_button = false
10 profile_message = Rails.configuration.user_profile_form_message
14 <div class="panel panel-default">
15 <div class="panel-heading">
16 <h4 class="panel-title">
20 <div class="panel-body">
21 <% if !missing_required_profile? && params[:offer_return_to] %>
22 <div class="alert alert-success">
23 <% if current_user.prefs[:getting_started_shown] %>
24 <p>Thank you for filling in your profile. <%= link_to 'Back to work!', params[:offer_return_to], class: 'btn btn-sm btn-primary' %></p>
26 <p>Thank you for filling in your profile. <%= link_to 'Get started', params[:offer_return_to], class: 'btn btn-sm btn-primary' %></p>
30 <div class="alert alert-info">
31 <p><%=raw(profile_message)%></p>
35 <%= form_for current_user, html: {id: 'save_profile_form', name: 'save_profile_form', class: 'form-horizontal'} do %>
36 <%= hidden_field_tag :offer_return_to, params[:offer_return_to] %>
37 <%= hidden_field_tag :return_to, profile_user_path(current_user.uuid, offer_return_to: params[:offer_return_to]) %>
38 <div class="form-group">
39 <label for="email" class="col-sm-3 control-label"> E-mail </label>
40 <div class="col-sm-8">
41 <p class="form-control-static" id="email" name="email"><%=current_user.email%></p>
44 <div class="form-group">
45 <label for="first_name" class="col-sm-3 control-label"> First Name </label>
46 <div class="col-sm-8">
47 <p class="form-control-static" id="first_name" name="first_name"><%=current_user.first_name%></p>
50 <div class="form-group">
51 <label for="last_name" class="col-sm-3 control-label"> Last Name </label>
52 <div class="col-sm-8">
53 <p class="form-control-static" id="last_name" name="last_name"><%=current_user.last_name%></p>
56 <div class="form-group">
57 <label for="identity_url" class="col-sm-3 control-label"> Identity URL </label>
58 <div class="col-sm-8">
59 <p class="form-control-static" id="identity_url" name="identity_url"><%=current_user.andand.identity_url%></p>
63 <% profile_config.kind_of?(Array) && profile_config.andand.each do |entry| %>
66 show_save_button = true
67 label = entry['required'] ? '* ' : ''
68 label += entry['form_field_title']
69 value = current_user_profile[entry['key'].to_sym] if current_user_profile
71 <div class="form-group">
72 <label for="<%=entry['key']%>"
73 class="col-sm-3 control-label"
74 style=<%="color:red" if entry['required']&&(!value||value.empty?)%>> <%=label%>
76 <% if entry['type'] == 'select' %>
77 <div class="col-sm-8">
78 <select class="form-control" name="user[prefs][profile][<%=entry['key']%>]">
79 <% entry['options'].each do |option| %>
80 <option value="<%=option%>" <%='selected' if option==value%>><%=option%></option>
85 <div class="col-sm-8">
86 <input type="text" class="form-control" name="user[prefs][profile][<%=entry['key']%>]" placeholder="<%=entry['form_field_description']%>" value="<%=value%>" ></input>
93 <%# If the user has other prefs, we need to preserve them %>
94 <% current_user.prefs.each do |key, value| %>
95 <% if key != :profile %>
96 <input type="hidden" name="user[prefs][<%=key%>]" value="<%=value.to_json%>">
100 <% if show_save_button %>
101 <div class="form-group">
102 <div class="col-sm-offset-3 col-sm-8">
103 <button type="submit" class="btn btn-primary">Save profile</button>