]> source.dussan.org Git - redmine.git/commitdiff
Add roles filter on permissions report (#32343).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 25 Oct 2019 15:53:27 +0000 (15:53 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 25 Oct 2019 15:53:27 +0000 (15:53 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@18861 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/roles_controller.rb
app/views/roles/permissions.html.erb
test/functional/roles_controller_test.rb

index 90b912258c9df55c9e785c5cdda9b047ae7ffcd7..9859533778812716c1a3491243b79c207f745948 100644 (file)
@@ -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|
index a4b14493d14a69bbe495bc56825bbc1374148b3e..16e78f8778866865835bfbbedd9b07a73fb50988 100644 (file)
@@ -1,7 +1,28 @@
 <%= title [l(:label_role_plural), roles_path], l(:label_permissions_report) %>
 
+<div class="hide-when-print">
+  <fieldset id="filters" class="collapsible collapsed">
+    <legend onclick="toggleFieldset(this);" class="icon icon-collapsed"><%= l(:label_filter_plural) %></legend>
+    <div style="display: none;">
+      <%= form_tag({}, :method => :get) do %>
+        <% Role.sorted.to_a.each do |role| %>
+          <label>
+            <%= check_box_tag "ids[]", role.id, @roles.include?(role) %>
+            <%= role.name %>
+          </label>
+        <% end %>
+        <p>
+          <%= submit_tag l(:button_apply), :name => nil %>
+          <%= link_to l(:button_clear), permissions_roles_path, :class => 'icon icon-reload' %>
+        </p>
+      <% end %>
+    </div>
+  </fieldset>
+</div>
+
 <%= form_tag(permissions_roles_path, :id => 'permissions_form') do %>
 <%= hidden_field_tag 'permissions[0]', '', :id => nil %>
+<%= hidden_field_tag 'ids[]', @roles.map(&:id) %>
 <div class="autoscroll">
 <table class="list permissions">
 <thead>
index dccb37fc7cdb1fd69071f94cef0ba5a3f3512d0d..34be7c7b26b1a40ec27e6d53d52f1a053fd5c18d 100644 (file)
@@ -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 => {