  <% if @product.images.blank? %>
  <div class="callout callout-warning">
    <h4>Brak zdjęć</h4>
    <p>Dla tego produktu.</p>
  </div>
  <% else %>
  <table class="table table-bordered">
    <tbody>
      <tr>
        <th style="width: 150px">Poz</th>
        <th>Zdjęcie</th>
        <th style="width: 100px">Okładka</th>
        <th style="width: 100px">Widoczne</th>
        <th style="width: 100px">Akcje</th>
      </tr>
      <% for image in @product.images.order('position ASC') %>
        <tr>
            <td style="text-align:center; vertical-align:middle;">
              <% if image.position == 1 %>
                <%= link_to raw('<i class="fa fa-caret-square-o-up"></i>'), '#', class: 'btn btn-xs btn-success', remote: true, title: 'Do góry', disabled: 'disabled' %>
              <% else %>
                <%= link_to raw('<i class="fa fa-caret-square-o-up"></i>'), {controller: '/ps_admin/image', action: 'pos_up', id: image.id, product_id: @product.id}, class: 'btn btn-xs btn-success', remote: true, title: 'Do góry' %>
              <% end %>
              <% if image.position >= @product.images.size %>
                <%= link_to raw('<i class="fa fa-caret-square-o-down"></i>'), '#', class: 'btn btn-xs btn-primary', remote: true, title: 'W dół', disabled: 'disabled' %>
              <% else %>
                <%= link_to raw('<i class="fa fa-caret-square-o-down"></i>'), {controller: '/ps_admin/image', action: 'pos_down', id: image.id, product_id: @product.id}, class: 'btn btn-xs btn-primary', remote: true, title: 'W dół' %>
              <% end %>
            </td>
            <td style="text-align:center; vertical-align:middle;">
                <%= image_tag image.image.url(:medium) %>
            </td>
            <td style="text-align:center; vertical-align:middle;"><%= raw image.cover.eql?(true) ? '<h4><i class="fa fa-check text-green"></i></h4>' : link_to(raw('<h4><i class="fa fa-close text-red"></i></h4>'), {controller: '/ps_admin/image', action: 'set_cover', id: image.id, product_id: @product.id, cover: 1}, remote: true) %></td>
            <td style="text-align:center; vertical-align:middle;"><%= raw image.active.eql?(true) ? link_to(raw('<h4><i class="fa fa-eye text-green"></i></h4>'), {controller: '/ps_admin/image', action: 'set_active', id: image.id, product_id: @product.id, active: 0}, remote: true) : link_to(raw('<h4><i class="fa fa-eye-slash text-red"></i></h4>'), {controller: '/ps_admin/image', action: 'set_active', id: image.id, product_id: @product.id, active: 1}, remote: true) %></td>
            <td style="text-align:center; vertical-align:middle;">
            <%= link_to raw('<i class="fa fa-trash"></i> Usuń'), {controller: '/ps_admin/image', action: 'destroy', id: image.id, product_id: @product.id},
                class: "btn btn-danger btn-xs", method: :delete, data: { confirm: "Czy na pewno usunąć zdjęcie?" }, remote: true %>
            </td>
        </tr>
      <% end %>
    </tbody>
  </table>
  <% end %>
