Skip to content

Commit ccc3499

Browse files
author
Bryan Chu
committed
Implemented "Show all users" toggleability for my_users page - Admins only
1 parent 5ed259b commit ccc3499

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

app/controllers/redmine_my_users_controller.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ def index
2222

2323
@status = params[:status] || 1
2424

25-
scope = User.where("parent_id = ?", User.current.id).status(@status)
25+
@admin_toggle = params[:admin_toggle_all] || false
26+
27+
if User.current.admin? && @admin_toggle == "on"
28+
scope = User.all.status(@status)
29+
else
30+
scope = User.where("parent_id = ?", User.current.id).status(@status)
31+
end
32+
2633
scope = scope.like(params[:name]) if params[:name].present?
2734
scope = scope.in_group(params[:group_id]) if params[:group_id].present?
2835

@@ -45,4 +52,3 @@ def index
4552
end
4653

4754
end
48-

app/views/redmine_my_users/index.html.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
<%= text_field_tag 'name', params[:name], :size => 30 %>
2323

2424
<%= submit_tag l(:button_apply), :class => "small", :name => nil %>
25+
<%if User.current.admin?%>
26+
<label for='name'><%= l(:label_admin_toggle_box) %>:</label>
27+
<%= check_box_tag 'admin_toggle_all', params[:admin_toggle_all], @admin_toggle, onclick: "this.form.submit();" %>
28+
<%end%>
2529
<%= link_to l(:button_clear), my_users_path, :class => 'icon icon-reload' %>
2630
</fieldset>
2731
<% end %>

config/locales/en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
en:
33
field_user_parent: "Sponsor"
44
label_my_users: "My users"
5+
label_admin_toggle_box: "Show all users"

init.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212

1313
version '0.1.4'
1414
requires_redmine :version_or_higher => '2.0.0'
15+
settings :default => {
16+
:admin_toggle_all => false,
17+
:save_log => false
18+
}
1519
end
1620

1721

@@ -41,4 +45,3 @@ def load_patches(path = nil)
4145
end
4246
end
4347
load_patches
44-

0 commit comments

Comments
 (0)