houston/houston-core

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

Summary

Maintainability
Test Coverage
<% content_for :title do %>
<h1 class="project-banner space-below">
  Projects

  <%= render partial: "projects/keyboard_shortcuts" %>
</h1>
<% end %>

<% if @projects.any? %>
  <div class="nomargin">
    <table id="projects" class="table table-sortable table-striped">
      <thead>
        <tr>
          <td class="table-margin"></td>
          <th class="project-title sort-desc">Title</th>
          <th class="project-team">Team</th>
        <% Houston.view["projects"].columns.each do |column| %>
          <% next unless column.permitted?(current_ability) %>
          <th><%= column.name %></th>
        <% end %>
          <th class="project-features">Features</th>
          <td class="project-following"></td>
          <td class="table-margin"></td>
        </tr>
      </thead>
      <tbody>
        <% @projects.each do |project| %>
          <tr id="project_<%= project.id %>">
            <td class="table-margin"></td>

            <td class="project-title">
              <% if project.color %>
                <b class="bubble <%= project.color %>" rel="tooltip" title="<%= project.color.name.titleize %>" data-tooltip-placement="right"></b>
              <% else %>
                <b class="bubble"></b>
              <% end %>
              <%= link_to_if can?(:update, project), project.name, edit_project_path(project) %>
            </td>

            <td class="project-team">
              <%= project.team && project.team.name %>
            </td>

          <% Houston.view["projects"].columns.each do |column| %>
            <% next unless column.permitted?(current_ability) %>
            <td><%= column.render(self, project) %></td>
          <% end %>

            <td class="project-features">
              <%= project.features.map { |feature| link_to_project_feature(project, feature) }.join(", ").html_safe %>
            </td>

            <td class="project-following">
              <% if current_user %>
                <% if current_user.follows?(project) %>
                  <%= button_to project_unfollow_path(project), method: :delete, class: "btn-link" do %>
                    <i class="fa fa-star"/></i>
                  <% end %>
                <% else %>
                  <%= button_to project_follow_path(project), method: :post, class: "btn-link" do %>
                    <i class="fa fa-star-o"/></i>
                  <% end %>
                <% end %>
              <% end %>
            </td>

            <td class="table-margin"></td>
          </tr>
        <% end %>
      </tbody>
    </table>
  </div>
<% else %>
  <div class="alert alert-info">There are no projects yet. Click <b>New Project</b> to create one.</div>
<% end %>

<% content_for :javascripts do %>
  <script type="text/javascript">
    $(function() {
      $('#projects').tablesorter();
    });
  </script>
<% end %>