<div class="ux-toolkit-settings-section">
  <p><strong><%= l(:label_ux_toolkit_text_snippets) %></strong></p>
  <p class="info"><%= l(:text_ux_toolkit_text_snippets_help) %></p>

  <% if UxToolkitTextSnippet.table_available? %>
    <% snippets = UxToolkitTextSnippet.ordered.to_a %>

    <p>
      <%= link_to l(:label_ux_toolkit_new_text_snippet),
                  new_ux_toolkit_text_snippet_path,
                  class: 'icon icon-add' %>
      <%= link_to l(:label_ux_toolkit_manage_text_snippets),
                  ux_toolkit_text_snippets_path,
                  class: 'icon icon-list' %>
    </p>

    <% if snippets.any? %>
      <table class="list ux-toolkit-template-list">
        <thead>
          <tr>
            <th><%= l(:label_ux_toolkit_text_snippet_title) %></th>
            <th><%= l(:label_ux_toolkit_template_enabled) %></th>
            <th><%= l(:field_updated_on) %></th>
            <th></th>
          </tr>
        </thead>
        <tbody>
          <% snippets.each do |snippet| %>
            <tr class="<%= cycle('odd', 'even') %>">
              <td class="name"><%= link_to h(snippet.title), edit_ux_toolkit_text_snippet_path(snippet) %></td>
              <td><%= checked_image snippet.enabled? %></td>
              <td><%= format_time(snippet.updated_at) %></td>
              <td class="buttons">
                <%= link_to l(:button_edit),
                            edit_ux_toolkit_text_snippet_path(snippet),
                            class: 'icon icon-edit' %>
                <% if snippet.enabled? %>
                  <%= link_to l(:button_ux_toolkit_disable),
                              disable_ux_toolkit_text_snippet_path(snippet),
                              method: :post,
                              class: 'icon icon-lock' %>
                <% else %>
                  <%= link_to l(:button_ux_toolkit_enable),
                              enable_ux_toolkit_text_snippet_path(snippet),
                              method: :post,
                              class: 'icon icon-unlock' %>
                <% end %>
                <%= link_to l(:button_delete),
                            ux_toolkit_text_snippet_path(snippet),
                            method: :delete,
                            data: {confirm: l(:text_ux_toolkit_confirm_delete_text_snippet)},
                            class: 'icon icon-del' %>
              </td>
            </tr>
          <% end %>
        </tbody>
      </table>
    <% else %>
      <p class="nodata"><%= l(:text_ux_toolkit_no_text_snippets) %></p>
    <% end %>
  <% else %>
    <p class="nodata"><%= l(:text_ux_toolkit_text_snippets_unavailable) %></p>
  <% end %>
</div>
