<% memberships = principal.memberships.preload(:member_roles, :roles).sorted_by_project.to_a %>

<%= link_to sprite_icon('add', l(:label_add_projects)), new_principal_membership_path(principal), :remote => true, :class => "icon icon-add" %>

<% if memberships.any? %> <%= call_table_header_hook principal %> <% memberships.each do |membership| %> <% next if membership.new_record? %> <%= call_table_row_hook principal, membership %> <% end %>
<%= l(:label_project) %> <%= l(:label_role_plural) %>
<%= link_to_project membership.project %> <%=h membership.roles.sort.collect(&:to_s).join(', ') %>
<%= link_to sprite_icon('edit', l(:button_edit)), edit_principal_membership_path(principal, membership), :remote => true, :class => 'icon icon-edit' %> <%= delete_link principal_membership_path(principal, membership), :remote => true if membership.deletable? %>
<% else %>

<%= l(:label_no_data) %>

<% end %>