OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Align headers on user activity page
Christophe Bliard08b14994b2b9
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rbindex 8ccb5fb2215..f1d9b955bcf 100644--- a/app/helpers/users_helper.rb+++ b/app/helpers/users_helper.rb@@ -118,6 +118,10 @@ module UsersHelperendend+ def visible_user_information?(user)+ user.pref.can_expose_mail? || user.visible_custom_field_values.any? { _1.value.present? }+ end+def user_name(user)user ? user.name : I18n.t('user.deleted')enddiff --git a/app/models/user_preference.rb b/app/models/user_preference.rbindex f710029d341..1eca2b38a17 100644--- a/app/models/user_preference.rb+++ b/app/models/user_preference.rb@@ -94,6 +94,10 @@ class UserPreference < ApplicationRecordsettings.fetch(:hide_mail, true)end+ def can_expose_mail?+ !hide_mail+ end+def auto_hide_popups=(value)settings[:auto_hide_popups] = to_boolean(value)enddiff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erbindex b5d3cb82b32..91c7e4cc119 100644--- a/app/views/users/show.html.erb+++ b/app/views/users/show.html.erb@@ -45,16 +45,18 @@ See COPYRIGHT and LICENSE files for more details.<div class="grid-block medium-up-2"><div class="grid-content"><%= call_hook :view_account_left_top, user: @user %>- <ul>- <% unless @user.pref.hide_mail %>- <li><%= User.human_attribute_name(:mail) %>: <%= mail_to(h(escape_javascript(@user.mail)), nil, encode: 'javascript') %></li>- <% end %>- <% @user.visible_custom_field_values.each do |custom_value| %>- <% if !custom_value.value.blank? %>- <li><%=h custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>+ <% if visible_user_information?(@user) %>+ <ul>+ <% if @user.pref.can_expose_mail? %>+ <li><%= User.human_attribute_name(:mail) %>: <%= mail_to(h(escape_javascript(@user.mail)), nil, encode: 'javascript') %></li><% end %>- <% end %>- </ul>+ <% @user.visible_custom_field_values.each do |custom_value| %>+ <% if custom_value.value.present? %>+ <li><%=h custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>+ <% end %>+ <% end %>+ </ul>+ <% end %><%= call_hook :view_account_left_middle, user: @user %>diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rbindex ee73ee5b880..d0da27a9f15 100644--- a/spec/helpers/users_helper_spec.rb+++ b/spec/helpers/users_helper_spec.rb@@ -114,4 +114,41 @@ RSpec.describe UsersHelper doendendend++ describe '#visible_user_information?' do+ subject { visible_user_information?(user) }++ context 'when user has hide_mail = false in their preferences' do+ let(:user) { build(:user, preferences: { hide_mail: false }) }++ it { is_expected.to be(true) }+ end++ context 'when user has hide_mail = true in their preferences' do+ let(:user) { build(:user, preferences: { hide_mail: true }) }++ it { is_expected.to be(false) }+ end++ context 'when user has a custom field with a present value' do+ let(:custom_field) { create(:string_user_custom_field) }+ let(:user) { build(:user, custom_values: [build(:custom_value, custom_field:, value: 'Hello')]) }++ it { is_expected.to be(true) }+ end++ context 'when user has a custom field with a blank value' do+ let(:custom_field) { create(:string_user_custom_field) }+ let(:user) { build(:user, custom_values: [build(:custom_value, custom_field:, value: ' ')]) }++ it { is_expected.to be(false) }+ end++ context 'when user has a non-visible custom field with a present value' do+ let(:custom_field) { create(:string_user_custom_field, visible: false) }+ let(:user) { build(:user, custom_values: [build(:custom_value, custom_field:, value: 'Hello')]) }++ it { is_expected.to be(false) }+ end+ endend