Codeminer42/cm42-central

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

Summary

Maintainability
Test Coverage
<% content_for :navbar do %>
  <%= render 'projects/navbar', project: @project %>
<% end %>

<% content_for :title_bar do %>
  <ul class="nav navbar-nav">
    <li>
      <%= link_to @project.name, @project %>
    </li>
  </ul>
<% end %>

<div class="row">
  <% if policy(User).manage? %>
    <div class="col-xs-12">
      <div class="page-header">
        <h4 class="page-header-title">
          <i class="mi md-20">dashboard</i> <%= t('add new member') %>
        </h4>
      </div>
    </div>

    <div class="col-xs-12">

      <div class="add-member panel panel-default card">
        <div class="panel-body">
          <%= form_for @user,
            url: project_memberships_path(@project.id, @user) do |f| %>

            <%= content_tag :div, class: 'alert alert-danger' do %>
              <%= t('errors.template.header', count: @user.errors.count, model: @user.class.name.humanize) %>

              <ul>
                <% @user.errors.full_messages.each do |msg| %>
                  <li><%= msg %></li>
                <% end %>
              </ul>
            <% end if @user.errors.any? %>

            <div class="form-group">
              <%= f.label :email, class: 'control-label' %>
              <%= f.email_field :email, class: 'form-control auth-form-control', required: true %>
            </div>

            <div class="actions">
              <%= f.submit 'Add user', class: 'btn btn-primary pull-right' %>
            </div>
          <% end %>
        </div>
      </div>
    </div>
  <% end %>

  <div id="user_list">
    <%= render 'user_list', project: @project, current_team_users: @current_team_users %>
  </div>
</div>