diff --git a/app/assets/javascripts/projects/index.js b/app/assets/javascripts/projects/index.js index 783f09c75..f6bb51855 100644 --- a/app/assets/javascripts/projects/index.js +++ b/app/assets/javascripts/projects/index.js @@ -237,6 +237,16 @@ }); } + // Initialize view project users modal remote loading. + function initViewProjectUsersLink() { + $('#cardsWrapper').on('ajax:success', '.view-project-users-link', function(e, data) { + let viewProjectUsersModal = $('#viewProjectUsersModal'); + viewProjectUsersModal.find('.modal-title').html(data.html_title); + viewProjectUsersModal.find('.modal-body').html(data.html_body); + viewProjectUsersModal.modal('show'); + }); + } + // Initialize reloading manage user modal content after posting new // user. function initAddUserForm() { @@ -627,6 +637,7 @@ initExportProjectsModal(); initExportProjects(); initArchiveRestoreToolbarButtons(); + initViewProjectUsersLink(); initManageProjectUsersLink(); initAddUserForm(); initRemoveUserLinks(); diff --git a/app/assets/stylesheets/projects.scss b/app/assets/stylesheets/projects.scss index b5d6ba55d..9aefbc68e 100644 --- a/app/assets/stylesheets/projects.scss +++ b/app/assets/stylesheets/projects.scss @@ -460,6 +460,12 @@ li.module-hover { } .projects-index { + .project-users-list { + hr { + margin: .5em 0; + } + } + .filter-container { .projects-filters { .select-block { @@ -525,6 +531,15 @@ li.module-hover { } .card { + .project-users-link { + color: $color-silver-chalice; + display: inline; + + &:hover { + text-decoration: none; + } + } + &.folder-card { text-align: center; @@ -664,15 +679,8 @@ li.module-hover { } .new-user { - align-items: center; background: $color-concrete; - border-radius: 50%; - color: $color-silver-chalice; - cursor: pointer; - display: flex; - height: 2em; - justify-content: center; - width: 2em; + text-align: center; } } } diff --git a/app/controllers/user_projects_controller.rb b/app/controllers/user_projects_controller.rb index c66c876bb..ae98a2eb2 100644 --- a/app/controllers/user_projects_controller.rb +++ b/app/controllers/user_projects_controller.rb @@ -10,16 +10,13 @@ class UserProjectsController < ApplicationController before_action :check_manage_permissions, only: %i(update destroy) def index - @users = @project.user_projects + @user_projects = @project.user_projects respond_to do |format| format.json do render json: { - html: render_to_string( - partial: 'index.html.erb' - ), - project_id: @project.id, - counter: @project.users.count # Used for counter badge + html_title: t('projects.index.modal_view_users.modal_title', name: @project.name), + html_body: render_to_string(partial: 'index.html.erb') } end end @@ -33,7 +30,6 @@ class UserProjectsController < ApplicationController respond_to do |format| format.json do render json: { - project: @project, html_title: t('projects.index.modal_manage_users.modal_title', name: @project.name), html_body: render_to_string(partial: 'index_edit.html.erb'), html_footer: render_to_string(partial: 'index_edit_footer.html.erb') @@ -51,7 +47,7 @@ class UserProjectsController < ApplicationController respond_to do |format| format.json do - redirect_to project_users_edit_path(format: :json), turbolinks: false + redirect_to edit_project_users_path(format: :json), turbolinks: false end end else @@ -77,7 +73,7 @@ class UserProjectsController < ApplicationController respond_to do |format| format.json do - redirect_to project_users_edit_path(format: :json), turbolinks: false + redirect_to edit_project_users_path(format: :json), turbolinks: false end end else @@ -97,7 +93,7 @@ class UserProjectsController < ApplicationController log_activity(:unassign_user_from_project) respond_to do |format| format.json do - redirect_to project_users_edit_path(format: :json), + redirect_to edit_project_users_path(format: :json), turbolinks: false, status: :see_other end diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb index f206db305..d60791634 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/projects/index.html.erb @@ -17,6 +17,7 @@ <%= render partial: 'projects/index/modals/edit_modal' %> <%= render partial: 'projects/index/modals/move_to_modal' %> + <%= render partial: 'projects/index/modals/view_users' %> <%= render partial: 'projects/index/modals/manage_users' %> <%= render partial: 'projects/index/modals/export_projects' %> diff --git a/app/views/projects/index/_project_card.html.erb b/app/views/projects/index/_project_card.html.erb index 67a4b570f..07c667422 100644 --- a/app/views/projects/index/_project_card.html.erb +++ b/app/views/projects/index/_project_card.html.erb @@ -50,29 +50,17 @@
<%= t('projects.index.card.users') %>
- - <% 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[4..-1].to_a %> - <% if more_users.any? %> - - +<%= more_users.size %> - - <% end %> - <% if can_manage_project?(project) %> - <%= link_to project_users_edit_path(project), - class: 'manage-users-link manage-project-users-link', - remote: true, - data: { 'view-mode': 'active' } do %> - + <%= link_to edit_project_users_path(project), class: 'project-users-link manage-project-users-link', remote: true do %> + <%= render partial: 'projects/index/users_list.html.erb', locals: { project: project } %> + <% end %> + <% else %> + <%= link_to project_users_path(project), class: 'project-users-link view-project-users-link', remote: true do %> + <%= render partial: 'projects/index/users_list.html.erb', locals: { project: project } %> + <% end %> <% end %>
diff --git a/app/views/projects/index/_users_list.html.erb b/app/views/projects/index/_users_list.html.erb new file mode 100644 index 000000000..e6ce7bdbd --- /dev/null +++ b/app/views/projects/index/_users_list.html.erb @@ -0,0 +1,12 @@ +<% 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[4..-1].to_a %> +<% if more_users.any? %> + + +<%= more_users.size %> + +<% end %> diff --git a/app/views/projects/index/modals/_view_users.html.erb b/app/views/projects/index/modals/_view_users.html.erb new file mode 100644 index 000000000..575c6de4a --- /dev/null +++ b/app/views/projects/index/modals/_view_users.html.erb @@ -0,0 +1,16 @@ + diff --git a/app/views/user_projects/_index.html.erb b/app/views/user_projects/_index.html.erb index 22fea5dc2..99f284570 100644 --- a/app/views/user_projects/_index.html.erb +++ b/app/views/user_projects/_index.html.erb @@ -1,30 +1,28 @@ -
<%= t("projects.index.users_tab") %>
-
-