From 0dc7269c8878502744bf825b052ba6e1f37f6e7f Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 25 Oct 2019 15:53:27 +0000 Subject: [PATCH] Add roles filter on permissions report (#32343). git-svn-id: http://svn.redmine.org/redmine/trunk@18861 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/roles_controller.rb | 6 +++++- app/views/roles/permissions.html.erb | 21 +++++++++++++++++++++ test/functional/roles_controller_test.rb | 11 +++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb index 90b912258..985953377 100644 --- a/app/controllers/roles_controller.rb +++ b/app/controllers/roles_controller.rb @@ -103,7 +103,11 @@ class RolesController < ApplicationController end def permissions - @roles = Role.sorted.to_a + scope = Role.sorted + if params[:ids].present? + scope = scope.where(:id => params[:ids]) + end + @roles = scope.to_a @permissions = Redmine::AccessControl.permissions.select { |p| !p.public? } if request.post? @roles.each do |role| diff --git a/app/views/roles/permissions.html.erb b/app/views/roles/permissions.html.erb index a4b14493d..16e78f877 100644 --- a/app/views/roles/permissions.html.erb +++ b/app/views/roles/permissions.html.erb @@ -1,7 +1,28 @@ <%= title [l(:label_role_plural), roles_path], l(:label_permissions_report) %> +
+ +
+ <%= form_tag(permissions_roles_path, :id => 'permissions_form') do %> <%= hidden_field_tag 'permissions[0]', '', :id => nil %> +<%= hidden_field_tag 'ids[]', @roles.map(&:id) %>
diff --git a/test/functional/roles_controller_test.rb b/test/functional/roles_controller_test.rb index dccb37fc7..34be7c7b2 100644 --- a/test/functional/roles_controller_test.rb +++ b/test/functional/roles_controller_test.rb @@ -236,6 +236,17 @@ class RolesControllerTest < Redmine::ControllerTest assert_select 'input[name=?][type=checkbox][value=delete_issues]:not([checked])', 'permissions[3][]' end + def test_get_permissions_with_filter + get :permissions, :params => { + :ids => ['2', '3'] + } + assert_response :success + + assert_select 'table.permissions thead th', 3 + assert_select 'input[name=?][type=checkbox][value=add_issues][checked=checked]', 'permissions[3][]' + assert_select 'input[name=?][type=checkbox][value=delete_issues]:not([checked])', 'permissions[3][]' + end + def test_post_permissions post :permissions, :params => { :permissions => { -- 2.39.5