<% if @all_pages.blank? %>
<div class="callout callout-warning">
  <h4>Brak wpisów</h4>

  <p>Dla kategorii Strony.</p>
</div>
<% else %>
  <table class="table table-bordered">
    <tbody>
      <tr>
        <th>Nazwa</th>
        <th>Publiczna/Aktualna</th>
        <th>Tytuł</th>
        <th>Wyświetleń</th>
        <th>Rodzaj</th>
        <th>Data utworzenia</th>
        <th style="width: 200px">Akcje</th>
      </tr>
      <% for ap in @all_pages %>
      <tr>
        <td><%= ap.name %></td>
        <td id="publish_<%= ap.id %>"><%= link_to raw(ap.published_page ? '<span class="badge bg-green" title="Zdejmij publikację">Tak</span>' : '<span class="badge bg-red" title="Opublikuj">Nie</span>'), (ap.published_page ? {controller: '/admin/all_page', action: 'unpublish', id: ap.id} : {controller: '/admin/all_page', action: 'publish', id: ap.id}), remote: true %>/<%= raw(ap.published.eql?(true) ? '<span class="badge bg-green">Tak</span>' : '<span class="badge bg-red">Nie</span>') %></td>
        <td><%= ap.title %></td>
        <th><%= ap.published_page ? ap.published_page.number_of_views : '-' %></th>
        <td><%= AllPage::PAGE_TYPES[ap.type_of] %></td>
        <td><%= ap.updated_at %></td>
        <td>
          <%= link_to raw('<i class="fa fa-edit"></i> Edycja'), {controller: '/admin/all_page', action: 'edit', id: ap.id}, class: 'btn btn-xs btn-info' %>
          <%= link_to raw('<i class="fa fa-trash"></i> Usuń'), {controller: '/admin/all_page', action: 'destroy', id: ap.id}, class: "btn btn-danger btn-xs", method: :delete, data: { confirm: 'Czy na pewno usunąć?' } %>
          <%= link_to raw('<i class="fa fa-search"></i> Podgląd'), {controller: '/site', action: 'preview', id: ap.id}, class: 'btn btn-xs btn-primary', target: '__blank' %>
        </td>
      </tr>
      <% end %>
    </tbody>
  </table>
<% end %>
