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") %>
-
-
- <% if @users.size == 0 then %>
- - <%= t 'projects.index.no_users' %>
+
+ <% if @user_projects.blank? %>
+ -
+ <%= t('projects.index.modal_view_users.no_users') %>
+
<% else %>
- <% @users.each_with_index do |user_proj, i| user = user_proj.user %>
+ <% @user_projects.each do |user_project| %>
-
- <% if i > 0 %>
<% end %>
-
+
- <%= image_tag avatar_path(user, :icon_small), class: 'img-circle pull-left' %>
+ <%= image_tag avatar_path(user_project.user, :icon_small), class: 'img-circle pull-left' %>
-
-
<%= user.full_name %>
-
<%= t('user_projects.enums.role.'<< user_proj.role.to_s) %>
+
+ <%= user_project.user.full_name %>
+ <% if user_project.user == current_user %>
+ <%= t('projects.index.modal_view_users.current_user_label') %>
+ <% end %>
+
+ <%= t('user_projects.enums.role.'<< user_project.role) %>
+
<% end %>
<% end %>
-<% if can_manage_project?(@project) %>
-
-
- <%= link_to t("projects.index.manage_users"), project_users_edit_path(@project, format: :json), class: "manage-users-link", remote: true %>
-
-<% end %>
diff --git a/app/views/user_projects/_index_edit.html.erb b/app/views/user_projects/_index_edit.html.erb
index dff419ae7..826c489a1 100644
--- a/app/views/user_projects/_index_edit.html.erb
+++ b/app/views/user_projects/_index_edit.html.erb
@@ -16,16 +16,17 @@
-
+
<%= user.full_name %>
-
<%= t('user_projects.enums.role.'<< user_project.role) %>
+
+ <%= t('user_projects.enums.role.'<< user_project.role) %>
<% unless user.id == current_user.id %>
<%= form_for user_project,
- url: project_user_project_path(@project, user_project.id),
+ url: project_user_path(@project, user_project.id),
format: :json,
method: 'put',
remote: true,
@@ -43,7 +44,7 @@
<% end %>
- <%= link_to project_user_project_path(@project, user_project, format: :json), method: :delete, remote: true, class: 'btn btn-link remove-user-link' do %>
+ <%= link_to project_user_path(@project, user_project, format: :json), method: :delete, remote: true, class: 'btn btn-link remove-user-link' do %>
<% end %>
@@ -58,10 +59,9 @@
-
- <%= bootstrap_form_for [@project, @new_user_project], remote: true, format: :json, html: { class: 'add-user-form' } do |f| %>
- <%= hidden_field_tag :project_id, @project.id %>
+ <%= bootstrap_form_for [@project, @new_user_project], url: project_users_path(@project), remote: true, format: :json, html: { class: 'add-user-form' } do |f| %>
- <%= collection_select(:user_project, :user_id, @unassigned_users, :id, :full_name, {}, { class: 'selectpicker' }) %>
+ <%= collection_select(:user_project, :user_id, @unassigned_users, :id, :full_name, {}, { class: 'selectpicker' }) %>
@@ -75,10 +75,10 @@
- <%= f.button class: 'btn btn-primary' do %>
-
- <%= t("projects.index.modal_manage_users.create") %>
- <% end %>
+ <%= f.button class: 'btn btn-primary' do %>
+
+ <%= t('projects.index.modal_manage_users.create') %>
+ <% end %>
<% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 5213eef61..d2a2f1ebe 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -424,6 +424,10 @@ en:
invite_users_link: "Invite users"
invite_users_details: "to team %{team}."
contact_admins: "To invite additional users to team %{team}, contact its administrator/s."
+ modal_view_users:
+ modal_title: "Members of %{name}"
+ no_users: "No users!"
+ current_user_label: "(you)"
filters_modal:
members:
label: "Members"
diff --git a/config/routes.rb b/config/routes.rb
index 8f9c7551e..61aed9273 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -228,8 +228,11 @@ Rails.application.routes.draw do
end
resources :projects, except: [:destroy] do
- resources :user_projects, path: '/users',
- only: [:create, :index, :update, :destroy]
+ resources :user_projects, path: '/users', only: %i(create index update destroy), as: :users do
+ collection do
+ get 'edit', to: 'user_projects#index_edit'
+ end
+ end
resources :project_comments,
path: '/comments',
only: [:create, :index, :edit, :update, :destroy]
@@ -294,10 +297,6 @@ Rails.application.routes.draw do
get 'sidebar'
end
- # This route is defined outside of member block
- # to preserve original :project_id parameter in URL.
- get 'users/edit', to: 'user_projects#index_edit'
-
collection do
get 'cards', to: 'projects#cards'
get 'users_filter'
diff --git a/features/home_page.feature b/features/home_page.feature
index 4a154b234..9a2b684bb 100644
--- a/features/home_page.feature
+++ b/features/home_page.feature
@@ -132,7 +132,7 @@ Feature: Home page
And I click element with css "html body.modal-open div#content-wrapper div#wrapper.container-fluid div#fluid-content.container-fluid div#new-project-modal.modal.in form#new_project.new_project div.modal-dialog div.modal-content div.modal-footer input.btn.btn-primary"
And I click element with css ".fa-users"
And I click element with css ".manage-users-link"
- And I click element with css "#project-actions-modal > div:nth-child(1) > div:nth-child(1) > div:nth-child(3) > span:nth-child(1) > a:nth-child(1)"
+ And I click element with css "#manageProjectUsersModal > div:nth-child(1) > div:nth-child(1) > div:nth-child(3) > span:nth-child(1) > a:nth-child(1)"
And I click element with css ".dropdown-teams-user"
And I click element with css ".open > ul:nth-child(2) > li:nth-child(7) > a:nth-child(1)"
And I click "Remove" button