app/views/spree/admin/promotion_codes/index.html.erb
<%# Place for new code form %>
<% content_for :page_actions do %>
<%= button_link_to(Spree.t(:new_promotion_code),
new_admin_promotion_promotion_code_url,
class: "btn-success",
icon: 'add',
id: 'admin_new_promotion_action') %>
<% end if can? :create, Spree::PromotionCode %>
<% if @collection.any? %>
<table class="table">
<thead data-hook="promotion_codes_header">
<tr>
<th><%= Spree.t(:code) %></th>
<th><%= Spree.t(:disabled) %></th>
<th><%= Spree.t(:times_used) %></th>
<th><%= Spree.t(:usage_limit) %></th>
<th class="actions"></th>
</tr>
</thead>
<tbody>
<% @collection.each do |promotion_code| %>
<tr id="<%= spree_dom_id promotion_code %>" <%= 'style="color:red;"' if promotion_code.disabled? %> data-hook="promotion_codes_row">
<td><%= promotion_code.code %></td>
<td><%= humanize_disabled(promotion_code.disabled) %></td>
<td><%= link_to(promotion_code.times_used_count, admin_orders_path(q: { with_promotion_code: promotion_code.code })) %></td>
<td><%= promotion_code.usage_limit.nil? ? '∞' : promotion_code.usage_limit %></td>
<td class="actions actions-2 text-right">
<%= link_to_edit(promotion_code, no_text: true) if can?(:edit, promotion_code) %>
<%= link_to_delete(promotion_code, no_text: true) if can?(:destroy, promotion_code) && promotion_code.times_used_count <= 0 %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<div class="no-objects-found alert alert-info">
<%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::PromotionCode)) %>,
<%= link_to(Spree.t(:add_one), spree.new_admin_promotion_promotion_code_path(@promotion)) if can? :create, Spree::PromotionCode %>!
</div>
<% end %>