JordanHatch/maslow-redux

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

Summary

Maintainability
Test Coverage
<% content_for :page_title, "##{need.need_id}: #{format_need_goal(need.goal)}" %>
<% content_for :navigation do %>
  <%= render partial: 'needs/navigation' %>
<% end %>

<article class="need">
  <section class="need-main need-response">
    <header>
      <h1>
        <em><%= need.need_responses.count %></em>
        <%= 'thing'.pluralize(need.need_responses.count) %> meeting this need
      </h1>
    </header>

    <% if !need.closed? && current_user.can?(:create, NeedResponse) %>
    <p>
      <%= link_to new_need_response_path(need), class: 'action new-action' do %>
        <span class="icon" aria-hidden="true"></span>
        Add a new thing that meets this need
      <% end %>
    </p>
    <% end %>

    <ul class="response-list">
      <% need.need_responses.each do |need_response| %>
        <li class="need-response-item box">
          <h1>
            <%= need_response.response_type_text %>
          </h1>
          <p class="response-name">
            <%= need_response.name %>
            <% if need_response.url.present? %>
              &mdash; <%= link_to need_response.url, need_response.url %>
            <% end %>
          </p>
          <% unless need.closed? %>
            <ul class="actions">
              <% if current_user.can?(:update, NeedResponse) %>
                <li>
                  <%= link_to edit_need_response_path(need, need_response), class: 'action edit-action' do %>
                    <span class="icon" aria-hidden="true"></span> Edit
                  <% end %>
                </li>
              <% end %>
              <% if current_user.can?(:destroy, NeedResponse) %>
                <li>
                  <%= link_to need_response_path(need, need_response), method: 'delete', data: { confirm: 'Are you sure? This cannot be undone.' }, class: 'action delete-action' do %>
                    <span class="icon" aria-hidden="true"></span> Delete
                  <% end %>
                </li>
              <% end %>
            </ul>
          <% end %>
        </li>
      <% end %>
    </ul>

  </section>
</article>