bisscomm/refinerycms-products

View on GitHub
app/views/refinery/products/admin/products/_product.html.erb

Summary

Maintainability
Test Coverage
<% # setup params for various action links
  preview_url = refinery.products_product_path(product)
  edit_url = refinery.edit_products_admin_product_path(product)
  delete_url = refinery.products_admin_product_path(product)
  delete_options = {
    class: "cancel confirm-delete",
    data: {
      confirm: t('message',  
        scope: 'refinery.admin.delete', 
        title: product_title_with_translations(product)
      )
    }
  }
%>

<li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= dom_id(product) -%>">
  <span class='title'>
    
    <%= product_title_with_translations product %>
    
    <% if Refinery::I18n.frontend_locales.many? %>
      <span class='locales'>
        <% product.translations.sort_by{ |t| Refinery::I18n.frontend_locales.index(t.locale)}.each do |translation| %>
          <% if translation.title.present? %>
            <%= link_to refinery.edit_products_admin_product_path(product, switch_locale: translation.locale),
                        class: 'locale', title: translation.locale.upcase do %>

              <div class="<%=translation.locale %> locale_marker">
                <%= locale_text_icon(translation.locale.upcase) %>
              </div>
            <% end %>
          <% end %>
        <% end %>
      </span>
    <% end %>

    <span class="preview">
      <%= product.sku %>

      <% if product.draft? %>
        <span class="label notice"><%= t('draft', :scope => 'refinery.products.admin') %></span>
      <% else %>
        <%= product.published_at.strftime('%b %d, %Y') %>
      <% end %>
    </span>
  </span>

  <span class='actions'>
    <%= action_icon(:preview, preview_url, t('.view_live_html')) %>
    <%= action_icon(:edit,    edit_url ,  t('edit',   scope: 'refinery.admin.pages' ) ) %>
    <%= action_icon(:delete,  delete_url, t('delete', scope: 'refinery.admin.pages' ), delete_options ) %>
  </span>
</li>