X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/32af86f5f4a2849b12c96e40ed20d33b7682ba55..5e9787f914dd1a2f762ae7a653fe8dda36f8f555:/apps/workbench/app/views/users/profile.html.erb diff --git a/apps/workbench/app/views/users/profile.html.erb b/apps/workbench/app/views/users/profile.html.erb index 2c40fefb63..caa22bda11 100644 --- a/apps/workbench/app/views/users/profile.html.erb +++ b/apps/workbench/app/views/users/profile.html.erb @@ -1,16 +1,20 @@ +<%# Copyright (C) The Arvados Authors. All rights reserved. + +SPDX-License-Identifier: AGPL-3.0 %> + <% - profile_config = Rails.configuration.user_profile_form_fields + profile_config = [] + Rails.configuration.Workbench.UserProfileFormFields.each do |k, v| + r = v.dup + r["Key"] = k + profile_config << r + end + profile_config.sort_by! { |v| v["Position"] } + current_user_profile = current_user.prefs[:profile] show_save_button = false - profile_message = Rails.configuration.user_profile_form_message ? Rails.configuration.user_profile_form_message : 'You can manage your profile using this page. Any feilds in red are required and missing. Please fill in those fields before you can accesse Arvados Workbench.' - - missing_required = missing_required_profile? - - profile_url = '/users/'+current_user.uuid+'/profile' - target = request.url.partition('?target=')[-1] - target = request.url if target.empty? - return_to_url = (request.url.ends_with? profile_url) ? profile_url : profile_url+'?target='+target + profile_message = Rails.configuration.Workbench.UserProfileFormMessage %>
@@ -21,38 +25,37 @@
- <% if !missing_required && params.andand.keys.include?('target') %> -
-

Thank you for filling in your profile. If you are done updating your profile, - you can now access Arvados Workbench by clicking on this button. -

- -
-

+ <% if !missing_required_profile? && params[:offer_return_to] %> +
+ <% if current_user.prefs[:getting_started_shown] %> +

Thank you for filling in your profile. <%= link_to 'Back to work!', params[:offer_return_to], class: 'btn btn-sm btn-primary' %>

+ <% else %> +

Thank you for filling in your profile. <%= link_to 'Get started', params[:offer_return_to], class: 'btn btn-sm btn-primary' %>

+ <% end %>
<% else %> -
-

<%=raw(profile_message)%>

+
+

<%=raw(profile_message)%>

<% end %> -
- <%= form_tag "/users/#{current_user.uuid}", {method: 'patch', id: 'save_profile_form', name: 'save_profile_form', class: 'form-horizontal'} do %> - <%= hidden_field_tag :return_to, return_to_url %> + <%= form_for current_user, html: {id: 'save_profile_form', name: 'save_profile_form', class: 'form-horizontal'} do %> + <%= hidden_field_tag :offer_return_to, params[:offer_return_to] %> + <%= hidden_field_tag :return_to, profile_user_path(current_user.uuid, offer_return_to: params[:offer_return_to]) %>
- +

<%=current_user.email%>

- +

<%=current_user.first_name%>

- +

<%=current_user.last_name%>

@@ -65,35 +68,43 @@
<% profile_config.kind_of?(Array) && profile_config.andand.each do |entry| %> - <% if entry['key'] %> + <% if entry[:Key] %> <% show_save_button = true - label = entry['required'] ? '* ' : '' - label += entry['form_field_title'] - value = current_user_profile[entry['key'].to_sym] if current_user_profile + label = entry[:Required] ? '* ' : '' + label += entry[:FormFieldTitle] + value = current_user_profile[entry[:Key].to_sym] if current_user_profile %>
- - <% if entry['type'] == 'select' %> + <% if entry[:Type] == 'select' %>
- + <% entry[:Options].each do |option, _| %> + <% option = option.to_s %> <% end %>
<% else %>
- +
<% end %>
<% end %> <% end %> + <%# If the user has other prefs, we need to preserve them %> + <% current_user.prefs.each do |key, value| %> + <% if key != :profile %> + + <% end %> + <% end %> + <% if show_save_button %>
@@ -102,7 +113,6 @@
<% end %> <% end %> -