message("global_permissions.#{role}", :default => role)
end
+ def link_to_edit_roles_permission_form(label, role, resource_id, html_id)
+ link_to message(label), {:controller => :roles, :action => :edit_users, :role => role, :resource => resource_id},
+ :id => html_id, :class => 'open-modal link-action', 'modal-width' => '780px'
+ end
+
+ def link_to_edit_groups_permission_form(label, role, resource_id, html_id)
+ link_to message(label), {:controller => :roles, :action => :edit_groups, :role => role, :resource => resource_id},
+ :id => html_id, :class => 'open-modal link-action', 'modal-width' => '780px'
+ end
+
end
<% end %>
</select>
</td>
- <td style="padding: 0 10px;" align="center">
+ <td style="padding: 0 10px;" align="center" nowrap="nowrap">
<button id="select_right" onclick="SelectBox.move('from', 'to');SelectBox.sort('to');SelectBox.redisplay('to');return false;">select >></button><br>
<button id="select_right_all" onclick="SelectBox.move_all('from', 'to');return false;">select all >></button><br><br>
<button id="select_left" onclick="SelectBox.move('to', 'from');return false;"><< unselect</button><br>
<% end %>
</select>
</td>
- <td style="padding: 0 10px;" align="center">
+ <td style="padding: 0 10px;" align="center" nowrap="nowrap">
<button id="select_right" onclick="SelectBox.move('from', 'to');SelectBox.sort('to');SelectBox.redisplay('to');return false;">select >></button><br>
<button id="select_right_all" onclick="SelectBox.move_all('from', 'to');return false;">select all >></button><br><br>
<button id="select_left" onclick="SelectBox.move('to', 'from');return false;"><< unselect</button><br>
<td valign="top"><b><%= h permission_template.name %></b><br/>
<span class="small gray"><%= h permission_template.description -%></span>
</td>
- <td valign="top">
- <%
- users=Api::Utils.insensitive_sort(permission_template.getUsersForPermission('admin').collect {|u| u.userName})
- groups=Api::Utils.insensitive_sort(permission_template.getGroupsForPermission('admin').collect {|g| g.groupName.blank? ? 'Anyone' : g.groupName})
- %>
- <span id="u-admin-<%= u permission_template.name -%>"><%= users.join(', ') %></span>
- (<%= link_to message('select users'), {:action => :edit_users, :name => permission_template.name, :permission => 'admin'},
- :id => "selectu-admin-#{u permission_template.name}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/>
- <span id="g-admin-<%= u permission_template.name -%>"><%= groups.join(', ') %></span>
- (<%= link_to message('select groups'), {:action => :edit_groups, :name => permission_template.name, :permission => 'admin'},
- :id => "selectg-admin-#{u permission_template.name}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)
- </td>
- <td valign="top">
- <%
- users=Api::Utils.insensitive_sort(permission_template.getUsersForPermission('user').collect {|u| u.userName})
- groups=Api::Utils.insensitive_sort(permission_template.getGroupsForPermission('user').collect {|g| g.groupName.blank? ? 'Anyone' : g.groupName})
- %>
- <span id="u-user-<%= u permission_template.name -%>"><%= users.join(', ') %></span>
- (<%= link_to message('select users'), {:action => :edit_users, :name => permission_template.name, :permission => 'user'},
- :id => "selectu-user-#{u permission_template.name}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/>
- <span id="g-user-<%= u permission_template.name -%>"><%= groups.join(', ') %></span>
- (<%= link_to message('select groups'), {:action => :edit_groups, :name => permission_template.name, :permission => 'user'},
- :id => "selectg-user-#{u permission_template.name}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)
- </td>
- <td valign="top">
- <%
- users=Api::Utils.insensitive_sort(permission_template.getUsersForPermission('codeviewer').collect {|u| u.userName})
- groups=Api::Utils.insensitive_sort(permission_template.getGroupsForPermission('codeviewer').collect {|g| g.groupName.blank? ? 'Anyone' : g.groupName})
- %>
- <span id="u-codeviewer-<%= u permission_template.name -%>"><%= users.join(', ') %></span>
- (<%= link_to message('select users'), {:action => :edit_users, :name => permission_template.name, :permission => 'codeviewer'},
- :id => "selectu-codeviewer-#{u permission_template.name}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/>
- <span id="g-codeviewer-<%= u permission_template.name -%>"><%= groups.join(', ') %></span>
- (<%= link_to message('select groups'), {:action => :edit_groups, :name => permission_template.name, :permission => 'codeviewer'},
- :id => "selectg-codeviewer-#{u permission_template.name}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)
- </td>
+ <% ['admin', 'user', 'codeviewer'].each do |permission| -%>
+ <td valign="top">
+ <%
+ users=Api::Utils.insensitive_sort(permission_template.getUsersForPermission(permission).collect {|u| u.userName})
+ groups=Api::Utils.insensitive_sort(permission_template.getGroupsForPermission(permission).collect {|g| g.groupName.blank? ? 'Anyone' : g.groupName})
+ %>
+ <span id="u-<%= permission -%>-<%= u permission_template.name -%>"><%= users.join(', ') %></span>
+ (<%= link_to message('select users'), {:action => :edit_users, :name => permission_template.name, :permission => permission},
+ :id => "selectu-#{permission}-#{u permission_template.name}", :class => 'open-modal link-action', 'modal-width' => '780px' %>)<br/>
+ <span id="g-<%= permission -%>-<%= u permission_template.name -%>"><%= groups.join(', ') %></span>
+ (<%= link_to message('select groups'), {:action => :edit_groups, :name => permission_template.name, :permission => permission},
+ :id => "selectg-#{permission}-#{u permission_template.name}", :class => 'open-modal link-action', 'modal-width' => '780px' %>)<br/>
+ </td>
+ <% end %>
<td>
<% qualifiers = []
@default_templates.each_pair do |q, t|
<td valign="top"><b>Administrators</b><br/><span class="small gray">Ability to perform administration functions for a project by accessing its settings.</span></td>
<td valign="top" style="word-break:break-all;width:35%;">
<span id="admin-role-users"><%= users('admin', @project.id).map(&:name).join(', ') %></span>
- (<%= link_to message('select'), {:controller => :roles, :action => :edit_users, :role => 'admin', :resource => @project.id},
- :id => 'select-admin-edit-users', :class => 'open-modal link-action', 'modal-width' => '760px' %>)
+ (<%= link_to_edit_roles_permission_form(message('select'), 'admin', @project.id, 'select-admin-edit-users') %>)<br/>
</td>
<td valign="top" style="word-break:break-all;width:35%;">
<span id="admin-role-groups"><%= groups('admin', @project.id).map{|g| group_name(g)}.join(', ') %></span>
- (<%= link_to message('select'), {:controller => :roles, :action => :edit_groups, :role => 'admin', :resource => @project.id},
- :id => 'select-admin-edit-groups', :class => 'open-modal link-action', 'modal-width' => '760px' %>)
+ (<%= link_to_edit_groups_permission_form(message('select'), 'admin', @project.id, 'select-admin-edit-groups') %>)<br/>
</td>
</tr>
<tr class="odd">
<td valign="top"><b>Users</b><br/><span class="small gray">Ability to navigate through every service of a project, except viewing source code and settings.</span></td>
<td valign="top" style="word-break:break-all;width:35%;">
<span id="user-role-users"><%= users('user', @project.id).map(&:name).join(', ') %></span>
- (<%= link_to message('select'), {:controller => :roles, :action => :edit_users, :role => 'user', :resource => @project.id},
- :id => 'select-user-edit-users', :class => 'open-modal link-action', 'modal-width' => '760px' %>)
+ (<%= link_to_edit_roles_permission_form(message('select'), 'user', @project.id, 'select-user-edit-users') %>)<br/>
</td>
<td valign="top" style="word-break:break-all;width:35%;">
<span id="user-role-groups"><%= groups('user', @project.id).map{|g| group_name(g)}.join(', ') %></span>
- (<%= link_to message('select'), {:controller => :roles, :action => :edit_groups, :role => 'user', :resource => @project.id},
- :id => 'select-user-edit-groups', :class => 'open-modal link-action', 'modal-width' => '760px' %>)
+ (<%= link_to_edit_groups_permission_form(message('select'), 'user', @project.id, 'select-user-edit-groups') %>)<br/>
</td>
</tr>
<tr class="even" >
<td valign="top"><b>Code viewers</b><br/><span class="small gray">Ability to view source code of a project.</span></td>
<td valign="top" style="word-break:break-all;width:35%;">
<span id="codeviewer-role-users"><%= users('codeviewer', @project.id).map(&:name).join(', ') %></span>
- (<%= link_to message('select'), {:controller => :roles, :action => :edit_users, :role => 'codeviewer', :resource => @project.id},
- :id => 'select-codeviewer-edit-users', :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/>
+ (<%= link_to_edit_roles_permission_form(message('select'), 'codeviewer', @project.id, 'select-codeviewer-edit-users') %>)<br/>
</td>
<td valign="top" style="word-break:break-all;width:35%;">
<span id="codeviewer-role-groups"><%= groups('codeviewer', @project.id).map{|g| group_name(g)}.join(', ') %></span>
- (<%= link_to message('select'), {:controller => :roles, :action => :edit_groups, :role => 'codeviewer', :resource => @project.id},
- :id => 'select-codeviewer-edit-groups', :class => 'open-modal link-action', 'modal-width' => '760px' %>)
-
+ (<%= link_to_edit_groups_permission_form(message('select'), 'codeviewer', @project.id, 'select-codeviewer-edit-groups') %>)<br/>
+ </td>
</tr>
</tbody>
</table>
\ No newline at end of file
<% end %>
</select>
</td>
- <td style="padding: 0 10px;" align="center">
+ <td style="padding: 0 10px;" align="center" nowrap="nowrap">
<button id="select_right" onclick="SelectBox.move('from', 'to');SelectBox.sort('to');SelectBox.redisplay('to');return false;">select >></button><br>
<button id="select_right_all" onclick="SelectBox.move_all('from', 'to');return false;">select all >></button><br><br>
<button id="select_left" onclick="SelectBox.move('to', 'from');return false;"><< unselect</button><br>
<% end %>
</select>
</td>
- <td style="padding: 0 10px;" align="center">
+ <td style="padding: 0 10px;" align="center" nowrap="nowrap">
<button id="select_right" onclick="SelectBox.move('from', 'to');SelectBox.sort('to');SelectBox.redisplay('to');return false;">select >></button><br>
<button id="select_right_all" onclick="SelectBox.move_all('from', 'to');return false;">select all >></button><br><br>
<button id="select_left" onclick="SelectBox.move('to', 'from');return false;"><< unselect</button><br>
<span class="small gray"><%= message('global_permissions.' + global_permission_key + '.desc') -%></span></td>
<td valign="top" style="word-break:break-all;width:30%;">
<span><%= users(global_permission_key).map(&:name).join(', ') -%></span>
- (<%= link_to message('select'), {:action => :edit_users, :role => global_permission_key},
- :id => "select-users-#{global_permission_key}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/>
+ (<%= link_to_edit_roles_permission_form(message('select'), global_permission_key, nil, "select-users-#{global_permission_key}") %>)<br/>
</td>
<td valign="top" style="word-break:break-all;width:30%;">
<span><%= groups(global_permission_key).map{|g| group_name(g)}.join(', ') %></span>
- (<%= link_to message('select'), {:action => :edit_groups, :role => global_permission_key},
- :id => "select-groups-#{global_permission_key}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/>
+ (<%= link_to_edit_groups_permission_form(message('select'), global_permission_key, nil, "select-groups-#{global_permission_key}") %>)<br/>
</td>
</tr>
<% end %>
<td valign="top"><b><%= h project.name %></b><br/>
<span class="small gray"><%= h project.key -%></span>
</td>
- <td valign="top">
- <%
- users=Api::Utils.insensitive_sort(project.user_roles.select { |ur| ur.role=='admin' }.map { |ur| ur.user.name })
- groups=Api::Utils.insensitive_sort(project.group_roles.select { |gr| gr.role=='admin' }.map { |gr| group_name(gr.group) })
- %>
- <span id="u-admin-<%= u project.kee -%>"><%= users.join(', ') %></span>
- (<%= link_to message('select users'), {:action => :edit_users, :role => 'admin', :resource => project.id},
- :id => "selectu-admin-#{u project.kee}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/>
- <span id="g-admin-<%= u project.kee -%>"><%= groups.join(', ') %></span>
- (<%= link_to message('select groups'), {:action => :edit_groups, :role => 'admin', :resource => project.id},
- :id => "selectg-admin-#{u project.kee}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/>
- </td>
- <td valign="top">
- <%
- users=Api::Utils.insensitive_sort(project.user_roles.select { |ur| ur.role=='user' }.map { |ur| ur.user.name })
- groups=Api::Utils.insensitive_sort(project.group_roles.select { |gr| gr.role=='user' }.map { |gr| group_name(gr.group) })
- %>
- <span id="u-user-<%= u project.kee -%>"><%= users.join(', ') %></span>
- (<%= link_to message('select users'), {:action => :edit_users, :role => 'user', :resource => project.id},
- :id => "selectu-user-#{u project.kee}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/>
- <span id="g-user-<%= u project.kee -%>"><%= groups.join(', ') %></span>
- (<%= link_to message('select groups'), {:action => :edit_groups, :role => 'user', :resource => project.id},
- :id => "selectg-user-#{u project.kee}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/>
- </td>
- <td valign="top">
- <%
- users=Api::Utils.insensitive_sort(project.user_roles.select { |ur| ur.role=='codeviewer' }.map { |ur| ur.user.name })
- groups=Api::Utils.insensitive_sort(project.group_roles.select { |gr| gr.role=='codeviewer' }.map { |gr| group_name(gr.group) })
- %>
- <span id="u-codeviewer-<%= u project.kee -%>"><%= users.join(', ') %></span>
- (<%= link_to message('select users'), {:action => :edit_users, :role => 'codeviewer', :resource => project.id},
- :id => "selectu-codeviewer-#{u project.kee}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/>
- <span id="g-codeviewer-<%= u project.kee -%>"><%= groups.join(', ') %></span>
- (<%= link_to message('select groups'), {:action => :edit_groups, :role => 'codeviewer', :resource => project.id},
- :id => "selectg-codeviewer-#{u project.kee}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/>
- </td>
+ <% ['admin', 'user', 'codeviewer'].each do |permission| -%>
+ <td valign="top">
+ <%
+ users=Api::Utils.insensitive_sort(project.user_roles.select { |ur| ur.role==permission }.map { |ur| ur.user.name })
+ groups=Api::Utils.insensitive_sort(project.group_roles.select { |gr| gr.role==permission }.map { |gr| group_name(gr.group) })
+ %>
+ <span id="u-<%= permission -%>-<%= u project.kee -%>"><%= users.join(', ') %></span>
+ (<%= link_to_edit_roles_permission_form(message('select users'), permission, project.id, "selectu-#{permission}-#{u project.kee}") %>)<br/>
+ <span id="g-<%= permission -%>-<%= u project.kee -%>"><%= groups.join(', ') %></span>
+ (<%= link_to_edit_groups_permission_form(message('select groups'), permission, project.id, "selectg-#{permission}-#{u project.kee}") %>)<br/>
+ </td>
+ <% end %>
<td align="right">
<%= link_to message('projects_role.apply_template'), {:action => :apply_template_form, :projects => [project.id], :project_name => project.name, :qualifier => @qualifier},
:id => "apply-template-modal-#{project.id}", :class => 'open-modal link-action' %>