Codeminer42/cm42-central

View on GitHub
app/views/users/_user_list.html.erb

Summary

Maintainability
Test Coverage
<div class="col-xs-12">
  <div class="row">
    <div class="col-xs-12 col-sm-6">
      <div class="row">
        <div class="col-md-12">
          <h4><i class="mi md-20">group</i> <%= t('projects.project_members') %></h4>
        </div>

      <% project.users.order('name').each do |user| %>
        <div class="col-md-12">
          <div class="panel panel-default card user-card">
            <div class="panel-body">
              <div class="row">
                <div class="col-xs-3 user-image-container">
                  <% cache "user/#{user.email}/avatar", expires_in: 1.hour do %>
                    <img class="user-image" src="<%= avatar_url(user) %>">
                  <% end %>
                </div>
                <div class="col-xs-9 user-description">
                  <%= user.name %> <br>
                  <span class="user-email"><%= user.email %></span>
                </div>
              </div>
            </div>

            <% if policy(User).destroy? %>
              <%= link_to t('remove'),
                project_user_path(project, user),
                data: { confirm: t('remove user confirm', email: user.email) },
                method: :delete,
                remote: true,
                class: 'card-footer' %>
            <% end %>
          </div>
        </div>
      <% end %>
      </div>
    </div>

    <div class="col-xs-12 col-sm-6">
      <% if policy(User).create? %>
        <div class="row">
          <div class="col-md-12">
            <h4><i class="mi md-20">group</i> <%= t('projects.available_users') %></h4>
          </div>

          <% current_team_users.each do |user| %>
          <div class="col-md-12">
            <div class="panel panel-default card user-card">
              <div class="panel-body">
                <div class="row">
                  <div class="col-xs-3 user-image-container">
                    <% cache "user/#{user.email}/avatar", expires_in: 1.hour do %>
                      <img class="user-image" src="<%= avatar_url(user) %>">
                    <% end %>
                  </div>
                  <div class="col-xs-9 user-description">
                    <%= user.name %> <br>
                    <span class="user-email"><%= user.email %></span>
                  </div>
                </div>
              </div>

              <%= form_tag project_memberships_path(project.id), method: :post, remote: true do %>
                <%= hidden_field_tag 'user[email]', user.email %>
                <%= button_tag t('add'), class: 'btn btn-link unstyled-link card-footer' %>
              <% end %>
            </div>
          </div>
          <% end %>
        </div>
      <% end %>
    </div>
  </div>
</div>