From cd43973952605c18fc9d071f01df65763347b674 Mon Sep 17 00:00:00 2001 From: Urban Rotnik Date: Mon, 4 Jan 2021 16:44:31 +0100 Subject: [PATCH 1/3] Add tooltips for users on project cards --- app/helpers/projects_helper.rb | 8 ++++++++ app/views/projects/index/_project_card.html.erb | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index ea2ce7024..a6140144f 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -5,6 +5,14 @@ module ProjectsHelper t('user_projects.enums.role.' + user_project.role) end + def user_names_with_roles(user_projects) + user_projects.map { |up| user_name_with_role(up) }.join(' ') + end + + def user_name_with_role(user_project) + "#{user_project.user.name} - #{I18n.t("user_projects.enums.role.#{user_project.role}")}" + end + def construct_module_connections(my_module) conns = [] my_module.outputs.each do |output| diff --git a/app/views/projects/index/_project_card.html.erb b/app/views/projects/index/_project_card.html.erb index 26329d1b5..a4ca471fc 100644 --- a/app/views/projects/index/_project_card.html.erb +++ b/app/views/projects/index/_project_card.html.erb @@ -37,12 +37,19 @@ <%= t('projects.index.card.users') %>
- <% project.users.each do |user| %> + <% project.user_projects[0..4].each do |user_project| %> - <%= image_tag avatar_path(user, :icon_small) %> + <%= image_tag(avatar_path(user_project.user, :icon_small), title: user_name_with_role(user_project)) %> <% end %> + <% more_users = project.user_projects[5..-1].to_a %> + <% if more_users.any? %> + + + <%= more_users.size %> + + <% end %> + <% if project.active? %> <%= link_to project_users_edit_path(project), class: 'manage-users-link', From 283bfc8759dd22520df0bd8daef9b6425da046bc Mon Sep 17 00:00:00 2001 From: Mojca Lorber Date: Tue, 5 Jan 2021 18:31:33 +0100 Subject: [PATCH 2/3] Update css for users on project cards --- app/assets/stylesheets/projects.scss | 21 +++++++++++++++++-- app/helpers/projects_helper.rb | 4 ++-- .../projects/index/_project_card.html.erb | 8 +++---- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/app/assets/stylesheets/projects.scss b/app/assets/stylesheets/projects.scss index 80f60ccca..a3b844c18 100644 --- a/app/assets/stylesheets/projects.scss +++ b/app/assets/stylesheets/projects.scss @@ -528,7 +528,7 @@ li.module-hover { grid-auto-rows: 2em; grid-column-gap: 1em; grid-row-gap: 1em; - grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); + grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); width: 100%; .table-header { @@ -767,7 +767,7 @@ li.module-hover { grid-auto-rows: 2em; grid-column-gap: 1em; grid-row-gap: 1em; - grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); + grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); width: 100%; .table-header { @@ -926,6 +926,23 @@ li.module-hover { display: none; } + .more-users { + align-items: center; + background: $color-volcano; + border-radius: 50%; + color: $color-white; + cursor: pointer; + display: flex; + height: 2em; + justify-content: center; + margin-right: .25em; + width: 2em; + + &:hover { + text-decoration: none; + } + } + .new-user { align-items: center; background: $color-concrete; diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index a6140144f..5fcb1e236 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -6,11 +6,11 @@ module ProjectsHelper end def user_names_with_roles(user_projects) - user_projects.map { |up| user_name_with_role(up) }.join(' ') + user_projects.map { |up| user_name_with_role(up) }.join(' ').html_safe end def user_name_with_role(user_project) - "#{user_project.user.name} - #{I18n.t("user_projects.enums.role.#{user_project.role}")}" + sanitize_input("#{user_project.user.name} - #{I18n.t("user_projects.enums.role.#{user_project.role}")}") end def construct_module_connections(my_module) diff --git a/app/views/projects/index/_project_card.html.erb b/app/views/projects/index/_project_card.html.erb index a4ca471fc..7a3e9f32c 100644 --- a/app/views/projects/index/_project_card.html.erb +++ b/app/views/projects/index/_project_card.html.erb @@ -37,16 +37,16 @@ <%= t('projects.index.card.users') %>
- <% project.user_projects[0..4].each do |user_project| %> + <% project.user_projects[0..3].each do |user_project| %> <%= image_tag(avatar_path(user_project.user, :icon_small), title: user_name_with_role(user_project)) %> <% end %> - <% more_users = project.user_projects[5..-1].to_a %> + <% more_users = project.user_projects[4..-1].to_a %> <% if more_users.any? %> - - + <%= more_users.size %> + + +<%= more_users.size %> <% end %> From 2ebd78676fbb2de3483d9b688543e48588272f18 Mon Sep 17 00:00:00 2001 From: Mojca Lorber Date: Wed, 6 Jan 2021 09:14:43 +0100 Subject: [PATCH 3/3] Move sanitize_input --- app/helpers/projects_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 5fcb1e236..6e1b0f818 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -10,7 +10,7 @@ module ProjectsHelper end def user_name_with_role(user_project) - sanitize_input("#{user_project.user.name} - #{I18n.t("user_projects.enums.role.#{user_project.role}")}") + "#{sanitize_input(user_project.user.name)} - #{I18n.t("user_projects.enums.role.#{user_project.role}")}" end def construct_module_connections(my_module)