spree-contrib/spree_drop_ship

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

Summary

Maintainability
Test Coverage
<%# Updated icon %>
<% content_for :page_actions do %>
  <%= button_link_to Spree.t('new_supplier'), new_object_url, icon: 'add', class: 'btn-success' %>
<% end %>

<% content_for :page_title do %>
  <%= Spree.t(:listing_suppliers) %>
<% end %>

<% content_for :table_filter_title do %>
  <%= Spree.t(:search) %>
<% end %>

<% content_for :table_filter do %>
  <div data-hook='admin_suppliers_filter'>
    <%= search_form_for [:admin, @search] do |f| %>
        <div class="form-group">
          <%= f.label :name_cont, Spree.t(:name) %>
          <%= f.text_field :name_cont, :size => 15, class: "form-control" %>
        </div>
      <div class="clear"></div>
      <div class="form-actions" data-hook="admin_suppliers_index_search_buttons">
        <%= button Spree.t(:search), 'search' %>
      </div>
    <% end %>
  </div>
<% end %>

<%# This is a new paginate! %>
<%= render :partial => 'spree/admin/shared/index_table_options', :locals => { :collection => @collection } %>

<% if @collection.any? %>
  <table class="table" id="listing_suppliers">
    <thead>
      <tr data-hook='admin_suppliers_index_headers'>
        <th><%= sort_link @search, :name,  Spree::Supplier.human_attribute_name(:name) %></th>
        <th><%= sort_link @search, :email, Spree::Supplier.human_attribute_name(:email) %></th>
        <th><%= Spree.t(:users) %></th>
        <th><%= sort_link @search, :active, Spree::Supplier.human_attribute_name(:active) %></th>
        <th data-hook="admin_suppliers_index_header_actions" class="actions"></th>
      </tr>
    </thead>
    <tbody>
    <%# Updated classes! %>
      <%- @collection.each do |supplier| %>
        <tr <%= "style='color: red;'" if supplier.deleted? %> id="<%= spree_dom_id supplier %>" data-hook="admin_suppliers_index_rows" class="<%= cycle('odd', 'even') %>">
          <!--todo: Fix this link!-->
          <td><%= link_to supplier.name, edit_object_url(supplier) %></td>
          <td><%= mail_to supplier.email %></td>
          <td><%= supplier.users.pluck(:email).join(', ') %></td>
          <td><%= supplier.active %></td>
          <td class='actions actions-3' data-hook='admin_suppliers_index_row_actions'>
            <% unless supplier.deleted? %>
              <%= link_to_edit supplier, :no_text => true, :class => 'edit' %>
              <%= link_to_delete supplier, :no_text => true %>
            <% end %>
          </td>
        </tr>
      <% end %>
    </tbody>
  </table>
<% else %>
  <%# New alert with link to add new supplier %>
  <div class="alert alert-info no-objects-found">
    <%= Spree.t(:no_resource_found, resource: Spree::Supplier.model_name.human(count: :many)) %>,
    <%= link_to Spree.t(:add_one), spree.new_admin_supplier_path %>!
  </div>
<% end %>

<%# This is a new paginate! %>
<%= render :partial => 'spree/admin/shared/index_table_options', :locals => { :collection => @collection } %>