permissions.html.erb 2.25 KB
Newer Older
jplang's avatar
jplang committed
1
<%= title [l(:label_role_plural), roles_path], l(:label_permissions_report) %>
2

jplang's avatar
jplang committed
3
<%= form_tag(permissions_roles_path, :id => 'permissions_form') do %>
4
<%= hidden_field_tag 'permissions[0]', '', :id => nil %>
5
<div class="autoscroll">
6
<table class="list permissions">
jplang's avatar
jplang committed
7
<thead>
8
    <tr>
jplang's avatar
jplang committed
9
    <th><%=l(:label_permissions)%></th>
10
    <% @roles.each do |role| %>
11
    <th>
12 13 14 15
        <%= link_to_function('',
                             "toggleCheckboxesBySelector('input.role-#{role.id}')",
                             :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
                             :class => 'icon-only icon-checked') %>
jplang's avatar
jplang committed
16
        <%= content_tag(role.builtin? ? 'em' : 'span', role.name) %>
17
    </th>
18 19
    <% end %>
    </tr>
jplang's avatar
jplang committed
20 21
</thead>
<tbody>
jplang's avatar
jplang committed
22 23 24
<% perms_by_module = @permissions.group_by {|p| p.project_module.to_s} %>
<% perms_by_module.keys.sort.each do |mod| %>
    <% unless mod.blank? %>
25
        <tr class="group open">
26
          <td>
27 28 29
            <span class="expander" onclick="toggleRowGroup(this);">&nbsp;</span>
            <%= l_or_humanize(mod, :prefix => 'project_module_') %>
          </td>
30
          <% @roles.each do |role| %>
jplang's avatar
jplang committed
31
          <td class="role"><%= role.name %></td>
32
          <% end %>
33
        </tr>
34
    <% end %>
jplang's avatar
jplang committed
35
    <% perms_by_module[mod].each do |permission| %>
36
        <tr class="<%= cycle('odd', 'even') %> permission-<%= permission.name %>">
37
        <td class="name">
38 39 40 41
            <%= link_to_function('',
                                 "toggleCheckboxesBySelector('.permission-#{permission.name} input')",
                                 :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
                                 :class => 'icon-only icon-checked') %>
42
            <%= l_or_humanize(permission.name, :prefix => 'permission_') %>
43
        </td>
jplang's avatar
jplang committed
44
        <% @roles.each do |role| %>
45
        <td>
jplang's avatar
jplang committed
46
        <% if role.setable_permissions.include? permission %>
47
          <%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name), :id => nil, :class => "role-#{role.id}" %>
jplang's avatar
jplang committed
48 49 50 51
        <% end %>
        </td>
        <% end %>
        </tr>
jplang's avatar
jplang committed
52 53
    <% end %>
<% end %>
54 55
</tbody>
</table>
56
</div>
57 58
<p><%= check_all_links 'permissions_form' %></p>
<p><%= submit_tag l(:button_save) %></p>
59
<% end %>