Commit 4096a035b2acea97c9c61f8ba3e494f71cd9d736

Authored by Victor Costa
1 parent e01af1ea

Display badges separated by the owner

controllers/admin/gamification_plugin_badges_controller.rb
1 1 class GamificationPluginBadgesController < PluginAdminController
2 2  
3 3 def index
4   - @gamification_plugin_badges = environment.gamification_plugin_badges
  4 + @gamification_plugin_badges = environment.gamification_plugin_badges.group_by(&:owner)
5 5 end
6 6  
7 7 def show
... ...
views/gamification_plugin_badges/index.html.erb
... ... @@ -10,7 +10,11 @@
10 10 <th></th>
11 11 </tr>
12 12  
13   -<% @gamification_plugin_badges.each do |gamification_plugin_badge| %>
  13 +<% @gamification_plugin_badges.each do |owner, badges| %>
  14 + <% if owner.present? %>
  15 + <tr><th colspan="6"><%= _("Badges for:") %> <%= owner.name %></th></tr>
  16 + <% end %>
  17 + <% badges.each do |gamification_plugin_badge| %>
14 18 <tr>
15 19 <td><%= gamification_plugin_badge.name %></td>
16 20 <td><%= gamification_plugin_badge.title %></td>
... ... @@ -19,6 +23,7 @@
19 23 <td><%= link_to 'Edit', :action => :edit, :id => gamification_plugin_badge.id %></td>
20 24 <td><%= button_without_text :delete, _('Remove'), {:action => :destroy, :id => gamification_plugin_badge.id}, :method => :post, :confirm => _('Are you sure?') %></td>
21 25 </tr>
  26 + <% end %>
22 27 <% end %>
23 28 </table>
24 29  
... ...