vinsol/spree_favorite_products

View on GitHub
app/views/spree/admin/favorite_products/index.html.erb

Summary

Maintainability
Test Coverage
<% content_for :page_title do %>
  <%= Spree.t(:listing_favorite_products) %>
<% end %>

<%= paginate @favorite_products %>

<% if @favorite_products.any? %>
  <table class="table table-striped" id="listing_products">
    <thead>
      <tr data-hook="admin_products_index_headers">
        <th><%= Spree.t(:sku) %></th>
        <th><%= Spree.t(:image) %></th>
        <th><%= sort_link @search, :name, Spree.t(:name) %></th>
        <th class="text-right"><%= sort_link @search, 'favorite_users_count', Spree.t(:favorite_users) %></th>
      </tr>
    </thead>
    <tbody>
      <% @favorite_products.each do |product| %>
          <tr data-hook="admin_products_index_rows">
            <td ><%= product.sku rescue '' %></td>
            <td ><%= mini_image(product) %></td>
            <td><%= link_to product.try(:name), edit_admin_product_path(product) %></td>
            <td class="text-right">
              <%= link_to product.favorite_users.count, users_admin_favorite_product_path(id: product.id, type: 'product') %>
            </td>
          </tr>
      <% end %>
    </tbody>
  </table>
<% else %>
  <div class="no-objects-found">
    <%= Spree.t(:no_results) %>
  </div>
<% end %>

<%= paginate @favorite_products %>