app/views/organizations/_authorizations.html.erb
<div class="tabs">
<ul>
<li><a href="#tabs-group"><%= I18n.t(:groups) %></a></li>
<li><a href="#tabs-project-security-levels"><%= I18n.t(:security_level) %></a></li>
<li><a href="#tabs-organization-permissions"><%= I18n.t(:organization_permissions) %></a></li>
<li><a href="#tabs-global-permissions"><%= I18n.t(:global_permissions) %></a></li>
<li><a href="#tabs-modules-permissions"><%= I18n.t(:modules_permissions) %></a></li>
<li><a href="#tabs-estimations-permissions"><%= I18n.t(:estimations_permissions) %></a></li>
</ul>
<div id="tabs-group">
<b>
<%= I18n.t(:groups) %>
</b>
<% if can? :show_groups, Group %>
<% if can? :manage, Group %>
<%= link_to I18n.t('new_group'), new_organization_group_path(@organization), :class => 'btn pull-right' %>
<% end %>
<%= render :partial => 'organizations/groups', object: @groups %>
<% else %>
<div class="red_color"><%= I18n.t(:notice_cannot_view_groups) %></div>
<% end %>
</div>
<div id="tabs-project-security-levels" style="min-height: 50px;">
<b><%= I18n.t(:security_level) %></b>
<% if can? :show_project_security_levels, ProjectSecurityLevel %>
<% if can? :manage, ProjectSecurityLevel %>
<%= link_to I18n.t('new_project_security_level'), new_organization_project_security_level_path(@organization), :class => 'btn pull-right' %>
<% end %>
<table id="table_list_1" class="table tablesorterPager table-striped table-bordered table-condensed">
<thead>
<tr>
<th style="text-align:left;"><%= I18n.t(:name) %></th>
<th style="text-align:left;"><%= I18n.t(:description) %></th>
<th class="action"><%= I18n.t(:actions) %></th>
</tr>
</thead>
<% @project_security_levels.each do |project_security_level| %>
<tr>
<td><%= project_security_level.name %></td>
<td><%= project_security_level.description %></td>
<td class="center">
<%= link_to '', edit_organization_project_security_level_path(@organization, project_security_level), :class => 'icon-pencil', :title => I18n.t('edit') %>
<% if can? :manage, ProjectSecurityLevel %>
<%= link_to '', organization_project_security_level_path(@organization, project_security_level), confirm: I18n.t('are_you_sure'), method: :delete, :class => 'icon-trash', :style => 'color:red', :title => I18n.t('delete') %>
<% end %>
</td>
</tr>
<% end %>
<%= render :partial => 'layouts/footer_table' %>
</table>
<% else %>
<div class="red_color"><%= I18n.t(:notice_cannot_view_project_securities_levels) %></div>
<% end %>
</div>
<%= form_tag(set_rights_path, :method => 'post', :class => 'simple_form') do %>
<div id="tabs-organization-permissions">
<b><%= I18n.t(:organization_permissions) %></b>
<% if can? :show_organization_permissions, Permission %>
<table class="table table-bordered table-condensed table-striped">
<tr>
<th style="text-align:left;"><%= I18n.t(:groups_and_roles) %></th>
<% @groups.each_with_index do |group, i| %>
<th>
<%= link_to group.name, "#", title: group.description %>
<%= link_to '', '#', :id => "cols_select_all_global_#{group.id}", 'data-group_global_id' => group.id, 'data-rows_or_cols_global' => 'cols', :remote => true, :class => 'fa fa-check-square-o', :title => I18n.t('select_unselect_all'), :onclick => "select_or_unselect_all_permissions(this, 'group_global_id', 'permission_global_id', 'global');" %>
</th>
<% end %>
</tr>
<% @permissions_classes_organization.each do |cla| %>
<tr>
<td style="text-align:left; vertical-align:middle; font-style:italic;">
<%= cla.blank? ? '' : cla %>
</td>
<% @groups.each do |group| %>
<td style="text-align:center; font-style:italic; vertical-align:bottom; font-size: 85%; border-left: 0;">
<%= group.name %>
</td>
<% end %>
</tr>
<% @organization_permissions.each do |perm| %>
<tr>
<% if perm.category.to_s == cla %>
<td>
<%= link_to '', '#', :id => "lines_select_all_global_#{perm.id}", 'data-permission_global_id' => perm.id, 'data-rows_or_cols_global' => 'rows', :remote => true, :class => 'fa-check-square-o fa', :title => I18n.t('select_unselect_all'), :onclick => "select_or_unselect_all_permissions(this, 'group_global_id', 'permission_global_id', 'global');" %>
<%= link_to perm.name, edit_permission_path(perm), title: perm.description %>
</td>
<% @groups.each do |group| %>
<%= hidden_field_tag "permissions[#{group.id}][]" %>
<td style="text-align: center;">
<%= check_box_tag("permissions[#{group.id}][]", perm.id, (group.permissions.map(&:id).include? perm.id), :id => nil, :class => "group_global_id_#{group.id} permission_global_id_#{perm.id}") %>
</td>
<% end %>
<% end %>
</tr>
<% end %>
<% end %>
</table>
<% if can? :manage_organization_permissions, Permission %>
<%= submit_tag I18n.t('apply'), name: "organization_permissions", :class => 'btn' %>
<%= submit_tag I18n.t('cancel'), name: "organization_permissions", :class => 'btn'%>
<% end %>
<% else %>
<div class="red_color"><%= I18n.t(:notice_cannot_view_organization_super_admin_permissions) %></div>
<% end %>
</div>
<div id="tabs-global-permissions">
<b><%= I18n.t(:global_permissions) %></b>
<% if can? :show_global_permissions, Permission %>
<table class="table table-bordered table-condensed table-striped">
<tr>
<th style="text-align:left;"><%= I18n.t(:groups_and_roles) %></th>
<% @groups.each_with_index do |group, i| %>
<th>
<%= link_to group.name, "#", title: group.description %>
<%= link_to '', '#', :id => "cols_select_all_global_#{group.id}", 'data-group_global_id' => group.id, 'data-rows_or_cols_global' => 'cols', :remote => true, :class => 'fa fa-check-square-o', :title => I18n.t('select_unselect_all'), :onclick => "select_or_unselect_all_permissions(this, 'group_global_id', 'permission_global_id', 'global');" %>
</th>
<% end %>
</tr>
<% @permissions_classes_globals.each do |cla| %>
<tr>
<td style="text-align:left; vertical-align:middle; font-style:italic;">
<%= cla.blank? ? '' : cla %>
</td>
<% @groups.each do |group| %>
<td style="text-align:center; font-style:italic; vertical-align:bottom; font-size: 85%; border-left: 0;">
<%= group.name %>
</td>
<% end %>
</tr>
<% @global_permissions.each do |perm| %>
<tr>
<% if perm.category.to_s == cla %>
<td>
<%= link_to '', '#', :id => "lines_select_all_global_#{perm.id}", 'data-permission_global_id' => perm.id, 'data-rows_or_cols_global' => 'rows', :remote => true, :class => 'fa-check-square-o fa', :title => I18n.t('select_unselect_all'), :onclick => "select_or_unselect_all_permissions(this, 'group_global_id', 'permission_global_id', 'global');" %>
<%= link_to perm.name, edit_permission_path(perm), title: perm.description %>
</td>
<% @groups.each do |group| %>
<%= hidden_field_tag "permissions[#{group.id}][]" %>
<td style="text-align: center;">
<%= check_box_tag("permissions[#{group.id}][]", perm.id, (group.permissions.map(&:id).include? perm.id), :id => nil, :class => "group_global_id_#{group.id} permission_global_id_#{perm.id}") %>
</td>
<% end %>
<% end %>
</tr>
<% end %>
<% end %>
</table>
<% if can? :manage_global_permissions, Permission %>
<%= submit_tag I18n.t('apply'), name: "global_permissions", :class => 'btn' %>
<%= submit_tag I18n.t('cancel'), name: "gloabal_permissions", :class => 'btn'%>
<% end %>
<% else %>
<div class="red_color"><%= I18n.t(:notice_cannot_view_global_permissions) %></div>
<% end %>
</div>
<div id="tabs-modules-permissions">
<b><%= I18n.t(:modules_permissions) %></b>
<% if can? :show_modules_permissions, Permission %>
<table class="table table-bordered table-condensed table-striped">
<tr>
<th style="text-align:left;"><%= I18n.t(:groups_and_roles) %></th>
<% @groups.each do |group| %>
<th style="text-align:center;">
<%= link_to group.name, "#", title: group.description %>
<%= link_to '', '#', :id => "cols_select_all_master_#{group.id}", 'data-group_master_id' => group.id, 'data-rows_or_cols_master' => 'cols', :remote => true, :class => 'fa fa-check-square-o', :title => I18n.t('select_unselect_all'), :onclick => "select_or_unselect_all_permissions(this, 'group_master_id', 'permission_master_id', 'master');" %>
</th>
<% end %>
</tr>
<% @permissions_classes_modules.each do |cla| %>
<tr>
<th style="text-align:left; vertical-align:middle;">
<%= cla.blank? ? '' : cla %>
</th>
<% @groups.each do |group| %>
<th style="text-align:center; font-style:italic; vertical-align:bottom; font-size: 85%; color: #999; border-left: 0;">
<%= group.name %>
</th>
<% end %>
</tr>
<% @modules_permissions.each do |perm| %>
<tr>
<% if perm.category.to_s == cla %>
<td>
<%= link_to '', '#', :id => "lines_select_all_global_#{perm.id}", 'data-permission_global_id' => perm.id, 'data-rows_or_cols_global' => 'rows', :remote => true, :class => 'fa-check-square-o fa', :title => I18n.t('select_unselect_all'), :onclick => "select_or_unselect_all_permissions(this, 'group_global_id', 'permission_global_id', 'global');" %>
<%= link_to perm.name, edit_permission_path(perm), title: perm.description %>
</td>
<% @groups.each do |group| %>
<td style="text-align: center;">
<%= check_box_tag("permissions[#{group.id}][]", perm.id, (group.permissions.map(&:id).include? perm.id), :id => nil, :class => "group_master_id_#{group.id} permission_master_id_#{perm.id}") %>
</td>
<% end %>
<% end %>
</tr>
<% end %>
<% end %>
</table>
<% if can? :manage_modules_permissions, Permission %>
<%= submit_tag I18n.t('apply'), name: "modules_permissions", :class => 'btn' %>
<% end %>
<%= submit_tag I18n.t('cancel'), name: "modules_permissions", :class => 'btn' %>
<% else %>
<div class="red_color">
<%= I18n.t(:notice_cannot_view_modules_permissions) %>
</div>
<% end %>
</div>
<% end %>
<div id="tabs-estimations-permissions">
<b><%= I18n.t(:estimations_permissions) %></b>
<% if can? :show_estimations_permissions, Permission %>
<%= form_tag({:action => 'set_rights_project_security', :controller => 'permissions'}, :method => 'post', :class => 'simple_form') do %>
<%= hidden_field_tag :organization_id, @organization.id %>
<table class="table table-bordered table-condensed table-striped">
<tr>
<th style="text-align:left;"><%= I18n.t(:groups_and_roles) %></th>
<% @project_security_levels.each do |ps| %>
<th style="text-align:center;">
<%= link_to ps.name, "#", title: ps.description %>
<%= link_to '', '#', :id => "cols_select_all_project_security_#{ps.id}", 'data-project_security_id' => ps.id, 'data-rows_or_cols_project_security' => 'cols', :remote => true, :class => 'fa fa-check-square-o', :title => I18n.t('select_unselect_all'), :onclick => "select_or_unselect_all_permissions(this, 'project_security_id', 'permission_project_id', 'project_security');" %>
</th>
<% end %>
</tr>
<tbody>
<% @permissions_classes_projects.each do |cla| %>
<tr>
<th style="text-align:left; vertical-align:middle;">
<%= cla.blank? ? '' : cla %>
</th>
<% @project_security_levels.each do |ps| %>
<th style="text-align:center; font-style:italic; vertical-align:bottom; font-size: 85%; color: #999; border-left: 0;">
<%= ps.name %>
</th>
<% end %>
</tr>
<% @permission_projects.each do |perm| %>
<tr>
<% if perm.category.to_s == cla %>
<td>
<%= link_to '', '#', :id => "lines_select_all_global_#{perm.id}", 'data-permission_global_id' => perm.id, 'data-rows_or_cols_global' => 'rows', :remote => true, :class => 'fa-check-square-o fa', :title => I18n.t('select_unselect_all'), :onclick => "select_or_unselect_all_permissions(this, 'group_global_id', 'permission_global_id', 'global');" %>
<%= link_to perm.name, edit_permission_path(perm), title: perm.description %>
</td>
<% @project_security_levels.each do |ps| %>
<td style="text-align: center;">
<%= check_box_tag("permissions[#{ps.id}][]", perm.id, (ps.permissions.map(&:id).include? perm.id), :id => nil, :class => "project_security_id_#{ps.id} permission_project_id_#{perm.id}") %>
</td>
<% end %>
<% end %>
</tr>
<% end %>
<% end %>
</tbody>
</table>
<% if can? :manage_estimations_permissions, Permission %>
<%= submit_tag I18n.t('apply'), :class => 'btn', :tab_name => 'tabs-estimation-permissions' %>
<%= submit_tag I18n.t('cancel'), :class => 'btn', :tab_name => 'tabs-estimation-permissions' %>
<% end %>
<% end %>
<% else %>
<div class="red_color"><%= I18n.t(:notice_cannot_view_estimations_permissions) %></div>
<% end %>
</div>
</div>