Noosfero/noosfero

View on GitHub
app/views/profile_members/_members_list.html.erb

Summary

Maintainability
Test Coverage
<% members = @data ? @data[:members] : profile.members_by('name') %>
<% collection = @collection == :profile_admins ? profile.admins : members %>
<% title = @title ? @title : _('Current members') %>
<% remove_action = @remove_action ? @remove_action : {:action => 'unassociate'} %>
<%= javascript_include_tag params[:controller] %>

<h3><%= title %></h3>

<table>
  <tr>
    <th><%= check_box_tag 'checkbox-all', 1, false, :onClick => "toggle(this)"  %></th>
    <th><%= _('Member') %></th>
    <th><%= _('Actions') %></th>
  </tr>

  <% collection.each do |m| %>
    <tr title="<%= m.name %>">
      <td><%= labelled_check_box('', 'members_filtered[]', m.id.to_s, false, :id => 'checkbox-'+m.identifier) %></td>
      <td><%= link_to_profile m.short_name, m.identifier, :title => m.name %> </td>
      <td>
        <%= button_without_text :edit, _('Edit'), :action => 'change_role', :id => m %>
        <%= button_to_remote_without_text(:trash, _('Remove'),
              :update => 'members-list',
              :loading => "jQuery('#members-list').addClass('loading')",
              :success => "jQuery('#tr-#{m.identifier}').show()",
              :complete => "jQuery('#members-list').removeClass('loading')",
              :url => { :id => m }.merge(remove_action)) if m != user %>
      </td>
    </tr>
  <% end %>
</table>
<% if collection.empty? %>
  <p>
    <em><%= _('No members found to: %s') % profile.name %></em>
  </p>
<% end %>